cee::vis::MarkupModel

class MarkupModel : public Model

Model used for drawing labels, arrows, lines, points, triangles and glyphs.

../_images/markup.png

The MarkupModel enables the user to draw custom markup figures and texts into the model. The markup model can, for instance, be used to:

  • Draw measure lines (distance/angle/…)

  • Add annotations as labels

  • Position 2D symbols in the model (Glyphs)

MarkupModel is a subclass of Model.

A View object has a collection of models. Add a model to the view with View::addModel().

The markup model has several drawing tools:

  • Label(s)MarkupPartLabels can be added with text, background and border. Labels can have a user defined text-, border- and background color. The defaults are black text and border on a yellow background. Multiple labels can be added to a single part, sharing the same settings.

  • Arrow(s)MarkupPartArrows can be added by setting a start position, an end position, and a color. The head of the arrow will be in the end position. Multiple arrows can be added to the same part sharing the color.

  • TrianglesMarkupPartTriangles can be added with color and opacity. Multiple triangles can be added to the same part sharing the same settings.

  • Line(s)MarkupPartLines can be added by specifying a start- and end position, a color, and the line width. Multiple lines can be added to the same part sharing the same settings.

  • Point(s)MarkupPartPoints can be added by specifying a position, a color and a point size. Multiple points can be added to the same part, sharing the same settings.

  • Fixed Size SphereMarkupPartFixedSizeSphere can be added by specifying a position, color and a size in pixels (radius). The sphere will have a constant pixel size when navigating in the view.

  • Fixed Size ArrowMarkupPartFixedSizeArrow can be added by specifying a position, a direction and a size in pixels (length of arrow). The arrow will have a constant pixel size when navigating in the view.

  • Fixed Size GlyphMarkupPartFixedSizeGlyph can be added by specifying an image, a position and a size in pixels (longest edge of the image). The glyph image will have a constant pixel size when navigating in the view.

The markup model provides a rayIntersect() method to support picking or selection.

Example

Reads and setup a model from file. Uses the values from the model’s bounding box to draw a bounding box as a markup model. The markup model is drawn as yellow lines.

Create the markup model object.

cee::PtrRef<cee::vis::MarkupModel> markupModel = new cee::vis::MarkupModel();

Get the bounding box from the view and get all vertices in the box.

cee::BoundingBox bb = view->boundingBox();
cee::Vec3d p1(bb.minimum().x(), bb.minimum().y(), bb.minimum().z());
cee::Vec3d p2(bb.minimum().x(), bb.maximum().y(), bb.minimum().z());
cee::Vec3d p3(bb.minimum().x(), bb.maximum().y(), bb.maximum().z());
cee::Vec3d p4(bb.minimum().x(), bb.minimum().y(), bb.maximum().z());
cee::Vec3d p5(bb.maximum().x(), bb.minimum().y(), bb.minimum().z());
cee::Vec3d p6(bb.maximum().x(), bb.maximum().y(), bb.minimum().z());
cee::Vec3d p7(bb.maximum().x(), bb.maximum().y(), bb.maximum().z());
cee::Vec3d p8(bb.maximum().x(), bb.minimum().y(), bb.maximum().z());

Add all the lines of the bounding box to the model.

cee::PtrRef<cee::vis::MarkupPartLines> part = new cee::vis::MarkupPartLines(cee::Color3f(1.0, 1.0, 0.0), 3, true, 0.0);
part->add(p1, p2);
part->add(p2, p3);
part->add(p3, p4);
part->add(p4, p1);
part->add(p1, p5);
part->add(p2, p6);
part->add(p3, p7);
part->add(p4, p8);
part->add(p5, p6);
part->add(p6, p7);
part->add(p7, p8);
part->add(p8, p5);
markupModel->addPart(part.get());

Add the markup model to the view

View->addModel(markupModel.get());

See the complete source code here: Visualization: Draw bounding box using markup model

Visualization: Draw bounding box using markup model

Subclassed by BoxLocator, PlaneLocator

Public Functions

MarkupModel()

Creates empty markup model.

size_t partCount() const

Returns the number of parts in the model.

size_t partIndex(MarkupPart *part) const

Returns the index of the specified part.

MarkupPart *part(size_t index)

Returns the part at the given index.

const MarkupPart *part(size_t index) const

Returns a const pointer to the part at the given index.

void addPart(MarkupPart *part)

Adds the part to the model.

void removePart(MarkupPart *part)

Removes the specified part from the model.

void removeAllParts()

Removes all parts from the model.

virtual BoundingBox boundingBox()

Returns the current bounding box of the model.

virtual Str modelInfo() const

Returns information about the model.

size_t rayIntersect(const Ray &ray, const View &view)

Returns the index of the part hit by the ray.

Returns cee::UNDEFINED_SIZE_T if no hit.

bool rayIntersect(const Ray &ray, const View &view, MarkupModelHitItem *hitItem)

Performs a ray intersect on the parts in the model.

If there is a hit, the provided hitItem will be updated with the markup part details of the closest part

Returns false if no hit.

bool rayIntersectAllHits(const Ray &ray, const View &view, MarkupModelHitItemCollection *hitItems)

Performs a ray intersect on the parts in the model, returning all parts that was intersected by the ray.

If there is a hit, the provided hitItem collection will be updated with the all the hit parts.

Returns false if no hit.

bool isViewClippingIgnored() const

Returns true if this model is configured to ignore view clipping.

void setIgnoreViewClipping(bool ignore)

Set if view clipping should be ignored for all parts in this model.

This will disable any clipping planes specified in the view for the this model