Power System Platform  2026w10a-beta
Loading...
Searching...
No Matches
IOControl Class Reference

Provides the communication with the power element. More...

#include <IOControl.h>

Inheritance diagram for IOControl:
Collaboration diagram for IOControl:

Public Types

enum  IOFlags {
  IN_TERMINAL_VOLTAGE = 1 << 0 , IN_VELOCITY = 1 << 1 , IN_ACTIVE_POWER = 1 << 2 , IN_REACTIVE_POWER = 1 << 3 ,
  OUT_FIELD_VOLTAGE = 1 << 4 , OUT_MEC_POWER = 1 << 5 , IN_INITIAL_TERMINAL_VOLTAGE = 1 << 6 , IN_INITIAL_MEC_POWER = 1 << 7 ,
  IN_INITIAL_VELOCITY = 1 << 8 , IN_DELTA_VELOCITY = 1 << 9 , IN_DELTA_ACTIVE_POWER = 1 << 10 , IN_TEST = 1 << 11
}
 

Public Member Functions

 IOControl (int ioFlags, int id)
 
virtual void DrawDC (wxPoint2DDouble translation, double scale, wxGraphicsContext *gc) const
 Draw the element using GDI+.
 
virtual bool Contains (wxPoint2DDouble position) const
 Checks if the element contains a position.
 
virtual bool Intersects (wxRect2DDouble rect) const
 Check if the element's rect intersects other rect.
 
virtual bool ShowForm (wxWindow *parent, Element *element)
 Show element data form.
 
virtual void Rotate (bool clockwise=true)
 Rotate the element.
 
virtual bool UpdateText ()
 Update the OpenGL text in the element (if present).
 
virtual wxString GenerateText ()
 
virtual void UpdatePoints ()
 
virtual IOFlags GetValue () const
 
virtual void SetValue (IOFlags value)
 
virtual int GetIOFlags () const
 
virtual Node::NodeType GetType ()
 
virtual wxString GetName () const
 
virtual void SetName (const wxString &name)
 
virtual SimTestData GetSimTestData () const
 
virtual void SetSimTestData (const SimTestData &simTestData)
 
virtual double GetTestValue () const
 
virtual void SetTestValue (const double &testValue)
 
virtual bool Initialize ()
 
virtual rapidxml::xml_node * SaveElement (rapidxml::xml_document<> &doc, rapidxml::xml_node<> *elementListNode)
 
virtual bool OpenElement (rapidxml::xml_node<> *elementNode)
 
virtual ElementGetCopy ()
 Get a the element copy.
 
- Public Member Functions inherited from ControlElement
 ControlElement (int id)
 
virtual void StartMove (wxPoint2DDouble position)
 Update the element attributes related to the movement.
 
virtual void Move (wxPoint2DDouble position)
 Move the element other position.
 
void SetNodeList (std::vector< Node * > nodeList)
 
std::vector< Node * > GetNodeList () const
 
virtual void DrawDCNodes (wxGraphicsContext *gc) const
 
virtual void ReplaceNode (Node *oldNode, Node *newNode)
 
virtual bool IsSolved () const
 
virtual void SetSolved (bool solved=true)
 
virtual bool Solve (double *input, double timeStep)
 
virtual double GetOutput () const
 
virtual void SetOutput (double output)
 
- Public Member Functions inherited from Element
 Element ()
 Constructor.
 
virtual ~Element ()
 Destructor.
 
void SetDragging (bool dragging=true)
 Set if the element are being dragged.
 
void SetHeight (double height)
 Set element height.
 
void SetPosition (const wxPoint2DDouble position)
 Set the element position and update the rectangle.
 
void SetSelected (bool selected=true)
 Set element selection.
 
void SetWidth (double width)
 Set element width.
 
void SetAngle (double angle)
 Set element angle.
 
void ShowPickbox (bool showPickbox=true)
 Set if the pickbox is shown.
 
void SetBorderSize (double borderSize)
 Set the size of the border (shown in selected elements).
 
bool SetOnline (bool online=true)
 Set if the element is online or offline.
 
virtual void SetPointList (std::vector< wxPoint2DDouble > pointList)
 Set the list of points that connect the element to the bus.
 
ElementType GetElementType ()
 
wxRect2DDouble GetRect () const
 Get the element rectangle.
 
wxPoint2DDouble GetPosition () const
 Get the element position.
 
bool IsDragging () const
 Checks if the element is being dragged.
 
double GetHeight () const
 Get the element height.
 
bool IsSelected () const
 Checks if the element is selected.
 
double GetWidth () const
 Get the element width.
 
double GetAngle () const
 Get the element angle.
 
double GetRotationAngle () const
 Get the angle of rotation.
 
bool IsPickboxShown () const
 Checks if the pickbox is shown.
 
bool IsOnline () const
 Checks if the element is online or offline.
 
virtual std::vector< wxPoint2DDouble > GetPointList () const
 Get the list of points that connect the element to bus.
 
virtual bool AddParent (Element *parent, wxPoint2DDouble position)
 Add a parent to the element. This method must be used on power elements that connect to a bus, so the parent must be a bus. The element basic points are calculated in this method, so apply this when the element is being inserted.
 
virtual void AddParent (Element *parent)
 Add a parent to the element.
 
virtual void SetID (int id)
 Set the element ID.
 
virtual int GetID () const
 Get the element ID.
 
virtual void AddChild (Element *child)
 Add a child to the child list.
 
virtual void RemoveChild (Element *child)
 Remove a child from the list.
 
virtual void ReplaceChild (Element *oldChild, Element *newChild)
 Replace a child from the list.
 
virtual wxString GetTipText () const
 Get the tip text.
 
virtual void DrawDC (wxPoint2DDouble translation, double scale, wxDC &dc) const
 Draw the element using wxDC.
 
virtual bool GetContextMenu (wxMenu &menu)
 Get the element contex menu.
 
virtual void AddPoint (wxPoint2DDouble point)
 Add point to the list of points that connect the element to the bus.
 
virtual void MoveNode (Element *parent, wxPoint2DDouble position)
 Move a node. StartMove(wxPoint2DDouble position) before start moving.
 
virtual bool NodeContains (wxPoint2DDouble position)
 Check if a node contains a point. If contains, set the attributes related to node movement.
 
virtual void UpdateNodes ()
 Update the nodes according to the parents. If a parent is removed, use this method.
 
void SetParent (Element *parent, int num)
 
void SetChild (Element *child, int num)
 
virtual bool SetNodeParent (Element *parent)
 Set a perent to the node. If all conditions are met, a new parent are added to the element and the points related to the nodes will be calculated.
 
virtual void RemoveParent (Element *parent)
 Remove a parent.
 
virtual void ReplaceParent (Element *oldParent, Element *newParent)
 Replace a parent.
 
virtual void RotateNode (Element *parent, bool clockwise=true)
 Rotate a node.
 
virtual bool PickboxContains (wxPoint2DDouble position)
 Check if a pickbox contains a point. If contains the attributes related to pickbox movement will be calculated.
 
virtual void MovePickbox (wxPoint2DDouble position)
 Move the pickbox.
 
virtual wxCursor GetBestPickboxCursor () const
 Get the best cursor to shown to the user when the mouse is above a pickbox.
 
virtual void ResetPickboxes ()
 Remove the pickboxes.
 
virtual void ResetNodes ()
 Remove the active nodes.
 
virtual wxPoint2DDouble WorldToScreen (wxPoint2DDouble translation, double scale, double offsetX=0.0, double offsetY=0.0) const
 Convert the element position to screen position.
 
virtual wxPoint2DDouble WorldToScreen (wxPoint2DDouble position, wxPoint2DDouble translation, double scale, double offsetX=0.0, double offsetY=0.0) const
 Convert a generic position to screen position.
 
virtual bool RotatedRectanglesIntersects (wxRect2DDouble rect1, wxRect2DDouble rect2, double angle1, double angle2) const
 Check if two roteted rectangles intersect.
 
virtual void DrawDCRectangle (wxPoint2DDouble position, double width, double height, double angle, wxDC &dc) const
 Draw a circle.
 
virtual void DrawDCRoundedRectRotated (wxDC &dc, const wxPoint2DDouble &center, double width, double height, double radius, double angleDeg, int arcSegments=8) const
 
virtual void DrawDCCircle (wxPoint2DDouble position, double radius, int numSegments, wxGraphicsContext *gc) const
 Draw a circle using device context.
 
virtual void DrawDCCircle (wxPoint2DDouble position, double radius, wxDC &dc) const
 
virtual void DrawDCArc (wxPoint2DDouble position, double radius, double initAngle, double finalAngle, int numSegments, wxGraphicsContext *gc) const
 
virtual void DrawDCArc (wxPoint2DDouble position, double radius, double initAngle, double finalAngle, wxDC &dc) const
 
virtual void DrawDCTriangle (std::vector< wxPoint2DDouble > points, wxGraphicsContext *gc) const
 Draw rectangle.
 
virtual void DrawDCTriangle (std::vector< wxPoint > points, wxDC &dc) const
 
virtual void DrawDCPickbox (wxPoint2DDouble position, wxGraphicsContext *gc) const
 Draw a point.
 
virtual wxPoint2DDouble RotateAtPosition (wxPoint2DDouble pointToRotate, double angle, bool degrees=true) const
 Rotate a point as element position being the origin.
 
virtual wxPoint2DDouble RotateLocal (wxPoint2DDouble local, double angleDeg) const
 
virtual wxPoint RotateAround (const wxPoint2DDouble &p, const wxPoint2DDouble &center, double angleDeg) const
 
virtual std::vector< Element * > GetParentList () const
 Get the parent list.
 
virtual std::vector< Element * > GetChildList () const
 Get the Child list.
 
virtual void CalculateBoundaries (wxPoint2DDouble &leftUp, wxPoint2DDouble &rightBottom) const
 Calculate the element boundaries.
 
virtual void GeneralMenuItens (wxMenu &menu)
 Insert general itens to context menu.
 
virtual double PointToLineDistance (wxPoint2DDouble point, int *segmentNumber=nullptr) const
 Calculate the distance between a line (formed by point list) and a point.
 
bool IsInserted () const
 Check if the element is properly inserted in the workspace.
 
void SetInserted (bool inserted=true)
 Set if the element is properly inserted in the workspace.
 
void SaveCADProperties (rapidxml::xml_document<> &doc, rapidxml::xml_node<> *elementNode)
 
bool OpenCADProperties (rapidxml::xml_node<> *elementNode)
 

Protected Attributes

IOFlags m_value
 
int m_ioFlags
 
wxString m_name = _("Input / Output")
 
SimTestData m_simTestData
 
double m_testValue = 0.0
 
Node::NodeType m_ioNodeType = Node::NodeType::NODE_IN
 
GCTextm_gcText = nullptr
 
- Protected Attributes inherited from ControlElement
std::vector< Node * > m_nodeList
 
bool m_solved = false
 
double m_output = 0.0
 
- Protected Attributes inherited from Element
ElementType m_elementType = ElementType::TYPE_NONE
 
int m_elementID = 0
 
std::vector< Element * > m_parentList
 
std::vector< Element * > m_childList
 
wxRect2DDouble m_rect
 
wxPoint2DDouble m_position
 
double m_width = 0.0
 
double m_height = 0.0
 
double m_angle = 0.0
 
double m_borderSize = 2.0
 
double m_rotationAngle = 45.0
 
double m_switchSize = 10.0
 
std::vector< wxRect2DDouble > m_switchRect
 
bool m_selected = false
 
bool m_dragging = false
 
bool m_showPickbox = false
 
bool m_inserted = false
 
int m_activePickboxID = ID_PB_NONE
 
int m_activeNodeID = 0
 
std::vector< wxPoint2DDouble > m_pointList
 
std::vector< wxPoint2DDouble > m_movePts
 
wxPoint2DDouble m_moveStartPt
 
wxPoint2DDouble m_movePos
 
bool m_online = true
 
wxColour m_selectionColour
 

Additional Inherited Members

- Static Public Member Functions inherited from ControlElement
static ControlElementGetControlElementFromID (std::vector< std::shared_ptr< ControlElement > > elementList, int id)
 
- Static Public Member Functions inherited from Element
static bool DoubleFromString (wxWindow *parent, wxString strValue, double &value, wxString errorMsg)
 Get a double value from a string. Show a error message if the conversion fail.
 
static bool IntFromString (wxWindow *parent, wxString strValue, int &value, wxString errorMsg)
 Convert a string to int. Show a error message if the conversion fail.
 
static wxString StringFromDouble (double value, int minDecimal=1, int maxDecimals=13)
 Convert a double value to string.
 
- Protected Member Functions inherited from ControlElement
void SaveControlNodes (rapidxml::xml_document<> &doc, rapidxml::xml_node<> *elementNode)
 
bool OpenControlNodes (rapidxml::xml_node<> *elementNode)
 

Detailed Description

Provides the communication with the power element.

Author
Thales Lima Oliveira thale.nosp@m.s@uf.nosp@m.u.br
Date
05/10/2017

Definition at line 42 of file IOControl.h.

Member Enumeration Documentation

◆ IOFlags

enum IOControl::IOFlags

Definition at line 45 of file IOControl.h.

45 {
46 IN_TERMINAL_VOLTAGE = 1 << 0,
47 IN_VELOCITY = 1 << 1,
48 IN_ACTIVE_POWER = 1 << 2,
49 IN_REACTIVE_POWER = 1 << 3,
50 OUT_FIELD_VOLTAGE = 1 << 4,
51 OUT_MEC_POWER = 1 << 5,
52 IN_INITIAL_TERMINAL_VOLTAGE = 1 << 6,
53 IN_INITIAL_MEC_POWER = 1 << 7,
54 IN_INITIAL_VELOCITY = 1 << 8,
55 IN_DELTA_VELOCITY = 1 << 9,
56 IN_DELTA_ACTIVE_POWER = 1 << 10,
57 IN_TEST = 1 << 11,
58 };

Constructor & Destructor Documentation

◆ IOControl()

IOControl::IOControl ( int  ioFlags,
int  id 
)

Definition at line 22 of file IOControl.cpp.

22 : ControlElement(id)
23{
24 m_ioFlags = ioFlags;
25
26 Node* node = new Node(m_position, Node::NodeType::NODE_IN, m_borderSize);
27 m_nodeList.push_back(node);
28
29 if (ioFlags & IN_TERMINAL_VOLTAGE)
30 SetValue(IN_TERMINAL_VOLTAGE);
31 else if (ioFlags & IN_VELOCITY)
32 SetValue(IN_VELOCITY);
33 node->StartMove(m_position);
34}
Node of a control element. This class manages the user interaction with the connection and control el...

◆ ~IOControl()

IOControl::~IOControl ( )

Definition at line 36 of file IOControl.cpp.

37{
38 //if(m_glText) delete m_glText;
39 if (m_gcText) delete m_gcText;
40 for (auto& node : m_nodeList) if (node) delete node;
41 m_nodeList.clear();
42}

Member Function Documentation

◆ Contains()

virtual bool IOControl::Contains ( wxPoint2DDouble  position) const
inlinevirtual

Checks if the element contains a position.

Parameters
positionPosition to be checked.

Implements Element.

Definition at line 65 of file IOControl.h.

65{ return m_rect.Contains(position); }

◆ DrawDC()

void IOControl::DrawDC ( wxPoint2DDouble  translation,
double  scale,
wxGraphicsContext *  gc 
) const
virtual

Draw the element using GDI+.

Parameters
translationTranslation of the system.
scaleScale of the system.
gcGraphics context

Reimplemented from Element.

Definition at line 126 of file IOControl.cpp.

127{
128 std::vector<wxPoint2DDouble> pts;
129 if (m_angle == 0.0) {
130 pts.push_back(m_rect.GetLeftTop() + wxPoint2DDouble(m_borderSize, m_borderSize));
131 pts.push_back(m_rect.GetRightTop() + wxPoint2DDouble(-m_borderSize - 10, m_borderSize));
132 pts.push_back(m_position + wxPoint2DDouble(m_width / 2 - m_borderSize, 0));
133 pts.push_back(m_rect.GetRightBottom() + wxPoint2DDouble(-m_borderSize - 10, -m_borderSize));
134 pts.push_back(m_rect.GetLeftBottom() + wxPoint2DDouble(m_borderSize, -m_borderSize));
135 }
136 else if (m_angle == 90.0) {
137 pts.push_back(m_rect.GetLeftTop() + wxPoint2DDouble(m_borderSize, m_borderSize));
138 pts.push_back(m_rect.GetRightTop() + wxPoint2DDouble(-m_borderSize, m_borderSize));
139 pts.push_back(m_rect.GetRightBottom() + wxPoint2DDouble(-m_borderSize, -m_borderSize - 10));
140 pts.push_back(m_position + wxPoint2DDouble(0, m_height / 2 - m_borderSize));
141 pts.push_back(m_rect.GetLeftBottom() + wxPoint2DDouble(m_borderSize, -m_borderSize - 10));
142 }
143 else if (m_angle == 180.0) {
144 pts.push_back(m_rect.GetLeftTop() + wxPoint2DDouble(m_borderSize + 10, m_borderSize));
145 pts.push_back(m_rect.GetRightTop() + wxPoint2DDouble(-m_borderSize, m_borderSize));
146 pts.push_back(m_rect.GetRightBottom() + wxPoint2DDouble(-m_borderSize, -m_borderSize));
147 pts.push_back(m_rect.GetLeftBottom() + wxPoint2DDouble(m_borderSize + 10, -m_borderSize));
148 pts.push_back(m_position + wxPoint2DDouble(-m_width / 2 + m_borderSize, 0));
149 }
150 else if (m_angle == 270.0) {
151 pts.push_back(m_position + wxPoint2DDouble(0, -m_height / 2 + m_borderSize));
152 pts.push_back(m_rect.GetRightTop() + wxPoint2DDouble(-m_borderSize, m_borderSize + 10));
153 pts.push_back(m_rect.GetRightBottom() + wxPoint2DDouble(-m_borderSize, -m_borderSize));
154 pts.push_back(m_rect.GetLeftBottom() + wxPoint2DDouble(m_borderSize, -m_borderSize));
155 pts.push_back(m_rect.GetLeftTop() + wxPoint2DDouble(m_borderSize, m_borderSize + 10));
156 }
157 pts.emplace_back(pts[0]);
158
159 if (m_selected) {
160 gc->SetPen(*wxTRANSPARENT_PEN);
161 gc->SetBrush(wxBrush(m_selectionColour));
162 double borderSize = (m_borderSize * 2.0 + 1.0) / scale;
163 std::vector<wxPoint2DDouble> selPts = pts;
164 if (m_angle == 0.0) {
165 selPts[0] += wxPoint2DDouble(-borderSize / 2, -borderSize / 2);
166 selPts[1] += wxPoint2DDouble(borderSize / 2, -borderSize / 2);
167 selPts[2] += wxPoint2DDouble(1.5 * borderSize / 2, 0);
168 selPts[3] += wxPoint2DDouble(borderSize / 2, borderSize / 2);
169 selPts[4] += wxPoint2DDouble(-borderSize / 2, borderSize / 2);
170 }
171 else if (m_angle == 90.0) {
172 selPts[0] += wxPoint2DDouble(-borderSize / 2, -borderSize / 2);
173 selPts[1] += wxPoint2DDouble(borderSize / 2, -borderSize / 2);
174 selPts[2] += wxPoint2DDouble(borderSize / 2, borderSize / 2);
175 selPts[3] += wxPoint2DDouble(0, 1.5 * borderSize / 2);
176 selPts[4] += wxPoint2DDouble(-borderSize / 2, borderSize / 2);
177 }
178 else if (m_angle == 180.0) {
179 selPts[0] += wxPoint2DDouble(-borderSize / 2, -borderSize / 2);
180 selPts[1] += wxPoint2DDouble(borderSize / 2, -borderSize / 2);
181 selPts[2] += wxPoint2DDouble(borderSize / 2, borderSize / 2);
182 selPts[3] += wxPoint2DDouble(-borderSize / 2, borderSize / 2);
183 selPts[4] += wxPoint2DDouble(-1.5 * borderSize / 2, 0);
184 }
185 else if (m_angle == 270.0) {
186 selPts[0] += wxPoint2DDouble(0, -1.5 * borderSize / 2);
187 selPts[1] += wxPoint2DDouble(borderSize / 2, -borderSize / 2);
188 selPts[2] += wxPoint2DDouble(borderSize / 2, borderSize / 2);
189 selPts[3] += wxPoint2DDouble(-borderSize / 2, borderSize / 2);
190 selPts[4] += wxPoint2DDouble(-borderSize / 2, -borderSize / 2);
191 }
192 gc->DrawLines(5, &selPts[0]);
193 }
194 gc->SetPen(wxPen(wxColour(0, 0, 0, 255), 1));
195 gc->SetBrush(wxBrush(wxColour(255, 255, 255, 255)));
196 gc->DrawLines(6, &pts[0]);
197
198 // Plot number.
199 if (m_angle == 0.0) {
200 m_gcText->Draw(m_position + wxPoint2DDouble(-5.0 - m_gcText->GetWidth() / 2, -m_gcText->GetHeight() / 2), gc);
201 }
202 else if (m_angle == 90.0) {
203 m_gcText->Draw(m_position + wxPoint2DDouble(-m_gcText->GetWidth() / 2, -5.0 - m_gcText->GetHeight() / 2), gc);
204 }
205 else if (m_angle == 180.0) {
206 m_gcText->Draw(m_position + wxPoint2DDouble(5.0 - m_gcText->GetWidth() / 2, -m_gcText->GetHeight() / 2), gc);
207 }
208 else if (m_angle == 270.0) {
209 m_gcText->Draw(m_position + wxPoint2DDouble(-m_gcText->GetWidth() / 2, 5.0 - m_gcText->GetHeight() / 2), gc);
210 }
211
212 gc->SetPen(*wxTRANSPARENT_PEN);
213 gc->SetBrush(wxBrush(wxColour(0, 0, 0, 255)));
214 DrawDCNodes(gc);
215}
virtual void Draw(wxPoint2DDouble position, wxGraphicsContext *gc, double angle=0.0, wxColour colour= *wxBLACK) const
Draw the text in wxGraphicsContext.
Definition GCText.cpp:35
Here is the call graph for this function:

◆ GenerateText()

wxString IOControl::GenerateText ( )
virtual

Definition at line 245 of file IOControl.cpp.

246{
247 wxString omega = wxString::FromUTF8("\xCF\x89");
248 wxString subZero = wxString::FromUTF8("\xE2\x82\x92");
249 wxString capDelta = wxString::FromUTF8("\xCE\x94");
250
251 switch (m_value) {
252 case IN_TERMINAL_VOLTAGE: {
253 m_ioNodeType = Node::NodeType::NODE_OUT;
254 return _("Vt");
255 } break;
256 case IN_VELOCITY: {
257 m_ioNodeType = Node::NodeType::NODE_OUT;
258 return omega;
259 } break;
260 case IN_ACTIVE_POWER: {
261 m_ioNodeType = Node::NodeType::NODE_OUT;
262 return _("P");
263 } break;
264 case IN_REACTIVE_POWER: {
265 m_ioNodeType = Node::NodeType::NODE_OUT;
266 return _("Q");
267 } break;
268 case OUT_FIELD_VOLTAGE: {
269 m_ioNodeType = Node::NodeType::NODE_IN;
270 return _("Vf");
271 } break;
272 case OUT_MEC_POWER: {
273 m_ioNodeType = Node::NodeType::NODE_IN;
274 return _("Pm");
275 } break;
276 case IN_INITIAL_TERMINAL_VOLTAGE: {
277 m_ioNodeType = Node::NodeType::NODE_OUT;
278 return _("Vt") + subZero;
279 } break;
280 case IN_INITIAL_MEC_POWER: {
281 m_ioNodeType = Node::NodeType::NODE_OUT;
282 return _("Pm") + subZero;
283 } break;
284 case IN_INITIAL_VELOCITY: {
285 m_ioNodeType = Node::NodeType::NODE_OUT;
286 return omega + subZero;
287 } break;
288 case IN_DELTA_VELOCITY: {
289 m_ioNodeType = Node::NodeType::NODE_OUT;
290 return capDelta + omega;
291 } break;
292 case IN_DELTA_ACTIVE_POWER: {
293 m_ioNodeType = Node::NodeType::NODE_OUT;
294 return capDelta + _("P");
295 } break;
296 }
297 return "";
298}

◆ GetCopy()

Element * IOControl::GetCopy ( )
virtual

Get a the element copy.

Returns
Copy of the element.

Reimplemented from Element.

Definition at line 355 of file IOControl.cpp.

356{
357 IOControl* copy = new IOControl(m_ioFlags, m_elementID);
358 *copy = *this;
359 copy->m_gcText = m_gcText->GetCopy();
360 return copy;
361}
virtual GCText * GetCopy()
Get a deep text copy.
Definition GCText.cpp:161
Provides the communication with the power element.
Definition IOControl.h:43
Here is the call graph for this function:

◆ GetIOFlags()

virtual int IOControl::GetIOFlags ( ) const
inlinevirtual

Definition at line 75 of file IOControl.h.

75{ return m_ioFlags; }

◆ GetName()

virtual wxString IOControl::GetName ( ) const
inlinevirtual

Definition at line 77 of file IOControl.h.

77{ return m_name; }

◆ GetSimTestData()

virtual SimTestData IOControl::GetSimTestData ( ) const
inlinevirtual

Definition at line 79 of file IOControl.h.

79{ return m_simTestData; }

◆ GetTestValue()

virtual double IOControl::GetTestValue ( ) const
inlinevirtual

Definition at line 81 of file IOControl.h.

81{ return m_testValue; }

◆ GetType()

virtual Node::NodeType IOControl::GetType ( )
inlinevirtual

Definition at line 76 of file IOControl.h.

76{ return m_ioNodeType; }

◆ GetValue()

virtual IOFlags IOControl::GetValue ( ) const
inlinevirtual

Definition at line 73 of file IOControl.h.

73{ return m_value; }

◆ Initialize()

bool IOControl::Initialize ( )
virtual

Reimplemented from ControlElement.

Definition at line 403 of file IOControl.cpp.

404{
405 m_solved = false;
406 m_output = 0.0;
407 if(m_value == IOControl::IN_TEST) {
408 m_output = m_testValue;
409 }
410 return true;
411}

◆ Intersects()

virtual bool IOControl::Intersects ( wxRect2DDouble  rect) const
inlinevirtual

Check if the element's rect intersects other rect.

Parameters
rectRect to check intersection.

Implements Element.

Definition at line 66 of file IOControl.h.

66{ return m_rect.Intersects(rect); }

◆ OpenElement()

bool IOControl::OpenElement ( rapidxml::xml_node<> *  elementNode)
virtual

Reimplemented from Element.

Definition at line 389 of file IOControl.cpp.

390{
391 if (!OpenCADProperties(elementNode)) return false;
392 if (!OpenControlNodes(elementNode)) return false;
393
394 // Element properties
395 IOControl::IOFlags value = static_cast<IOControl::IOFlags>(XMLParser::GetNodeValueInt(elementNode, "Value"));
396 SetValue(value);
397 auto name = elementNode->first_node("Name");
398 if (name) m_name = name->value();
399
400 return true;
401}

◆ Rotate()

void IOControl::Rotate ( bool  clockwise = true)
virtual

Rotate the element.

Parameters
clockwiseTrue to rotate clockwise, false to rotate counter-clockwise.

Reimplemented from Element.

Definition at line 226 of file IOControl.cpp.

227{
228 if (clockwise)
229 m_angle += 90.0;
230 else
231 m_angle -= 90.0;
232 if (m_angle >= 360.0)
233 m_angle = 0.0;
234 else if (m_angle < 0)
235 m_angle = 270.0;
236
237 UpdatePoints();
238
239 for (auto it = m_nodeList.begin(), itEnd = m_nodeList.end(); it != itEnd; ++it) {
240 Node* node = *it;
241 node->Rotate(clockwise);
242 }
243}

◆ SaveElement()

rapidxml::xml_node * IOControl::SaveElement ( rapidxml::xml_document<> &  doc,
rapidxml::xml_node<> *  elementListNode 
)
virtual

Reimplemented from Element.

Definition at line 370 of file IOControl.cpp.

371{
372 auto elementNode = XMLParser::AppendNode(doc, elementListNode, "IO");
373 XMLParser::SetNodeAttribute(doc, elementNode, "ID", m_elementID);
374
375 SaveCADProperties(doc, elementNode);
376 SaveControlNodes(doc, elementNode);
377
378 // Element properties
379 auto name = XMLParser::AppendNode(doc, elementNode, "Name");
380 XMLParser::SetNodeValue(doc, name, m_name);
381 auto value = XMLParser::AppendNode(doc, elementNode, "Value");
382 XMLParser::SetNodeValue(doc, value, m_value);
383 auto ioFlags = XMLParser::AppendNode(doc, elementNode, "IOFlags");
384 XMLParser::SetNodeValue(doc, ioFlags, m_ioFlags);
385
386 return elementNode;
387}

◆ SetName()

virtual void IOControl::SetName ( const wxString &  name)
inlinevirtual

Definition at line 78 of file IOControl.h.

78{ m_name = name; }

◆ SetSimTestData()

virtual void IOControl::SetSimTestData ( const SimTestData simTestData)
inlinevirtual

Definition at line 80 of file IOControl.h.

80{ m_simTestData = simTestData; }

◆ SetTestValue()

virtual void IOControl::SetTestValue ( const double &  testValue)
inlinevirtual

Definition at line 82 of file IOControl.h.

82{ m_testValue = testValue; }

◆ SetValue()

void IOControl::SetValue ( IOFlags  value)
virtual

Definition at line 300 of file IOControl.cpp.

301{
302 m_value = value;
303 wxString text = GenerateText();
304
305 if (m_gcText)
306 m_gcText->SetText(text);
307 else
308 m_gcText = new GCText(text);
309
310 m_width = m_gcText->GetWidth() + 10 + 2 * m_borderSize;
311 m_height = m_gcText->GetHeight() + 10 + 2 * m_borderSize;
312
313 SetPosition(m_position); // Update rectangle.
314
315 UpdatePoints();
316}
void SetPosition(const wxPoint2DDouble position)
Set the element position and update the rectangle.
Definition Element.cpp:27
Class to draw text on Graphics Context using wxWidgets.
Definition GCText.h:32
virtual void SetText(wxString text)
Set correctly a new text string.
Definition GCText.cpp:68

◆ ShowForm()

bool IOControl::ShowForm ( wxWindow *  parent,
Element element 
)
virtual

Show element data form.

Parameters
parentForm parent
elementElement that will be edited.
Returns
True if the form is shown, false otherwise.

Reimplemented from Element.

Definition at line 217 of file IOControl.cpp.

218{
219 IOControlForm form(parent, this);
220 if (form.ShowModal() == wxID_OK) {
221 return true;
222 }
223 return false;
224}
Form to edit the input/output control data.

◆ UpdatePoints()

void IOControl::UpdatePoints ( )
virtual

Definition at line 318 of file IOControl.cpp.

319{
320 if (m_nodeList.size() != 0) {
321 Node* node = m_nodeList[0];
322 if (node->GetNodeType() != m_ioNodeType) {
323 // Rotate 180 degrees
324 node->Rotate();
325 node->Rotate();
326 }
327 node->SetNodeType(m_ioNodeType);
328 if (m_angle == 0.0) {
329 if (m_ioNodeType == Node::NodeType::NODE_IN)
330 node->SetPosition(m_position + wxPoint2DDouble(-m_width / 2, 0));
331 else
332 node->SetPosition(m_position + wxPoint2DDouble(m_width / 2 - 2, 0));
333 }
334 else if (m_angle == 90.0) {
335 if (m_ioNodeType == Node::NodeType::NODE_IN)
336 node->SetPosition(m_position + wxPoint2DDouble(0, -m_height / 2));
337 else
338 node->SetPosition(m_position + wxPoint2DDouble(0, m_height / 2 - 2));
339 }
340 else if (m_angle == 180.0) {
341 if (m_ioNodeType == Node::NodeType::NODE_IN)
342 node->SetPosition(m_position + wxPoint2DDouble(m_width / 2, 0));
343 else
344 node->SetPosition(m_position + wxPoint2DDouble(2 - m_width / 2, 0));
345 }
346 else if (m_angle == 270.0) {
347 if (m_ioNodeType == Node::NodeType::NODE_IN)
348 node->SetPosition(m_position + wxPoint2DDouble(0, m_height / 2));
349 else
350 node->SetPosition(m_position + wxPoint2DDouble(0, 2 - m_height / 2));
351 }
352 }
353}

◆ UpdateText()

bool IOControl::UpdateText ( )
virtual

Update the OpenGL text in the element (if present).

Returns
true if OpenGLText is ok, false otherwise.

Reimplemented from ControlElement.

Definition at line 363 of file IOControl.cpp.

364{
365 SetValue(m_value);
366 //if (!m_glText->IsTextureOK()) return false;
367 return true;
368}

Member Data Documentation

◆ m_gcText

GCText* IOControl::m_gcText = nullptr
protected

Definition at line 100 of file IOControl.h.

◆ m_ioFlags

int IOControl::m_ioFlags
protected

Definition at line 92 of file IOControl.h.

◆ m_ioNodeType

Node::NodeType IOControl::m_ioNodeType = Node::NodeType::NODE_IN
protected

Definition at line 97 of file IOControl.h.

◆ m_name

wxString IOControl::m_name = _("Input / Output")
protected

Definition at line 93 of file IOControl.h.

◆ m_simTestData

SimTestData IOControl::m_simTestData
protected

Definition at line 94 of file IOControl.h.

◆ m_testValue

double IOControl::m_testValue = 0.0
protected

Definition at line 95 of file IOControl.h.

◆ m_value

IOFlags IOControl::m_value
protected

Definition at line 91 of file IOControl.h.


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