wxArt2D
canpin.h
Go to the documentation of this file.
1 /*! \file wx/canvas/canpin.h
2  \brief pins and handles
3 
4  \author Klaas Holwerda
5 
6  Copyright: 2000-2004 (c) Klaas Holwerda
7 
8  Licence: wxWidgets Licence
9 
10  RCS-ID: $Id: canprim.h,v 1.37 2009/07/17 16:03:34 titato Exp $
11 */
12 
13 #ifndef __WXCANPIN_H__
14 #define __WXCANPIN_H__
15 
16 #ifndef WX_PRECOMP
17 #include "wx/wx.h"
18 #endif
19 
20 #include "wx/canvas/candefs.h"
21 #include "wx/canvas/canobj.h"
22 #include "wx/canvas/connectgen.h"
23 
24 //! a2dHandle is used inside editing versions of a certain objects.
25 /*! In that case instances of this object are used to draw dragging Handles.
26 \remark width and height are defined in pixels.
27 
28 \ingroup canvasobject
29  */
30 class A2DCANVASDLLEXP a2dHandle: public a2dCanvasObject
31 {
32 
33  DECLARE_EVENT_TABLE()
34 
35 public:
36 
37  //! constructor
38  a2dHandle();
39 
40  //! construct a handle
41  /*!
42  \param parent parent of handle
43  \param xc center x
44  \param yc center y
45  \param name name of handle
46  \param w width of handle rectangle
47  \param h height of handle rectangle
48  \param angle angle of rotation of handle rectangle
49  \param radius for a rounded handle rectangle
50  */
51  a2dHandle( a2dCanvasObject* parent, double xc, double yc, const wxString& name = wxT( "" ), double w = 0, double h = 0, double angle = 0 , double radius = 0 );
52  a2dHandle( const a2dHandle& other, CloneOptions options, a2dRefMap* refs );
53  ~a2dHandle();
54 
55  //!get the name given to the handle.
56  wxString GetName() const { return m_name; }
57 
58  //! set the name of the handle (must be unique)
59  void SetName( const wxString& name ) { m_name = name; }
60 
61  //! set all parameters
62  /*!
63  \param xc center x
64  \param yc center y
65  \param w width of handle rectangle
66  \param h height of handle rectangle
67  \param angle angle of rotation of handle rectangle
68  \param radius for a rounded handle rectangle
69  */
70  void Set( double xc, double yc, double w, double h, double angle = 0 , double radius = 0 );
71 
72  //! set basic parameters
73  /*!
74  \param xc center x
75  \param yc center y
76  \param name empty means leave name as is
77  */
78  void Set2( double xc, double yc, const wxString& name = wxT( "" ) );
79 
80  //! set parent object of the pin
81  void SetParent( a2dCanvasObject* parent );
82 
83  //! get parent object of the pin
84  a2dCanvasObject* GetParent() const { return m_parent; }
85 
86  //!return width
87  double GetWidth() const { return m_width; }
88 
89  //!return height
90  double GetHeight() const { return m_height; }
91 
92  //!return radius
93  double GetRadius() const { return m_radius; }
94 
95  void SetMode( int mode )
96  {
97  m_mode = mode; SetPending( true );
98  }
99 
100  int GetMode() const { return m_mode; }
101 
102  static void SetWorldBased( bool worldBased ) { m_worldBased = worldBased; }
103 
104  static bool GetWorldBased() { return m_worldBased; }
105 
106 #if wxART2D_USE_CVGIO
107  virtual void DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts );
108  virtual void DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite );
109 #endif //wxART2D_USE_CVGIO
110  virtual bool IsTemporary_DontSave() const;
111 
112  DECLARE_DYNAMIC_CLASS( a2dHandle )
113 
114 protected:
115 
116  //! clone it
117  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const;
118 
119  void OnEnterObject( a2dCanvasObjectMouseEvent& event );
120 
121  void OnLeaveObject( a2dCanvasObjectMouseEvent& event );
122 
123  void OnCanvasObjectMouseEvent( a2dCanvasObjectMouseEvent& event );
124 
125  void DoRender( a2dIterC& ic, OVERLAP clipparent );
126 
127  bool DoIsHitWorld( a2dIterC& ic, a2dHitEvent& hitEvent );
128 
129  a2dBoundingBox DoGetUnTransformedBbox( a2dBboxFlags flags = a2dCANOBJ_BBOX_NON ) const;
130 
131  bool DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox );
132 
133  //! name of the handle
134  wxString m_name;
135 
136  //!width in pixels
137  double m_width;
138 
139  //!height in pixels
140  double m_height;
141 
142  //!radius of rectangle that will be rendered
143  double m_radius;
144 
145  //! modifies rendering
146  int m_mode;
147 
148  //!what is the a2dCanvasObject that i am part of
149  //* This is intentionally not a smart pointer to remove a reference loop */
150  a2dCanvasObject* m_parent;
151 
152  static bool m_worldBased;
153 
154 public:
155  static a2dPropertyIdInt32* PROPID_Width;
156  static a2dPropertyIdInt32* PROPID_Height;
157  static a2dPropertyIdInt32* PROPID_Radius;
158 
160 
161 public:
162  const static long sm_HandleNoHit;
163  const static long sm_HandleHit;
164 
165  //static const a2dPropertyIdLineSegment PROPID_linesegment;
166 
167 
168 private:
169  //!this is a not implemented copy constructor that avoids automatic creation of one
170  a2dHandle( const a2dHandle& other );
171 };
172 
173 #if (defined(__WXMSW__) && defined(WXUSINGDLL) )
174 template class A2DCANVASDLLEXP a2dSmrtPtr<a2dHandle>;
175 #endif
176 
177 //! smart pointer for a2dHandle
179 
180 
181 class A2DCANVASDLLEXP a2dPinClass;
182 #if (defined(__WXMSW__) && defined(WXUSINGDLL) )
183 template class A2DCANVASDLLEXP std::allocator<a2dPinClass*>;
184 template class A2DCANVASDLLEXP std::allocator< std::_List_nod<a2dPinClass*, std::allocator<a2dPinClass* > >::_Node >;
185 template class A2DCANVASDLLEXP std::allocator< std::_List_ptr<a2dPinClass*, std::allocator<a2dPinClass* > >::_Nodeptr >;
186 template class A2DCANVASDLLEXP std::list< a2dPinClass* >;
187 #endif
188 
189 class A2DCANVASDLLEXP a2dParPin;
190 
191 #define a2dAnyPin NULL
192 
193 //! a2dPin is used in a2dCanvasObject to add pins to it.
194 /*!
195  This class is meant to be added as child object to a a2dCanvasObject, there it is treated in a special manner
196  to connect the parent a2dCanvasObject to other a2dCanvasObject's.
197  Using pins one can create graph/diagram structures of connected a2dCanvasObjects.
198  Pins can connect one canvas object to another via two connected pins.
199  The Pin can be connected to several other Pins.
200  Special connection canvas objects like a2dWirePolylineL and a2dWires,
201  can be used to create wires between canvas objects.
202  The connection objects also have pins, which they use to connect to other a2dCanvasObjects.
203  Fro instance a2dWirePolylineL is a wire, which can have many pins along it, which are connected to othere canvas objects.
204  Those wire line objects do recalculate the wires when moving a connected a2dCanvasObject.
205  This is often called rubberbanding. A wire connection objects are used in dedicated reroute algorithms.
206  a2dConnectionGenerator is used to implement those algorithms. It work on sets of wires which are connected to other objects.
207  Moving the objects, leads to rewiring the connection objects.
208 
209  One can traverse connected a2dCanvasObject's via its pins, since the Pin has a parent pointer
210  to the a2dCanvasObject it belongs to. This way one can find groups of connected objects.
211 
212  a2dCanvasObject has member functions to manipulate the a2dPin's it has.
213  A pin itself is created by its parent, and therefore parent object decides where pins are located,
214  and what needs to happen when one wants to connect to one of its pins.
215  This is/can be specific for each derived a2dCanvasObject and each of its pins.
216  To achieve different behaviour for pins without deriving new pin classes, a pin has a a2dPinClass member.
217  The a2dPinClass is used to specialize a pin for a certain connection purpose.
218  Think of input and output pins on objects. One can for instance not connect an input pin of one object to
219  the input pin of another object.
220  All these constraints can be stored in the pin its a2dPinClass.
221  So in general there will be no need to derive your own MyCanvasPin, unless you want to e.g. change rendering.
222 
223  a2dPinClass is not stored into CVG format, only its name is stored, the list of available
224  pinclasses is assumed to be specific to the application.
225 
226  A pin does have an angle, this make the relative angle to a connected Pin
227  of another a2dCanvasObject well defined. Certain application require object to be connected at the same angles.
228 
229  Pins with the visible fag set false, will not be connected in routines where connections are being made.
230 
231  \ingroup canvasobject
232 */
233 class A2DCANVASDLLEXP a2dPin: public a2dCanvasObject
234 {
235 
236  DECLARE_EVENT_TABLE()
237 
238 public:
239 
240  typedef wxUint16 a2dPinFlagsMask;
241 
243  {
244  /*! no flag set */
245  NON = 0x0,
246 
247  /*! dynamic pins can walk along a line */
248  dynamic = 0x0001,
249 
250  /*! temporary pins are created to indicate possible connection, and deleted or cloned when connected */
251  temporary = 0x0002,
252 
253  /*! set when pin is on an object and not a wire or connect.*/
254  objectPin = 0x0004,
255 
256  /*! true when pin is internal to object border. */
257  internal = 0x0008,
258 
259  /*! temporary and objectPin set */
260  temporaryObjectPin = temporary | objectPin,
261 
262  /*! For Xor ing and all set */
263  ALLSET = 0xFFFFFFFF
264  };
265 
266  //! constructor
267  a2dPin();
268 
269  //! constructor
270  a2dPin( a2dCanvasObject* parent, const wxString& name, a2dPinClass* pinclass, double xc, double yc, double angle = 0 , double w = 0, double h = 0, double radius = 0 );
271 
272  //! copy constructor
273  a2dPin( const a2dPin& other, CloneOptions options, a2dRefMap* refs );
274 
275  //! destructor
276  ~a2dPin();
277 
278  //! flag to render connected pin
279  /*!
280  \remark set the object its pending flag and inform root about this
281  \remark default false
282  \param RenderConnected if true connected pin is rendered visible
283  */
284  inline void SetRenderConnected( bool RenderConnected ) { SetPending( true ); m_RenderConnected = RenderConnected; }
285 
286  //! \return true is connected pins are rendered
287  inline bool GetRenderConnected() { return m_RenderConnected; }
288 
289  virtual void SetPending( bool pending );
290 
291  //! set parent object of the pin
292  virtual void SetParent( a2dCanvasObject* parent );
293 
294  //! get parent object of the pin
295  a2dCanvasObject* GetParent() const { return m_parent; }
296 
297  //!return width
298  double GetWidth() const { return m_width; }
299 
300  //!return height
301  double GetHeight() const { return m_height; }
302 
303  //!return radius
304  double GetRadius() const { return m_radius; }
305 
306  //! default used to modify rendering
307  void SetMode( int mode )
308  {
309  m_mode = mode; SetPending( true );
310  }
311 
312  //! get current mode
313  int GetMode() const { return m_mode; }
314 
315  //! set if pins its size is in world coordinates, else it is in pixels.
316  static void SetWorldBased( bool worldBased ) { m_worldBased = worldBased; }
317 
318  //! get if pin sizes are in world coordinates, else it is in pixels.
319  static bool GetWorldBased() { return m_worldBased; }
320 
321  //!get the name given to the pin.
322  wxString GetName() const { return m_name; }
323 
324  //! set the name of the pin (must be unique)
325  void SetName( const wxString& name ) { m_name = name; }
326 
327  //! set postion angle and name of the pin
328  /*!
329  \param xc x-position
330  \param yc y-position
331  \param angle the angle
332  \param name empty means leave name as is
333  \param dynamic when true pin is only a temporary pin.
334  */
335  void Set( double xc, double yc, double angle = 0 , const wxString& name = wxT( "" ), bool dynamic = false );
336 
337  //! get absolute position of the pin ( after applying the parent's matrix and its own matrix )
338  a2dPoint2D GetAbsXY() const;
339 
340  //! get absolute X position of the pin ( after applying the parent's matrix and its own matrix )
341  double GetAbsX() const;
342 
343  //! get absolute Y position of the pin ( after applying the parent's matrix and its own matrix )
344  double GetAbsY() const;
345 
346  //! set the absolute X,Y position of the pin ( after applying the parent's matrix and its own matrix )
347  void SetAbsXY( double x, double y );
348 
349  //! set the absolute X,Y position of the pin ( after applying the parent's matrix and its own matrix )
350  void SetAbsXY( const a2dPoint2D& point );
351 
352  //! get absolute angle of the pin ( after applying the parent its matrix and it own matrix )
353  double GetAbsAngle() const;
354 
355  //! return the pin class of this pin
356  a2dPinClass* GetPinClass() const { return m_pinclass; }
357 
358  //! Set the pin class
359  void SetPinClass( a2dPinClass* pinClass ) { m_pinclass = pinClass; }
360 
361  //! Is given pin allowed to connect to this pin
362  /*!
363  Override this function to make restriction on connecting pins.
364  E.g You might make restriction for pins on one layer, not to connect with pins on other layers.
365 
366  The default implementation checks if the two pins have a2dPinClass which a2dPinClass::CanConnectTo() to eachother.
367  */
368  virtual bool MayConnectTo( a2dPin* connectto );
369 
370  //! If pin is connected to given pin, it will be disconnected from that other pin.
371  //! Next to that the rendering mode will be set to sm_PinUnConnected.
372  //! The connection entries are set to NULL in m_connectedPins and pin->m_connectedPins.
373  //! They are not erased from the list, in order to not interupt ongoing iterations at a higher level.
374  //! Call CleanUpNonConnected() to really erase them, or it will be done at destruction of pin.
375  //! \param pin if not NULL, this pin connected is removed or set to NULL.
376  //! \param forceErase if true, the pin connections is removed from the connection list else, only set to NULL.
377  bool Disconnect( a2dPin* pin = a2dAnyPin, bool forceErase = false );
378 
379  //! connect this pin to the given pin
380  void ConnectTo( a2dPin* connectto );
381 
382  //! Return the pin to which this pin is connected.
383  /*!
384  \param pin look for connection to this pin, if not given, first connected pin is returned.
385  */
386  a2dPin* IsConnectedTo( a2dPin* pin = a2dAnyPin ) const;
387 
388  //! find connecting pin which is not a wire.
389  //! Return NULL if non found
390  //! /param mask the connected object must have given mask.
391  a2dPin* FindNonWirePin( a2dCanvasObjectFlagsMask mask = a2dCanvasOFlags::ALL );
392 
393  //! find connecting pin which is a wire.
394  //! Return NULL if non found
395  //! /param mask the connected object must have given mask.
397 
398  //! Find a connectable pin.
399  /*! This only searches for pins of child objects of the root given */
400  a2dPin* FindConnectablePin( a2dCanvasObject* root, double margin, bool autocreate );
401 
402  //! Try to connect this pin to another pin at the same location
403  void AutoConnect( a2dCanvasObject* root, double margin );
404 
405  //! Check if this pin is Dislocated ( pin pos different from connected pins pos )
406  //! returns connected pin which is dislocated the most.
407  a2dPin* IsDislocated() const;
408 
409  //! Check if this pin is at same location
410  bool IsSameLocation( a2dPin* other, double margin = 0 ) const;
411 
412  //! return true if this pin is a dynamic pin
413  /*!
414  Pins like this are create automatically by some objects, when they are able to connect.
415  The location is dynamic, and therefore they are called dynamic.
416  When moving connected objects/wires, the pins may move in position.
417  */
418  bool IsDynamicPin() const { return m_dynamicPin; }
419 
420  //! set when pin is a dynamic pin
421  void SetDynamicPin( bool dynamicPin ) { m_dynamicPin = dynamicPin; }
422 
423  //! return true if this pin is a temporary pin
424  /*!
425  Pins like this are created automatically by some objects, when they are able to connect.
426  Since for Undo actions, commands are normally used to create extra pins inside tools.
427  But a temporary pin is in general for editing feedback, and therefore it only will stay alive when
428  the tools attempt to connect a second pin to it.
429  At that moment it becomes clear that a command is needed to create and connect the temporary pin using commands.
430  If not, the temporary pin will be deleted in the end, as if it did never existed, and no commands on the command stack
431  were issued.
432  */
433  bool IsTemporaryPin() const { return m_temporaryPin; }
434 
435  //! set when pin is only a temporary pin, which will be deleted by the application if not connected
436  //! to another pin later.
437  void SetTemporaryPin( bool temporaryPin ) { m_temporaryPin = temporaryPin; }
438 
439  //! set when pin is within the border of its parent
440  /*!
441  Used when routing wires to a pin which is within the object and not on the border.
442  Meaning wires must be able to route within the object that contains the pin.
443  */
444  void SetInternal( bool internal ) { m_internal = internal; }
445 
446  //! see SetInternal()
447  bool IsInternal() const { return m_internal; }
448 
449  //! set when pin is an object pin
450  void SetObjectPin( bool objectPin ) { m_objectPin = objectPin; }
451 
452  //! return true if the pin is on object instead of wire/connects
453  bool IsObjectPin() const { return m_objectPin; }
454 
455  a2dPinFlagsMask GetPinFlags() const;
456 
457  void SetPinFlags( a2dPinFlagsMask which, bool value );
458 
459  void SetPinFlags( a2dPinFlagsMask which );
460 
461  //! Return list fo connected pins.
462  a2dlist< a2dDumbPtr<a2dPin> >& GetConnectedPins() { return m_connectedPins; }
463 
464  //!Get the number of connected pins
465  wxUint32 GetConnectedPinsNr() const;
466 
467  //! Items in m_connectedPins which are NULL will be erased.
468  //! The NULL items is how Disconnect() does disconnect pins, if erase is not forced.
469  void CleanUpNonConnected();
470 
471  //! all connections to this pins, will become available in those connected pins too.
472  void DuplicateConnectedToOtherPins( bool undo = false );
473 
474  //! pins connected to given other pin, will become part of this pin.
475  void DuplicateConnectedPins( a2dPin* other, bool undo = false );
476 
477  //! pins connected to given other pin, will be removed on this pin.
478  void RemoveDuplicateConnectedPins( a2dPin* other );
479 
480  // to temporarily disable rendering ( like when rendering from a2dCameleonInst )
481  static void SetDoRender( bool doRender ) { m_doRender = doRender; }
482 
483  // to temporarily disable rendering ( like when rendering from a2dCameleonInst )
484  static bool GetDoRender() { return m_doRender; }
485 
486  virtual bool IsTemporary_DontSave() const;
487  virtual bool AlwaysWriteSerializationId() const;
488  virtual bool LinkReference( a2dObject* other );
489 
490  DECLARE_DYNAMIC_CLASS( a2dPin )
491 
492  //****************** RENDERING AND STYLE ******************/
493  /*! \name Rendering mode, set by connection feedback in e.g. a wire tool
494  */
495  //\{
496  //! Pin is not connected rendering mode
497  const static long sm_PinUnConnected;
498  //! Pin is connected rendering mode
499  const static long sm_PinConnected;
500  //! Pin can be connected rendering mode
501  const static long sm_PinCanConnect;
502  //! Pin can NOT be connected rendering mode
503  const static long sm_PinCannotConnect;
504  //! Pin can connect to supplied a2dPinClass
505  const static long sm_PinCanConnectToPinClass;
506  //\}
507 
508 protected:
509 
510  //! \remark the parent of the pin is taken over, but its connection pin only via refs to resolve
511  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const;
512 
513 #if wxART2D_USE_CVGIO
514  virtual void DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts );
515  virtual void DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite );
516 #endif //wxART2D_USE_CVGIO
517 
518  bool DoIsHitWorld( a2dIterC& ic, a2dHitEvent& hitEvent );
519 
521 
523 
525 
526  virtual void DrawHighLighted( a2dIterC& ic );
527 
528  void DoRender( a2dIterC& ic, OVERLAP clipparent );
529  a2dBoundingBox DoGetUnTransformedBbox( a2dBboxFlags flags = a2dCANOBJ_BBOX_NON ) const;
530  bool DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox );
531 
532 #ifdef _DEBUG
533  virtual void DoDump( int indent, wxString* line );
534 #endif
535 
536  //! name of the handle
537  wxString m_name;
538 
539  //!width in pixels
540  double m_width;
541 
542  //!height in pixels
543  double m_height;
544 
545  //!radius of rectangle that will be rendered
546  double m_radius;
547 
548  //! modifies rendering
549  int m_mode;
550 
551  //!what is the a2dCanvasObject that i am part of
552  //* This is intentionally not a smart pointer to remove a reference loop */
554 
555  //! pins are world based or not.
556  static bool m_worldBased;
557 
558  //! when set disables rending of pin objects
559  static bool m_doRender;
560 
561  //! The class defines to which other pins this pin can connect
563 
564  //! set when this pin is a temporary pin for editing feedback
565  bool m_dynamicPin: 1;
566 
567  //! set when this pin is a temporary pin for editing feedback,
568  //! this pin will be replaced by a normal pin or its flag will be reset, to make it so.
569  bool m_temporaryPin: 1;
570 
571  //! flag to render or not when connected
572  bool m_RenderConnected: 1;
573 
574  //! true when pin is internal to object border.
575  bool m_internal: 1;
576 
577  //! is true when pin is on an object instead of a wire/connect
578  bool m_objectPin: 1;
579 
580  //!to which a2dPin is this pin connected with other canvas objects its pins.
581  /*!
582  Added connections can be set to NULL or erased.
583  When not possible to erase (several ieraters on the list),
584  you can use CleanUpNonConnected() to clean the NULL items later on.
585  */
587 
588 private:
589  //!this is a not implemented copy constructor that avoids automatic creation of one
590  a2dPin( const a2dPin& other );
591 };
592 
594 
595 #if (defined(__WXMSW__) && defined(WXUSINGDLL) )
596 //! smart pointer for a2dPin
597 template class A2DCANVASDLLEXP a2dSmrtPtr<a2dPin>;
598 #endif
600 
601 //! This is a class/type description for a2dPin's
602 /*! a2dPin's have a pin class which can be used by a2dConnectionGenerator to define
603  to which other pin classes ( of other pins ) it can connect and how.
604  E.g. One class might be input and one class might be output and it is
605  only possible to connect an input to an output, but not two inputs or two
606  outputs.
607  This class mainly has a name and an array of pin classes it is allowed to connect to.
608  How and when a pinclass is connected to another pinclass ( one to one, or with a wire and what type of wire ),
609  is decided by the a2dConnectionGenerator.
610 
611  As an example:
612  You want pin object on certain layers to only connect to pins on some other layers. For that you give a pin
613  on a layerA a a2dPinClass called PC_layerA. And for pins on layers B C D you do the same.
614  Now to be able to connect a PC_layerA to PC_layerB PC_layerC and NOT PC_layerD. You add to PC_layerA
615  its m_canConnectTo, the pin classes: PC_layerA, PC_layerB, PC_layerC. And to PC_layerB, PC_layerC you add at least PC_layerA.
616  You could also define a pin class called PC_layersABC with in its m_canConnectTo he same PC_layersABC,
617  next you use for pins one layers A,B,C this class. So all pins on those ayesr can connect with each other.
618  As you see what layer a pin is on, is of no importance, it is the pin class which allows pins to connect or not.
619 
620 
621 
622  Both the class and the m_canConnectTo array are created statically. If not,
623  it is your responsibility to remove the canConnectTo array. The
624  m_canConnectTo array is terminated with a zero pointer. The default
625  class is a2dPinClass::Standard, which can only connect to itself.
626 */
627 
628 class A2DCANVASDLLEXP a2dPinClass
629 {
630 public:
631 
633  {
634  /*! output */
635  PC_angle = 0x0001,
636 
637  /*! For Xor ing and all set */
638  PC_ALLSET = 0xFFFFFFFF
639  };
640 
641  //! constructor
642  /*!
643  \param name name of the pinclass, can be used e.g. for XML saving
644  */
645  a2dPinClass( const wxString& name );
646 
647  //! destructor
648  ~a2dPinClass();
649 
650  //! add a connection pinclass, to which this pin can connect
651  void AddConnect( a2dPinClass* pinClass ) { m_canConnectTo.push_back( pinClass ); }
652 
653  //! remove a connection pinclass
654  void RemoveConnect( a2dPinClass* pinClass );
655 
656  //! called to initialize static stockobjects
657  static void InitializeStockPinClasses();
658 
659  //! called to delete all pin class objects
660  static void DeleteStockPinClasses();
661 
662  const wxString& GetName() const { return m_name; }
663 
664  //! is there an angle line on the pin
665  bool HasAngleLine() const { return ( m_flags & PC_angle ) == PC_angle; }
666 
667  //! is there an angle line on the pin
668  void SetAngleLine( bool value )
669  {
670  value ? ( m_flags = m_flags | PC_angle ) :
671  m_flags = m_flags & ( PC_ALLSET ^ PC_angle );
672  }
673 
674  //! get all flags
675  wxUint32 GetFlags() { return m_flags; }
676 
677  //! searches in the connection list for a given pin class
678  /*!
679  If the given pin class is found, this means that the pin having that pinclass can connect to
680  the pin having this pinclass.
681 
682  \param other pin to test connection
683  \param flags type of pin needed
684  */
685  a2dPinClass* CanConnectTo( a2dPinClass* other = NULL ) const;
686 
687  //! return list of connectable pin class objects.
688  std::list< a2dPinClass* >& GetConnectList() { return m_canConnectTo; }
689 
690  //! return the name of this pinclass.
691  static a2dPinClass* GetClassByName( const wxString& name );
692 
693  //! set default pin for graph like structure
694  void SetPin( a2dPin* newpin );
695 
696  //! get default pin for graph like structure
697  a2dPin* GetPin();
698 
699  //! \see GetPinCanConnect()
700  void SetPinCanConnect( a2dPin* newpin );
701 
702  //! represents the pin styles for pins that can connect right now
703  /*! This pin is usually bigger than the default pin and green */
704  a2dPin* GetPinCanConnect();
705 
706  //! \see GetPinCannotConnect()
707  void SetPinCannotConnect( a2dPin* newpin );
708 
709  //! represents the pin styles for pins that cannot connect right now
710  /*! This pin is usually smaller than the default pin and red */
711  a2dPin* GetPinCannotConnect();
712 
713  //! \see GetParPin()
714  void SetParPin( a2dParPin* newpin );
715 
716  //! Pin to use in a2dCameleonInst when creating a2dParPin from an a2dPort.
717  a2dParPin* GetParPin();
718 
719  //! Set class for generating new connection objects between object and pins
720  void SetConnectionGenerator( a2dConnectionGenerator* connectionGenerator ) { m_connectionGenerator = connectionGenerator; };
721 
722  //! Get class for generating new connection objects between object and pins
723  a2dConnectionGenerator* GetConnectionGenerator() const { return m_connectionGenerator; }
724 
725  a2dPinClass* GetPinClassForTask( a2dConnectTask task, a2dCanvasObject* obj = NULL, a2dPinClass* pinClassTo = NULL, a2dPin* pinFrom = NULL ) const
726  { return m_connectionGenerator->GetPinClassForTask( const_cast<a2dPinClass*>( this ), task, obj, pinClassTo, pinFrom ); }
727 
728 protected:
729 
730  //! name of pin class
731  wxString m_name;
732 
733  //! list of a2dPinClass objects, to which this a2dPinClass object can connect.
734  //! Each Pin has a a2dPinClass which defines to which that pin can connect to other pins.
735  //! This is approved based on those other Pins having a a2dPinClass in this array here.
736  //! Of course another pin which wants to connect, should check the availibility of this pin its pinclass
737  //! in its own connection list.
738  std::list< a2dPinClass* > m_canConnectTo;
739 
740  //! pinclass specific flags
741  wxUint32 m_flags;
742 
743  a2dPinPtr m_defPin;
744 
745  a2dPinPtr m_defCanConnectPin;
746 
747  a2dPinPtr m_defCannotConnectPin;
748 
749  a2dSmrtPtr<a2dParPin> m_defParPin;
750 
751  //! Use this connection generator for wires and pins
753 
754 public:
755 
756  //! a linked lists of all a2dPinClass'es, so that one can get a class by name
757  static std::list< a2dPinClass* > m_allPinClasses;
758 
759  //! used to ask for a new default pin on an object.
760  /*!
761  m_connectionGenerator decides what is returned when asking a connection task given this pin class.
762  */
763  static a2dPinClass* Any;
764 
765  //! Pins of this class can only connect to pins of the same class
767 };
768 
769 #endif /* __WXCANPIN_H__ */
770 
wxPoint2DDouble a2dPoint2D
this to define if coordinate numbers are integer or doubles
Definition: artglob.h:47
void SetConnectionGenerator(a2dConnectionGenerator *connectionGenerator)
Set class for generating new connection objects between object and pins.
Definition: canpin.h:720
virtual bool DoIsHitWorld(a2dIterC &ic, a2dHitEvent &hitEvent)
Does hit test on the object (exclusif child objects)
Definition: canobj.cpp:3713
void OnEnterObject(a2dCanvasObjectMouseEvent &event)
called when the mouse enters the object
Definition: canobj.cpp:1940
virtual void SetParent(a2dCanvasObject *parent)
set parent object of the pin or some other objects that needs a parent
Definition: canobj.h:2122
wxString m_name
name of the handle
Definition: canpin.h:537
a2dHandle is used inside editing versions of a certain objects.
Definition: canpin.h:30
virtual bool IsTemporary_DontSave() const
Check if this is a temporary object, which should not be saved.
Definition: canobj.cpp:6365
mouse event sent from a2dCanvasObject to itself
Definition: canglob.h:223
a2dConnectTask
flags for searching a connecting a2dpinClass, for the connecting task at hand.
Definition: connectgen.h:40
virtual wxString GetName() const
Returns the name of this object, if no name is given the internal id will be returned.
Definition: gen.cpp:1310
void OnCanvasObjectMouseEvent(a2dCanvasObjectMouseEvent &event)
default handler for mouse events, sent to the object from the a2dDrawingPart.
Definition: canobj.cpp:2391
class to map references to objects stored in XML, in order to make the connection later on...
Definition: gen.h:3462
void SetName(const wxString &name)
set the name of the handle (must be unique)
Definition: canpin.h:59
a2dCanvasOFlags m_flags
holds flags for objects
Definition: canobj.h:2528
int GetMode() const
get current mode
Definition: canpin.h:313
a2dPin is used in a2dCanvasObject to add pins to it.
Definition: canpin.h:233
This is a class/type description for a2dPin&#39;s.
Definition: canpin.h:628
Ref Counted base object.
Definition: gen.h:1045
void AddConnect(a2dPinClass *pinClass)
add a connection pinclass, to which this pin can connect
Definition: canpin.h:651
double GetRadius() const
return radius
Definition: canpin.h:304
virtual bool AlwaysWriteSerializationId() const
If true, always write an id.
Definition: gen.cpp:1455
static bool m_worldBased
pins are world based or not.
Definition: canpin.h:556
a2dPinClass * m_pinclass
The class defines to which other pins this pin can connect.
Definition: canpin.h:562
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:819
UpdateMode
Various mode flags for Update.
Definition: canobj.h:1091
virtual void SetPending(bool pending)
set this object pending for update
Definition: canobj.cpp:2585
OVERLAP
Result of a a2dBoundingBox intersection or hittest.
Definition: bbox.h:24
wxUint32 m_flags
pinclass specific flags
Definition: canpin.h:741
a2dParPin points to a2dPort
Definition: cameleon.h:172
The base class for all drawable objects in a a2dCanvasDocument.
#define DECLARE_PROPERTIES()
check if class has the given id as a valid id for this object
Definition: gen.h:835
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: canobj.cpp:5728
double m_height
height in pixels
Definition: canpin.h:543
a2dCanvasObject is the base class for Canvas Objects.
Definition: canobj.h:371
a2dCanvasObject * m_parent
what is the a2dCanvasObject that i am part of
Definition: canpin.h:553
defenitions an no more
wxString GetName() const
get the name given to the handle.
Definition: canpin.h:56
virtual void DoRender(a2dIterC &ic, OVERLAP clipparent)
render derived object
Definition: canobj.cpp:4695
double GetHeight() const
return height
Definition: canpin.h:90
bool HasAngleLine() const
is there an angle line on the pin
Definition: canpin.h:665
wxUint64 a2dCanvasObjectFlagsMask
mask flags for a2dCanvasObject
Definition: candefs.h:152
void SetInternal(bool internal)
set when pin is within the border of its parent
Definition: canpin.h:444
std list compatible list
Definition: a2dlist.h:42
void SetTemporaryPin(bool temporaryPin)
Definition: canpin.h:437
wxString m_name
name of pin class
Definition: canpin.h:731
std::list< a2dPinClass * > & GetConnectList()
return list of connectable pin class objects.
Definition: canpin.h:688
bool GetRenderConnected()
Definition: canpin.h:287
a2dlist< a2dDumbPtr< a2dPin > > m_connectedPins
to which a2dPin is this pin connected with other canvas objects its pins.
Definition: canpin.h:586
double GetHeight() const
return height
Definition: canpin.h:301
void SetMode(int mode)
default used to modify rendering
Definition: canpin.h:307
bool IsObjectPin() const
return true if the pin is on object instead of wire/connects
Definition: canpin.h:453
a2dSmrtPtr< a2dHandle > a2dHandlePtr
smart pointer for a2dHandle
Definition: canpin.h:178
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: canobj.cpp:5569
static std::list< a2dPinClass * > m_allPinClasses
a linked lists of all a2dPinClass&#39;es, so that one can get a class by name
Definition: canpin.h:757
void OnLeaveObject(a2dCanvasObjectMouseEvent &event)
called when the mouse leaves the object
Definition: canobj.cpp:1997
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:862
double m_radius
radius of rectangle that will be rendered
Definition: canpin.h:546
bool IsInternal() const
see SetInternal()
Definition: canpin.h:447
double m_width
width in pixels
Definition: canpin.h:540
void SetObjectPin(bool objectPin)
set when pin is an object pin
Definition: canpin.h:450
void SetMode(int mode)
you may use it to modify rendering of the object depending on setting
Definition: canpin.h:95
static void SetWorldBased(bool worldBased)
set if pins its size is in world coordinates, else it is in pixels.
Definition: canpin.h:316
bool IsTemporaryPin() const
return true if this pin is a temporary pin
Definition: canpin.h:433
bool IsDynamicPin() const
return true if this pin is a dynamic pin
Definition: canpin.h:418
a2dPinClass * GetPinClass() const
return the pin class of this pin
Definition: canpin.h:356
while iterating a a2dCanvasDocument, this holds the context.
Definition: canobj.h:3212
virtual void DrawHighLighted(a2dIterC &ic)
called by Render() if m_flags.m_HighLight is set
Definition: canobj.cpp:5020
a2dlist< a2dDumbPtr< a2dPin > > & GetConnectedPins()
Return list fo connected pins.
Definition: canpin.h:462
a2dCanvasObject * GetParent() const
get parent object of the pin
Definition: canpin.h:84
wxString GetName() const
get the name given to the pin.
Definition: canpin.h:322
void SetRenderConnected(bool RenderConnected)
flag to render connected pin
Definition: canpin.h:284
a2dConnectionGenerator * GetConnectionGenerator() const
Get class for generating new connection objects between object and pins.
Definition: canpin.h:723
int GetMode() const
get the rendering mode of the object.
Definition: canpin.h:100
static a2dPinClass * Standard
Pins of this class can only connect to pins of the same class.
Definition: canpin.h:766
double GetWidth() const
return width
Definition: canpin.h:87
static bool m_doRender
when set disables rending of pin objects
Definition: canpin.h:559
double GetRadius() const
return radius
Definition: canpin.h:93
virtual bool LinkReference(a2dObject *other)
link a reference in the object to the given value
Definition: gen.cpp:1460
void SetPinClass(a2dPinClass *pinClass)
Set the pin class.
Definition: canpin.h:359
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject.
Definition: bbox.h:39
void SetDynamicPin(bool dynamicPin)
set when pin is a dynamic pin
Definition: canpin.h:421
wxUint32 GetFlags()
get all flags
Definition: canpin.h:675
a2dPinFlags
Definition: canpin.h:242
virtual a2dBoundingBox DoGetUnTransformedBbox(a2dBboxFlags flags=a2dCANOBJ_BBOX_NON) const
In derived object this should be overriden to calculate the boundingbox of the object without its chi...
Definition: canobj.cpp:5031
int m_mode
modifies rendering
Definition: canpin.h:549
Classes for generating connection between pins in canvas objects.
static bool GetWorldBased()
get if pin sizes are in world coordinates, else it is in pixels.
Definition: canpin.h:319
static a2dPinClass * Any
used to ask for a new default pin on an object.
Definition: canpin.h:763
virtual bool DoUpdate(UpdateMode mode, const a2dBoundingBox &childbox, const a2dBoundingBox &clipbox, const a2dBoundingBox &propbox)
Update derived Object specific things ( mainly boundingbox)
Definition: canobj.cpp:5098
This template class is for property ids with a known data type.
Definition: id.h:477
a2dConnectionGeneratorPtr m_connectionGenerator
Use this connection generator for wires and pins.
Definition: canpin.h:752
static const a2dCanvasObjectFlagsMask ALL
Definition: candefs.h:220
a2dPinClassFlags
Definition: canpin.h:632
void SetName(const wxString &name)
set the name of the pin (must be unique)
Definition: canpin.h:325
a2dCanvasObject * GetParent() const
get parent object of the pin
Definition: canpin.h:295
std::list< a2dPinClass * > m_canConnectTo
Definition: canpin.h:738
void SetAngleLine(bool value)
is there an angle line on the pin
Definition: canpin.h:668
double GetWidth() const
return width
Definition: canpin.h:298
list of a2dObject&#39;s
Definition: gen.h:3157
CloneOptions
options for cloning
Definition: gen.h:1200
when a new wire or other connection object needs to be created,
Definition: connectgen.h:153
structure to give as parameter to member functions of a2dCanvasObject
Definition: canobj.h:252
canpin.h Source File -- Sun Oct 12 2014 17:04:14 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation