INET Framework for OMNeT++/OMNEST
inet::cPanelFigure Class Reference

Sets up an axis-aligned, unscaled coordinate system for children, canceling the effect of any transformation (scaling, rotation, etc.) inherited from ancestor figures. More...

#include <cPanelFigure.h>

Inheritance diagram for inet::cPanelFigure:

Public Member Functions

Constructors, destructor, assignment.
 cPanelFigure (const char *name=nullptr)
 
 cPanelFigure (const cPanelFigure &other)
 
cPanelFigureoperator= (const cPanelFigure &other)
 
Redefined cObject and cFigure member functions.
virtual cPanelFiguredup () const override
 
virtual std::string str () const override
 
virtual const char * getRendererClassName () const override
 
virtual void updateParentTransform (Transform &transform) override
 
virtual void move (double dx, double dy) override
 
virtual void moveLocal (double dx, double dy) override
 
Figure attributes
virtual const Point & getPosition () const
 
virtual void setPosition (const Point &position)
 
virtual const Point & getAnchorPoint () const
 By default, the (0,0) point in cPanelFigure's coordinate system will be mapped to the given position (i.e. More...
 
virtual void setAnchorPoint (const Point &anchorPoint)
 

Protected Member Functions

virtual const char ** getAllowedPropertyKeys () const override
 
virtual void parse (cProperty *property) override
 

Private Member Functions

void copy (const cPanelFigure &other)
 

Private Attributes

Point position
 
Point anchorPoint
 

Detailed Description

Sets up an axis-aligned, unscaled coordinate system for children, canceling the effect of any transformation (scaling, rotation, etc.) inherited from ancestor figures.

This allows pixel-based positioning of children, and makes them immune to zooming. The anchorPoint in the coordinate system is mapped to the position of the panel figure. Setting a transformation on the panel figure itself allows rotation, scaling, and skewing of the coordinate system. The anchorPoint is affected by this transformation.

The panel figure itself has no visual appearance.

Constructor & Destructor Documentation

inet::cPanelFigure::cPanelFigure ( const char *  name = nullptr)
inlineexplicit
54 : cFigure(name) {}
inet::cPanelFigure::cPanelFigure ( const cPanelFigure other)
inline
55 : cFigure(other) {copy(other);}
void copy(const cPanelFigure &other)
Definition: cPanelFigure.cc:33

Member Function Documentation

void inet::cPanelFigure::copy ( const cPanelFigure other)
private
34 {
35  setPosition(other.getPosition());
36  setAnchorPoint(other.getAnchorPoint());
37 }
virtual void setAnchorPoint(const Point &anchorPoint)
Definition: cPanelFigure.h:84
virtual void setPosition(const Point &position)
Definition: cPanelFigure.h:72
virtual cPanelFigure* inet::cPanelFigure::dup ( ) const
inlineoverridevirtual
61 {return new cPanelFigure(*this);}
cPanelFigure(const char *name=nullptr)
Definition: cPanelFigure.h:54
const char ** inet::cPanelFigure::getAllowedPropertyKeys ( ) const
overrideprotectedvirtual
63 {
64  static const char *keys[32];
65  if (!keys[0]) {
66  const char *localKeys[] = { PKEY_POS, PKEY_ANCHORPOINT, nullptr};
67  concatArrays(keys, cFigure::getAllowedPropertyKeys(), localKeys);
68  }
69  return keys;
70 }
std::vector< K > keys(const std::map< K, V > &m)
Definition: stlutils.h:96
virtual const Point& inet::cPanelFigure::getAnchorPoint ( ) const
inlinevirtual

By default, the (0,0) point in cPanelFigure's coordinate system will be mapped to the given position (i.e.

getPosition()) in the parent figure's coordinate system. By setting an anchorPoint, one can change (0,0) to an arbitrary point. E.g. by setting anchorPoint=(100,0), the (100,0) point will be mapped to the given position, i.e. panel contents will appear 100 pixels to the left (given there are no transforms set). The translation part of the local transform is cancelled out because the anchorPoint is subject to the transformation of the panel figure the same way as the child figures.

Referenced by copy().

83 {return anchorPoint;}
Point anchorPoint
Definition: cPanelFigure.h:45
virtual const Point& inet::cPanelFigure::getPosition ( ) const
inlinevirtual

Referenced by copy().

71 {return position;}
Point position
Definition: cPanelFigure.h:44
virtual const char* inet::cPanelFigure::getRendererClassName ( ) const
inlineoverridevirtual
63 {return "GroupFigureRenderer";} // just so it will have a QGraphicsLayer (avoids a crash)
virtual void inet::cPanelFigure::move ( double  dx,
double  dy 
)
inlineoverridevirtual
65 { moveLocal(dx, dy); }
virtual void moveLocal(double dx, double dy) override
Definition: cPanelFigure.h:66
virtual void inet::cPanelFigure::moveLocal ( double  dx,
double  dy 
)
inlineoverridevirtual
66 {position.x += dx; position.y += dy; fireTransformChange();}
Point position
Definition: cPanelFigure.h:44
cPanelFigure & inet::cPanelFigure::operator= ( const cPanelFigure other)
40 {
41  if (this == &other)
42  return *this;
43  cFigure::operator=(other);
44  copy(other);
45  return *this;
46 }
void copy(const cPanelFigure &other)
Definition: cPanelFigure.cc:33
void inet::cPanelFigure::parse ( cProperty *  property)
overrideprotectedvirtual
56 {
57  cFigure::parse(property);
58  setPosition(parsePoint(property, PKEY_POS, 0));
59  setAnchorPoint(parsePoint(property, PKEY_ANCHORPOINT, 0));
60 }
virtual void setAnchorPoint(const Point &anchorPoint)
Definition: cPanelFigure.h:84
virtual void setPosition(const Point &position)
Definition: cPanelFigure.h:72
virtual void inet::cPanelFigure::setAnchorPoint ( const Point &  anchorPoint)
inlinevirtual
84 {this->anchorPoint = anchorPoint; fireTransformChange();}
Point anchorPoint
Definition: cPanelFigure.h:45
virtual void inet::cPanelFigure::setPosition ( const Point &  position)
inlinevirtual

Referenced by inet::LabeledLineFigure::updateLabelPosition(), and inet::LabeledPolylineFigure::updateLabelPosition().

72 {this->position = position; fireTransformChange();}
Point position
Definition: cPanelFigure.h:44
std::string inet::cPanelFigure::str ( ) const
overridevirtual
49 {
50  std::stringstream os;
51  os << "at " << getPosition();
52  return os.str();
53 }
virtual const Point & getPosition() const
Definition: cPanelFigure.h:71
void inet::cPanelFigure::updateParentTransform ( Transform &  transform)
overridevirtual
73 {
74  // replace current transform with an axis-aligned, unscaled (thus also unzoomable)
75  // coordinate system, with anchorPoint at getPosition()
76  Point origin = transform.applyTo(getPosition());
77  Point anchor = getTransform().applyTo(getAnchorPoint());
78  transform = Transform().translate(origin.x - anchor.x, origin.y - anchor.y);
79 
80  // then apply our own transform in the normal way (like all other figures do)
81  transform.rightMultiply(getTransform());
82 }
virtual const Point & getPosition() const
Definition: cPanelFigure.h:71
virtual const Point & getAnchorPoint() const
By default, the (0,0) point in cPanelFigure&#39;s coordinate system will be mapped to the given position ...
Definition: cPanelFigure.h:83

Member Data Documentation

Point inet::cPanelFigure::anchorPoint
private
Point inet::cPanelFigure::position
private

The documentation for this class was generated from the following files: