OpenASIP 2.2
Loading...
Searching...
No Matches
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
41class Figure;
42class wxPoint;
43class wxRect;
44class EditPolicy;
45class Request;
47
48namespace 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 */
60class EditPart {
61public:
62 EditPart();
63 virtual ~EditPart();
64
65 void putGarbage(std::set<EditPart*>& trashbag);
66 EditPart* parent() const;
70 Figure* figure() const;
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;
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;
87 bool canHandle(Request* request) const;
88
89protected:
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.
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
109private:
110 /// Assignment not allowed.
112 /// Copying not allowed.
114
115 static float distance(wxPoint p, wxRect r);
116};
117
118#include "EditPart.icc"
119
120#endif
bool selected_
Tells whether the EditPart is selected or not.
Definition EditPart.hh:99
void setModel(TTAMachine::MachinePart *model)
int findInRange(wxPoint point, float radius, std::vector< EditPart * > &found)
Definition EditPart.cc:219
EditPart & operator=(EditPart &old)
Assignment not allowed.
EditPart * findNearest(wxPoint point, const EditPart *exclude=NULL)
Definition EditPart.cc:162
EditPart(EditPart &old)
Copying not allowed.
std::vector< EditPolicy * > editPolicies_
List of supported EditPolicies.
Definition EditPart.hh:105
TTAMachine::MachinePart * model_
Machine component corresponding to this EditPart.
Definition EditPart.hh:95
static float distance(wxPoint p, wxRect r)
Definition EditPart.cc:335
bool selectable() const
bool selected() const
Figure * figure_
Figure of this EditPart.
Definition EditPart.hh:93
void installEditPolicy(EditPolicy *editpolicy)
Definition EditPart.cc:247
std::vector< EditPart * > children_
List of children EditParts.
Definition EditPart.hh:107
void setFigure(Figure *figure)
bool hasEditPartRecursive(const EditPart *part) const
Definition EditPart.cc:274
void setSelectable(bool selectable)
int childCount() const
Figure * figure() const
bool canHandle(Request *request) const
Definition EditPart.cc:316
ComponentCommand * performRequest(Request *request) const
Definition EditPart.cc:297
EditPart * parent_
Parent of this EditPart.
Definition EditPart.hh:91
bool garbageCollected_
Helper member to prevent improper deletion.
Definition EditPart.hh:102
void setParent(EditPart *parent)
void setSelected(bool select)
EditPart * parent() const
EditPart * child(unsigned int index) const
void addChild(EditPart *child)
Definition EditPart.cc:260
EditPart * find(wxPoint point)
Definition EditPart.cc:102
TTAMachine::MachinePart * model() const
virtual ~EditPart()
Definition EditPart.cc:72
void putGarbage(std::set< EditPart * > &trashbag)
Definition EditPart.cc:87
bool selectable_
Tells whether the EditPart is selectable or not.
Definition EditPart.hh:97