Update cell marker appearance

- Added bounding box around marker text. Box is black when cell exists
  otherwise it is red.

- Changed format of marker text.

- Changed marker text's pivot point to be at center of text.
move
Rob Cutmore 9 years ago
parent 61b6806a62
commit 25744aaadd

@ -307,7 +307,13 @@ void CSVRender::Cell::setCellArrows (int mask)
void CSVRender::Cell::setCellMarker()
{
mCellMarker.reset(new CellMarker(mCellNode, mCoordinates));
bool cellExists = false;
int cellIndex = mData.getCells().searchId(mId);
if (cellIndex > -1)
{
cellExists = !mData.getCells().getRecord(cellIndex).isDeleted();
}
mCellMarker.reset(new CellMarker(mCellNode, mCoordinates, cellExists));
}
CSMWorld::CellCoordinates CSVRender::Cell::getCoordinates() const

@ -22,14 +22,27 @@ void CSVRender::CellMarker::buildMarker()
{
const int characterSize = 20;
// Set up marker text containing cell's coordinates.
// Set up attributes of marker text.
osg::ref_ptr<osgText::Text> markerText (new osgText::Text);
markerText->setBackdropType(osgText::Text::OUTLINE);
markerText->setLayout(osgText::Text::LEFT_TO_RIGHT);
markerText->setCharacterSize(characterSize);
markerText->setAlignment(osgText::Text::CENTER_CENTER);
markerText->setDrawMode(osgText::Text::TEXT | osgText::Text::FILLEDBOUNDINGBOX);
// If cell exists then show black bounding box otherwise show red.
if (mExists)
{
markerText->setBoundingBoxColor(osg::Vec4f(0.0f, 0.0f, 0.0f, 1.0f));
}
else
{
markerText->setBoundingBoxColor(osg::Vec4f(1.0f, 0.0f, 0.0f, 1.0f));
}
// Add text containing cell's coordinates.
std::string coordinatesText =
"#" + boost::lexical_cast<std::string>(mCoordinates.getX()) +
" " + boost::lexical_cast<std::string>(mCoordinates.getY());
boost::lexical_cast<std::string>(mCoordinates.getX()) + "," +
boost::lexical_cast<std::string>(mCoordinates.getY());
markerText->setText(coordinatesText);
// Add text to marker node.
@ -51,9 +64,11 @@ void CSVRender::CellMarker::positionMarker()
CSVRender::CellMarker::CellMarker(
osg::Group *cellNode,
const CSMWorld::CellCoordinates& coordinates
const CSMWorld::CellCoordinates& coordinates,
const bool cellExists
) : mCellNode(cellNode),
mCoordinates(coordinates)
mCoordinates(coordinates),
mExists(cellExists)
{
// Set up node for cell marker.
mMarkerNode = new osg::AutoTransform();

@ -38,6 +38,7 @@ namespace CSVRender
osg::Group* mCellNode;
osg::ref_ptr<osg::AutoTransform> mMarkerNode;
CSMWorld::CellCoordinates mCoordinates;
bool mExists;
// Not implemented.
CellMarker(const CellMarker&);
@ -46,7 +47,7 @@ namespace CSVRender
/// \brief Build marker containing cell's coordinates.
void buildMarker();
/// \brief Position marker above center of cell.
/// \brief Position marker at center of cell.
void positionMarker();
public:
@ -54,9 +55,11 @@ namespace CSVRender
/// \brief Constructor.
/// \param cellNode Cell to create marker for.
/// \param coordinates Coordinates of cell.
/// \param cellExists Whether or not cell exists.
CellMarker(
osg::Group *cellNode,
const CSMWorld::CellCoordinates& coordinates);
const CSMWorld::CellCoordinates& coordinates,
const bool cellExists);
~CellMarker();
};

Loading…
Cancel
Save