INET Framework for OMNeT++/OMNEST
inet::osg::LineNode Class Reference

#include <OsgUtils.h>

Inheritance diagram for inet::osg::LineNode:

Public Member Functions

 LineNode (const Coord &start, const Coord &end, cFigure::Arrowhead startArrowhead, cFigure::Arrowhead endArrowhead, double lineWidth)
 
void setStart (const Coord &start)
 
void setEnd (const Coord &end)
 

Protected Member Functions

Geode * getLineGeode ()
 
Geode * getStartArrowheadGeode ()
 
Geode * getEndArrowheadGeode ()
 
Geometry * getLineGeometry ()
 
Geometry * getStartArrowheadGeometry ()
 
Geometry * getEndArrowheadGeometry ()
 
AutoTransform * getStartArrowheadAutoTransform ()
 
AutoTransform * getEndArrowheadAutoTransform ()
 

Protected Attributes

double lineWidth
 
cFigure::Arrowhead startArrowhead
 
cFigure::Arrowhead endArrowhead
 

Constructor & Destructor Documentation

◆ LineNode()

inet::osg::LineNode::LineNode ( const Coord start,
const Coord end,
cFigure::Arrowhead  startArrowhead,
cFigure::Arrowhead  endArrowhead,
double  lineWidth 
)
330  :
334 {
335  auto line = inet::osg::createLineGeometry(start, end);
336  auto geode = new osg::Geode();
337  geode->addDrawable(line);
338  addChild(geode);
339  if (startArrowhead)
340  addChild(createArrowhead(end, start, 10 + 2 * lineWidth, 20 + 2 * lineWidth));
341  if (endArrowhead)
342  addChild(createArrowhead(start, end, 10 + 2 * lineWidth, 20 + 2 * lineWidth));
343 }

Member Function Documentation

◆ getEndArrowheadAutoTransform()

AutoTransform* inet::osg::LineNode::getEndArrowheadAutoTransform ( )
inlineprotected
81 { return static_cast<AutoTransform *>(getChild(startArrowhead ? 2 : 1)); }

◆ getEndArrowheadGeode()

Geode* inet::osg::LineNode::getEndArrowheadGeode ( )
inlineprotected
74 { return static_cast<Geode *>(getEndArrowheadAutoTransform()->getChild(0)); }

◆ getEndArrowheadGeometry()

Geometry* inet::osg::LineNode::getEndArrowheadGeometry ( )
inlineprotected
78 { return static_cast<Geometry *>(getEndArrowheadGeode()->getDrawable(0)); }

◆ getLineGeode()

Geode* inet::osg::LineNode::getLineGeode ( )
inlineprotected
72 { return static_cast<Geode *>(getChild(0)); }

◆ getLineGeometry()

Geometry* inet::osg::LineNode::getLineGeometry ( )
inlineprotected
76 { return static_cast<Geometry *>(getLineGeode()->getDrawable(0)); }

Referenced by setEnd(), and setStart().

◆ getStartArrowheadAutoTransform()

AutoTransform* inet::osg::LineNode::getStartArrowheadAutoTransform ( )
inlineprotected
80 { return static_cast<AutoTransform *>(getChild(1)); }

◆ getStartArrowheadGeode()

Geode* inet::osg::LineNode::getStartArrowheadGeode ( )
inlineprotected
73 { return static_cast<Geode *>(getStartArrowheadAutoTransform()->getChild(0)); }

◆ getStartArrowheadGeometry()

Geometry* inet::osg::LineNode::getStartArrowheadGeometry ( )
inlineprotected
77 { return static_cast<Geometry *>(getStartArrowheadGeode()->getDrawable(0)); }

◆ setEnd()

void inet::osg::LineNode::setEnd ( const Coord end)
361 {
362  auto line = getLineGeometry();
363  auto vertices = static_cast<osg::Vec3Array *>(line->getVertexArray());
364  vertices->at(1) = inet::osg::toVec3d(end);
365  line->dirtyBound();
366  line->dirtyDisplayList();
367  if (endArrowhead) {
368  // TODO suboptimal
369  removeChild(startArrowhead ? 2 : 1);
370  auto start = inet::osg::toCoord(vertices->at(0));
371  addChild(createArrowhead(start, end, 10 + 2 * lineWidth, 20 + 2 * lineWidth));
372  }
373 }

◆ setStart()

void inet::osg::LineNode::setStart ( const Coord start)
346 {
347  auto line = getLineGeometry();
348  auto vertices = static_cast<osg::Vec3Array *>(line->getVertexArray());
349  vertices->at(0) = inet::osg::toVec3d(start);
350  line->dirtyBound();
351  line->dirtyDisplayList();
352  if (startArrowhead) {
353  // TODO suboptimal
354  removeChild(1);
355  auto end = inet::osg::toCoord(vertices->at(1));
356  addChild(createArrowhead(end, start, 10 + 2 * lineWidth, 20 + 2 * lineWidth));
357  }
358 }

Member Data Documentation

◆ endArrowhead

cFigure::Arrowhead inet::osg::LineNode::endArrowhead
protected

Referenced by LineNode(), and setEnd().

◆ lineWidth

double inet::osg::LineNode::lineWidth
protected

Referenced by LineNode(), setEnd(), and setStart().

◆ startArrowhead

cFigure::Arrowhead inet::osg::LineNode::startArrowhead
protected

Referenced by LineNode(), setEnd(), and setStart().


The documentation for this class was generated from the following files:
inet::osg::toCoord
Coord toCoord(const Vec3d &vec3d)
Definition: OsgUtils.h:33
inet::osg::LineNode::getLineGeode
Geode * getLineGeode()
Definition: OsgUtils.h:72
inet::osg::LineNode::startArrowhead
cFigure::Arrowhead startArrowhead
Definition: OsgUtils.h:68
inet::osg::LineNode::getStartArrowheadGeode
Geode * getStartArrowheadGeode()
Definition: OsgUtils.h:73
inet::osg::LineNode::endArrowhead
cFigure::Arrowhead endArrowhead
Definition: OsgUtils.h:69
inet::osg::createLineGeometry
Geometry * createLineGeometry(const Coord &start, const Coord &end)
Definition: OsgUtils.cc:57
inet::osg::toVec3d
Vec3d toVec3d(const Coord &coord)
Definition: OsgUtils.h:32
inet::osg::createArrowhead
osg::Node * createArrowhead(const Coord &start, const Coord &end, double width, double height)
Definition: OsgUtils.cc:159
inet::osg::LineNode::getEndArrowheadGeode
Geode * getEndArrowheadGeode()
Definition: OsgUtils.h:74
inet::osg::LineNode::getLineGeometry
Geometry * getLineGeometry()
Definition: OsgUtils.h:76
inet::osg::LineNode::getEndArrowheadAutoTransform
AutoTransform * getEndArrowheadAutoTransform()
Definition: OsgUtils.h:81
inet::osg::LineNode::getStartArrowheadAutoTransform
AutoTransform * getStartArrowheadAutoTransform()
Definition: OsgUtils.h:80
inet::osg::LineNode::lineWidth
double lineWidth
Definition: OsgUtils.h:67