OpenASIP  2.0
EditPart.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file EditPart.hh
26  *
27  * Declaration of EditPart class.
28  *
29  * @author Ari Metsähalme 2003 (ari.metsahalme-no.spam-tut.fi)
30  * @note rating: yellow
31  * @note reviewed Jul 13 2004 by vpj, ll, jn, am
32  */
33 
34 #ifndef TTA_EDIT_PART_HH
35 #define TTA_EDIT_PART_HH
36 
37 #include <vector>
38 #include <set>
39 #include <stddef.h>
40 
41 class Figure;
42 class wxPoint;
43 class wxRect;
44 class EditPolicy;
45 class Request;
46 class ComponentCommand;
47 
48 namespace TTAMachine {
49  class MachinePart;
50 }
51 
52 /**
53  * Connects a model object to a graphical object on the canvas.
54  *
55  * An EditPart receives Requests generated by user actions and
56  * converts them to possible changes in the model (Commands) using its
57  * EditPolicies. EditParts can contain other EditParts as children.
58  * Every EditPart has a Figure.
59  */
60 class EditPart {
61 public:
62  EditPart();
63  virtual ~EditPart();
64 
65  void putGarbage(std::set<EditPart*>& trashbag);
66  EditPart* parent() const;
67  void setParent(EditPart* parent);
70  Figure* figure() const;
71  void setFigure(Figure* figure);
72  EditPart* find(wxPoint point);
74  EditPart* findNearest(wxPoint point, const EditPart* exclude = NULL);
75  int findInRange(wxPoint point, float radius,
76  std::vector<EditPart*>& found);
77  bool hasEditPartRecursive(const EditPart* part) const;
78  bool selectable() const;
79  bool selected() const;
80  void setSelectable(bool selectable);
81  void setSelected(bool select);
82  void installEditPolicy(EditPolicy* editpolicy);
83  void addChild(EditPart* child);
84  int childCount() const ;
85  EditPart* child(unsigned int index) const;
86  ComponentCommand* performRequest(Request* request) const;
87  bool canHandle(Request* request) const;
88 
89 protected:
90  /// Parent of this EditPart.
92  /// Figure of this EditPart.
94  /// Machine component corresponding to this EditPart.
96  /// Tells whether the EditPart is selectable or not.
98  /// Tells whether the EditPart is selected or not.
99  bool selected_;
100 
101  /// Helper member to prevent improper deletion.
103 
104  /// List of supported EditPolicies.
105  std::vector<EditPolicy*> editPolicies_;
106  /// List of children EditParts.
107  std::vector<EditPart*> children_;
108 
109 private:
110  /// Assignment not allowed.
111  EditPart& operator=(EditPart& old);
112  /// Copying not allowed.
113  EditPart(EditPart& old);
114 
115  static float distance(wxPoint p, wxRect r);
116 };
117 
118 #include "EditPart.icc"
119 
120 #endif
EditPart::findNearest
EditPart * findNearest(wxPoint point, const EditPart *exclude=NULL)
Definition: EditPart.cc:162
EditPart::garbageCollected_
bool garbageCollected_
Helper member to prevent improper deletion.
Definition: EditPart.hh:102
EditPart::find
EditPart * find(wxPoint point)
Definition: EditPart.cc:102
EditPart::setSelectable
void setSelectable(bool selectable)
EditPart::~EditPart
virtual ~EditPart()
Definition: EditPart.cc:72
EditPart::figure_
Figure * figure_
Figure of this EditPart.
Definition: EditPart.hh:93
EditPart::installEditPolicy
void installEditPolicy(EditPolicy *editpolicy)
Definition: EditPart.cc:247
EditPart::performRequest
ComponentCommand * performRequest(Request *request) const
Definition: EditPart.cc:297
EditPart::distance
static float distance(wxPoint p, wxRect r)
Definition: EditPart.cc:335
EditPart::hasEditPartRecursive
bool hasEditPartRecursive(const EditPart *part) const
Definition: EditPart.cc:274
EditPart::operator=
EditPart & operator=(EditPart &old)
Assignment not allowed.
EditPart::setParent
void setParent(EditPart *parent)
EditPart::children_
std::vector< EditPart * > children_
List of children EditParts.
Definition: EditPart.hh:107
EditPart::selectable
bool selectable() const
Figure
Definition: Figure.hh:50
EditPart::EditPart
EditPart()
Definition: EditPart.cc:60
EditPart::selectable_
bool selectable_
Tells whether the EditPart is selectable or not.
Definition: EditPart.hh:97
EditPart::setModel
void setModel(TTAMachine::MachinePart *model)
TTAMachine::MachinePart
Definition: MachinePart.hh:57
EditPolicy
Definition: EditPolicy.hh:47
EditPart
Definition: EditPart.hh:60
EditPart::child
EditPart * child(unsigned int index) const
EditPart::childCount
int childCount() const
EditPart::selected_
bool selected_
Tells whether the EditPart is selected or not.
Definition: EditPart.hh:99
EditPart::model
TTAMachine::MachinePart * model() const
Request
Definition: Request.hh:43
ComponentCommand
Definition: ComponentCommand.hh:46
EditPart::figure
Figure * figure() const
EditPart::parent
EditPart * parent() const
EditPart::findInRange
int findInRange(wxPoint point, float radius, std::vector< EditPart * > &found)
Definition: EditPart.cc:219
EditPart::model_
TTAMachine::MachinePart * model_
Machine component corresponding to this EditPart.
Definition: EditPart.hh:95
EditPart::setFigure
void setFigure(Figure *figure)
EditPart::canHandle
bool canHandle(Request *request) const
Definition: EditPart.cc:316
EditPart.icc
EditPart::setSelected
void setSelected(bool select)
EditPart::editPolicies_
std::vector< EditPolicy * > editPolicies_
List of supported EditPolicies.
Definition: EditPart.hh:105
EditPart::addChild
void addChild(EditPart *child)
Definition: EditPart.cc:260
TTAMachine
Definition: Assembler.hh:48
EditPart::selected
bool selected() const
EditPart::parent_
EditPart * parent_
Parent of this EditPart.
Definition: EditPart.hh:91
EditPart::putGarbage
void putGarbage(std::set< EditPart * > &trashbag)
Definition: EditPart.cc:87