2019-04-07 08:10:02 +00:00
|
|
|
#ifndef CSV_RENDER_TERRAINSELECTION_H
|
|
|
|
#define CSV_RENDER_TERRAINSELECTION_H
|
|
|
|
|
2022-10-19 17:02:00 +00:00
|
|
|
#include <string>
|
2019-04-07 08:10:02 +00:00
|
|
|
#include <utility>
|
|
|
|
#include <vector>
|
|
|
|
|
2022-10-19 17:02:00 +00:00
|
|
|
#include <osg/Array>
|
2019-04-07 08:10:02 +00:00
|
|
|
#include <osg/ref_ptr>
|
|
|
|
|
|
|
|
namespace osg
|
|
|
|
{
|
|
|
|
class Group;
|
2022-10-19 17:02:00 +00:00
|
|
|
class Geometry;
|
|
|
|
class PositionAttitudeTransform;
|
2019-04-07 08:10:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace CSVRender
|
|
|
|
{
|
|
|
|
class WorldspaceWidget;
|
|
|
|
|
|
|
|
enum class TerrainSelectionType
|
|
|
|
{
|
|
|
|
Texture,
|
|
|
|
Shape
|
|
|
|
};
|
|
|
|
|
2021-05-18 15:53:00 +00:00
|
|
|
enum class SelectionMethod
|
|
|
|
{
|
|
|
|
OnlySelect,
|
|
|
|
AddSelect,
|
|
|
|
RemoveSelect,
|
|
|
|
ToggleSelect
|
|
|
|
};
|
|
|
|
|
2019-04-07 08:10:02 +00:00
|
|
|
/// \brief Class handling the terrain selection data and rendering
|
|
|
|
class TerrainSelection
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TerrainSelection(osg::Group* parentNode, WorldspaceWidget* worldspaceWidget, TerrainSelectionType type);
|
|
|
|
~TerrainSelection();
|
|
|
|
|
|
|
|
void onlySelect(const std::vector<std::pair<int, int>>& localPositions);
|
|
|
|
void addSelect(const std::vector<std::pair<int, int>>& localPositions);
|
2021-10-03 21:20:39 +00:00
|
|
|
void removeSelect(const std::vector<std::pair<int, int>>& localPositions);
|
|
|
|
void toggleSelect(const std::vector<std::pair<int, int>>& localPositions);
|
2019-04-07 08:10:02 +00:00
|
|
|
void clearTemporarySelection();
|
|
|
|
|
|
|
|
void activate();
|
|
|
|
void deactivate();
|
|
|
|
|
2019-11-03 11:27:27 +00:00
|
|
|
std::vector<std::pair<int, int>> getTerrainSelection() const;
|
|
|
|
|
2019-04-07 08:10:02 +00:00
|
|
|
void update();
|
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
protected:
|
2019-04-07 08:10:02 +00:00
|
|
|
void drawShapeSelection(const osg::ref_ptr<osg::Vec3Array> vertices);
|
|
|
|
void drawTextureSelection(const osg::ref_ptr<osg::Vec3Array> vertices);
|
|
|
|
|
|
|
|
int calculateLandHeight(int x, int y);
|
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
private:
|
2021-10-03 21:20:39 +00:00
|
|
|
void handleSelection(const std::vector<std::pair<int, int>>& localPositions, SelectionMethod selectionMethod);
|
2021-05-18 15:53:00 +00:00
|
|
|
|
2019-11-03 21:57:35 +00:00
|
|
|
bool noCell(const std::string& cellId);
|
|
|
|
|
|
|
|
bool noLand(const std::string& cellId);
|
|
|
|
|
|
|
|
bool noLandLoaded(const std::string& cellId);
|
|
|
|
|
|
|
|
bool isLandLoaded(const std::string& cellId);
|
2021-10-02 11:23:43 +00:00
|
|
|
|
2019-04-07 08:10:02 +00:00
|
|
|
osg::Group* mParentNode;
|
|
|
|
WorldspaceWidget* mWorldspaceWidget;
|
|
|
|
osg::ref_ptr<osg::PositionAttitudeTransform> mBaseNode;
|
|
|
|
osg::ref_ptr<osg::Geometry> mGeometry;
|
|
|
|
osg::ref_ptr<osg::Group> mSelectionNode;
|
|
|
|
std::vector<std::pair<int, int>>
|
|
|
|
mSelection; // Global terrain selection coordinate in either vertex or texture units
|
|
|
|
std::vector<std::pair<int, int>>
|
|
|
|
mTemporarySelection; // Used during toggle to compare the most recent drag operation
|
|
|
|
TerrainSelectionType mSelectionType;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|