diff --git a/apps/opencs/model/world/cellcoordinates.hpp b/apps/opencs/model/world/cellcoordinates.hpp index f8851a6d9..6ff4e4b5d 100644 --- a/apps/opencs/model/world/cellcoordinates.hpp +++ b/apps/opencs/model/world/cellcoordinates.hpp @@ -38,7 +38,9 @@ namespace CSMWorld /// \note The worldspace part of \a id is ignored static std::pair fromId (const std::string& id); + /// \return cell coordinates such that given world coordinates are in it. static std::pair coordinatesToCellIndex (float x, float y); + }; bool operator== (const CellCoordinates& left, const CellCoordinates& right); diff --git a/apps/opencs/view/render/pagedworldspacewidget.cpp b/apps/opencs/view/render/pagedworldspacewidget.cpp index ab2e252af..a9d71626d 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.cpp +++ b/apps/opencs/view/render/pagedworldspacewidget.cpp @@ -19,6 +19,7 @@ #include "editmode.hpp" #include "mask.hpp" +#include "cameracontroller.hpp" bool CSVRender::PagedWorldspaceWidget::adjustCells() { @@ -512,12 +513,15 @@ void CSVRender::PagedWorldspaceWidget::useViewHint (const std::string& hint) { char ignore1; // : or ; char ignore2; // # + // Current coordinate int x, y; + // Loop throught all the coordinates to add them to selection while (stream >> ignore1 >> ignore2 >> x >> y) selection.add (CSMWorld::CellCoordinates (x, y)); - - /// \todo adjust camera position + + // Mark that camera needs setup + mCamPositionSet=false; } } else if (hint[0]=='r') diff --git a/apps/opencs/view/render/pagedworldspacewidget.hpp b/apps/opencs/view/render/pagedworldspacewidget.hpp index b963c6144..c25877e02 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.hpp +++ b/apps/opencs/view/render/pagedworldspacewidget.hpp @@ -85,6 +85,7 @@ namespace CSVRender virtual ~PagedWorldspaceWidget(); + /// Decodes the the hint string to set of cell that are rendered. void useViewHint (const std::string& hint); void setCellSelection(const CSMWorld::CellSelection& selection); diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index db0637a24..5d7a296cd 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -32,7 +32,7 @@ RenderWidget::RenderWidget(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f) , mRootNode(0) { - + osgViewer::CompositeViewer& viewer = CompositeViewer::get(); osg::DisplaySettings* ds = osg::DisplaySettings::instance().get(); diff --git a/apps/opencs/view/render/scenewidget.hpp b/apps/opencs/view/render/scenewidget.hpp index 723d93c00..001494ab3 100644 --- a/apps/opencs/view/render/scenewidget.hpp +++ b/apps/opencs/view/render/scenewidget.hpp @@ -7,15 +7,14 @@ #include #include -#include -#include - #include #include "lightingday.hpp" #include "lightingnight.hpp" #include "lightingbright.hpp" +#include +#include namespace Resource { @@ -54,7 +53,6 @@ namespace CSVRender RenderWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); virtual ~RenderWidget(); - /// Initiates a request to redraw the view void flagAsModified(); void setVisibilityMask(int mask); @@ -64,16 +62,13 @@ namespace CSVRender protected: osg::ref_ptr mView; - osg::ref_ptr mRootNode; - - QTimer mTimer; - protected slots: + osg::Group* mRootNode; - void toggleRenderStats(); + QTimer mTimer; }; - /// Extension of RenderWidget to support lighting mode selection & toolbar + // Extension of RenderWidget to support lighting mode selection & toolbar class SceneWidget : public RenderWidget { Q_OBJECT @@ -95,8 +90,18 @@ namespace CSVRender void setAmbient(const osg::Vec4f& ambient); + virtual void mousePressEvent (QMouseEvent *event); + virtual void mouseReleaseEvent (QMouseEvent *event); virtual void mouseMoveEvent (QMouseEvent *event); virtual void wheelEvent (QWheelEvent *event); + virtual void keyPressEvent (QKeyEvent *event); + virtual void keyReleaseEvent (QKeyEvent *event); + virtual void focusOutEvent (QFocusEvent *event); + + /// \return Is \a key a button mapping setting? (ignored otherwise) + virtual bool storeMappingSetting (const CSMPrefs::Setting *setting); + + std::string mapButton (QMouseEvent *event); boost::shared_ptr mResourceSystem; @@ -109,15 +114,17 @@ namespace CSVRender LightingBright mLightingBright; int mPrevMouseX, mPrevMouseY; - - FreeCameraController* mFreeCamControl; - OrbitCameraController* mOrbitCamControl; + std::string mMouseMode; + std::auto_ptr mFreeCamControl; + std::auto_ptr mOrbitCamControl; CameraController* mCurrentCamControl; - - private: + /// Tells update that camera isn't set bool mCamPositionSet; + std::map, std::string> mButtonMapping; + public slots: + /// \note Remember set the camera before running void update(double dt); protected slots: