1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-22 15:23:58 +00:00
openmw/apps/opencs/view/render/pagedworldspacewidget.hpp

219 lines
7.3 KiB
C++
Raw Normal View History

#ifndef OPENCS_VIEW_PAGEDWORLDSPACEWIDGET_H
#define OPENCS_VIEW_PAGEDWORLDSPACEWIDGET_H
#include <map>
2022-10-19 17:02:00 +00:00
#include <string>
#include <utility>
#include <vector>
#include <apps/opencs/model/world/cellcoordinates.hpp>
#include "../../model/world/cellselection.hpp"
#include "cell.hpp"
#include "instancedragmodes.hpp"
2022-09-22 18:26:05 +00:00
#include "worldspacewidget.hpp"
2022-10-19 17:02:00 +00:00
class QModelIndex;
class QObject;
class QWidget;
namespace osg
{
class Vec3f;
template <class T>
class ref_ptr;
}
namespace CSMDoc
{
class Document;
}
namespace CSMWorld
{
class UniversalId;
}
2014-11-28 08:14:02 +00:00
namespace CSVWidget
{
2022-09-22 18:26:05 +00:00
class SceneToolToggle2;
2022-10-19 17:02:00 +00:00
class SceneToolMode;
class SceneToolBar;
2014-11-28 08:14:02 +00:00
}
2014-11-28 08:14:02 +00:00
namespace CSVRender
{
2022-10-19 17:02:00 +00:00
class Cell;
class TagBase;
class PagedWorldspaceWidget : public WorldspaceWidget
{
2022-09-22 18:26:05 +00:00
Q_OBJECT
2022-09-22 18:26:05 +00:00
CSMDoc::Document& mDocument;
CSMWorld::CellSelection mSelection;
std::map<CSMWorld::CellCoordinates, Cell*> mCells;
std::string mWorldspace;
CSVWidget::SceneToolToggle2* mControlElements;
bool mDisplayCellCoord;
2022-09-22 18:26:05 +00:00
private:
std::pair<int, int> getCoordinatesFromId(const std::string& record) const;
2022-09-22 18:26:05 +00:00
/// Bring mCells into sync with mSelection again.
///
/// \return Any cells added or removed?
bool adjustCells();
2022-09-22 18:26:05 +00:00
void referenceableDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight) override;
2022-09-22 18:26:05 +00:00
void referenceableAboutToBeRemoved(const QModelIndex& parent, int start, int end) override;
2022-09-22 18:26:05 +00:00
void referenceableAdded(const QModelIndex& index, int start, int end) override;
2022-09-22 18:26:05 +00:00
void referenceDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight) override;
2016-05-03 02:08:49 +00:00
2022-09-22 18:26:05 +00:00
void referenceAboutToBeRemoved(const QModelIndex& parent, int start, int end) override;
2016-05-03 02:08:49 +00:00
2022-09-22 18:26:05 +00:00
void referenceAdded(const QModelIndex& index, int start, int end) override;
2016-05-03 02:08:49 +00:00
2022-09-22 18:26:05 +00:00
void pathgridDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight) override;
2022-09-22 18:26:05 +00:00
void pathgridAboutToBeRemoved(const QModelIndex& parent, int start, int end) override;
2022-09-22 18:26:05 +00:00
void pathgridAdded(const QModelIndex& parent, int start, int end) override;
2022-09-22 18:26:05 +00:00
std::string getStartupInstruction() override;
2022-09-22 18:26:05 +00:00
/// \note Does not update the view or any cell marker
void addCellToScene(const CSMWorld::CellCoordinates& coordinates);
2022-09-22 18:26:05 +00:00
/// \note Does not update the view or any cell marker
///
/// \note Calling this function for a cell that is not in the selection is a no-op.
void removeCellFromScene(const CSMWorld::CellCoordinates& coordinates);
2022-09-22 18:26:05 +00:00
/// \note Does not update the view or any cell marker
void addCellSelection(int x, int y);
2022-09-22 18:26:05 +00:00
/// \note Does not update the view or any cell marker
void moveCellSelection(int x, int y);
2022-09-22 18:26:05 +00:00
void addCellToSceneFromCamera(int offsetX, int offsetY);
2017-08-19 23:36:45 +00:00
2022-09-22 18:26:05 +00:00
public:
PagedWorldspaceWidget(QWidget* parent, CSMDoc::Document& document);
///< \note Sets the cell area selection to an invalid value to indicate that currently
/// no cells are displayed. The cells to be displayed will be specified later through
/// hint system.
2022-09-22 18:26:05 +00:00
virtual ~PagedWorldspaceWidget();
2022-09-22 18:26:05 +00:00
/// Decodes the the hint string to set of cell that are rendered.
void useViewHint(const std::string& hint) override;
2022-09-22 18:26:05 +00:00
void setCellSelection(const CSMWorld::CellSelection& selection);
2022-09-22 18:26:05 +00:00
const CSMWorld::CellSelection& getCellSelection() const;
2014-05-03 12:00:30 +00:00
2022-09-22 18:26:05 +00:00
/// \return Drop handled?
bool handleDrop(const std::vector<CSMWorld::UniversalId>& data, DropType type) override;
2022-09-22 18:26:05 +00:00
dropRequirments getDropRequirements(DropType type) const override;
2014-05-03 12:00:30 +00:00
2022-09-22 18:26:05 +00:00
/// \attention The created tool is not added to the toolbar (via addTool). Doing
/// that is the responsibility of the calling function.
virtual CSVWidget::SceneToolToggle2* makeControlVisibilitySelector(CSVWidget::SceneToolbar* parent);
2022-09-22 18:26:05 +00:00
unsigned int getVisibilityMask() const override;
2016-05-16 21:03:00 +00:00
2022-09-22 18:26:05 +00:00
/// \param elementMask Elements to be affected by the clear operation
void clearSelection(int elementMask) override;
2022-09-22 18:26:05 +00:00
/// \param elementMask Elements to be affected by the select operation
void invertSelection(int elementMask) override;
2022-09-22 18:26:05 +00:00
/// \param elementMask Elements to be affected by the select operation
void selectAll(int elementMask) override;
2022-09-22 18:26:05 +00:00
// Select everything that references the same ID as at least one of the elements
// already selected
//
/// \param elementMask Elements to be affected by the select operation
void selectAllWithSameParentId(int elementMask) override;
2022-09-22 18:26:05 +00:00
void selectInsideCube(const osg::Vec3d& pointA, const osg::Vec3d& pointB, DragMode dragMode) override;
2022-09-22 18:26:05 +00:00
void selectWithinDistance(const osg::Vec3d& point, float distance, DragMode dragMode) override;
2022-09-22 18:26:05 +00:00
std::string getCellId(const osg::Vec3f& point) const override;
2019-09-11 09:59:15 +00:00
2022-09-22 18:26:05 +00:00
Cell* getCell(const osg::Vec3d& point) const override;
2019-09-11 09:59:15 +00:00
2022-09-22 18:26:05 +00:00
Cell* getCell(const CSMWorld::CellCoordinates& coords) const override;
2019-09-11 09:59:15 +00:00
2022-09-22 18:26:05 +00:00
void setCellAlteredHeight(const CSMWorld::CellCoordinates& coords, int inCellX, int inCellY, float height);
2019-09-11 09:59:15 +00:00
2022-09-22 18:26:05 +00:00
float* getCellAlteredHeight(const CSMWorld::CellCoordinates& coords, int inCellX, int inCellY);
2022-09-22 18:26:05 +00:00
void resetAllAlteredHeights();
2016-02-16 15:02:29 +00:00
2022-11-04 22:04:42 +00:00
osg::ref_ptr<TagBase> getSnapTarget(unsigned int elementMask) const override;
2022-09-22 18:26:05 +00:00
std::vector<osg::ref_ptr<TagBase>> getSelection(unsigned int elementMask) const override;
2016-03-01 14:48:34 +00:00
void selectGroup(const std::vector<std::string>& group) const override;
void unhideAll() const override;
2022-09-22 18:26:05 +00:00
std::vector<osg::ref_ptr<TagBase>> getEdited(unsigned int elementMask) const override;
2016-03-04 14:19:26 +00:00
2022-09-22 18:26:05 +00:00
void setSubMode(int subMode, unsigned int elementMask) override;
2022-09-22 18:26:05 +00:00
/// Erase all overrides and restore the visual representation to its true state.
void reset(unsigned int elementMask) override;
2022-09-22 18:26:05 +00:00
protected:
void addVisibilitySelectorButtons(CSVWidget::SceneToolToggle2* tool) override;
2014-11-13 09:45:59 +00:00
2022-09-22 18:26:05 +00:00
void addEditModeSelectorButtons(CSVWidget::SceneToolMode* tool) override;
2022-09-22 18:26:05 +00:00
void handleInteractionPress(const WorldspaceHitResult& hit, InteractionType type) override;
2022-09-22 18:26:05 +00:00
signals:
2022-09-22 18:26:05 +00:00
void cellSelectionChanged(const CSMWorld::CellSelection& selection);
2022-09-22 18:26:05 +00:00
private slots:
2022-09-22 18:26:05 +00:00
virtual void cellDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight);
2022-09-22 18:26:05 +00:00
virtual void cellRemoved(const QModelIndex& parent, int start, int end);
2022-09-22 18:26:05 +00:00
virtual void cellAdded(const QModelIndex& index, int start, int end);
2022-09-22 18:26:05 +00:00
virtual void landDataChanged(const QModelIndex& topLeft, const QModelIndex& botomRight);
virtual void landAboutToBeRemoved(const QModelIndex& parent, int start, int end);
virtual void landAdded(const QModelIndex& parent, int start, int end);
2022-09-22 18:26:05 +00:00
virtual void landTextureDataChanged(const QModelIndex& topLeft, const QModelIndex& botomRight);
virtual void landTextureAboutToBeRemoved(const QModelIndex& parent, int start, int end);
virtual void landTextureAdded(const QModelIndex& parent, int start, int end);
2017-08-19 23:36:45 +00:00
2022-09-22 18:26:05 +00:00
void assetTablesChanged();
2022-09-22 18:26:05 +00:00
void loadCameraCell();
2022-09-22 18:26:05 +00:00
void loadEastCell();
2022-09-22 18:26:05 +00:00
void loadNorthCell();
2022-09-22 18:26:05 +00:00
void loadWestCell();
2022-09-22 18:26:05 +00:00
void loadSouthCell();
};
}
#endif