OpenASIP 2.2
Loading...
Searching...
No Matches
MachineCanvas.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 MachineCanvas.hh
26 *
27 * Declaration of MachineCanvas class.
28 *
29 * @author Veli-Pekka Jääskeläinen (vjaaskel-no.spam-cs.tut.fi)
30 * @note rating: red
31 */
32
33#ifndef TTA_MACHINE_CANVAS_HH
34#define TTA_MACHINE_CANVAS_HH
35
36#include <vector>
37#include <wx/scrolwin.h>
38#include <wx/docmdi.h>
39#include "Exception.hh"
41#include "ChildFrame.hh"
42
43namespace TTAMachine {
44 class Machine;
45 class MachinePart;
46 class Bus;
47 class Port;
48}
49
51class RootEditPart;
53class EditPart;
54class Figure;
55
56/**
57 * Machine Object Model visualization canvas.
58 *
59 * MachineCanvas is a window which can be utilized to display visualization
60 * of a machine object model. The visualization is interactive, and behaviour
61 * of machine components can be defined using custom EditPolicies and custom
62 * MachineCanvasTools.
63 */
64class MachineCanvas : public wxScrolledWindow {
65public:
66 MachineCanvas(wxWindow* parent, EditPolicyFactory* policyFactory,
67 ChildFrame* parentFrame = nullptr);
68 virtual ~MachineCanvas();
69 virtual void OnDraw(wxDC& dc);
70
71 double zoomFactor();
72 void setZoomFactor(double factor);
73 void zoomIn();
74 void zoomOut();
75 wxSize getFigureSize() const;
76
77
80
82 void updateMachine();
84 EditPart* findEditPart(int x, int y);
86 bool hasEditPart(const EditPart* part) const;
87 int findEditPartsInRange(int x, int y, int range,
88 std::vector<EditPart*>& found);
89 void highlight(TTAMachine::MachinePart* model, const wxColour& colour);
90 void clearHighlights();
91 void clearSelection();
92 void select(EditPart* part);
93 void refreshToolFigure();
94
95 void addMove(
96 const TTAMachine::Bus* bus, const TTAMachine::Port* source,
97 const TTAMachine::Port* target);
98 void clearMoves();
99
100#if wxCHECK_VERSION(3, 0, 0)
101 bool saveSVG(const std::string& filename);
102#else
103 bool saveEPS(
104 const std::string& filename,
105 const std::string& title,
106 const std::string& creator = "");
107#endif
108
109 bool savePNG(const std::string& filename);
110
112
113protected:
114 void onMouseEvent(wxMouseEvent& event);
115 void refreshLogicalRect(const wxRect& rectangle);
116
117private:
118 /// Tool which handles mouse events on the MachineCanvas.
120 /// Machine to draw on the canvas.
122 /// EditPolicyFactory which creates edit policies for machine components.
124 /// Parent frame which holds the MachineCanvas
126
127 /// Zoom factor of the canvas.
129 /// Tells if the figures need to be laid out before next draw.
130 bool dirty_;
131 /// Root of the machine EditPart hierarchy.
133
134 /// Pointer to the the selected component.
136 /// Bounding box of the last tool figure drawn.
138
139 /// Move figures to be drawn on the canvas.
140 std::vector<Figure*> moveFigures_;
141
143
144 /// Event table of the canvas.
145 DECLARE_EVENT_TABLE()
146};
147#endif
TTAMachine::Machine * machine
the architecture definition of the estimated processor
bool savePNG(const std::string &filename)
EditPolicyFactory * editPolicyFactory_
EditPolicyFactory which creates edit policies for machine components.
void onMouseEvent(wxMouseEvent &event)
virtual ~MachineCanvas()
RootEditPart * root_
Root of the machine EditPart hierarchy.
void highlight(TTAMachine::MachinePart *model, const wxColour &colour)
EditPart * selection()
wxSize getFigureSize() const
int findEditPartsInRange(int x, int y, int range, std::vector< EditPart * > &found)
TTAMachine::Machine * machine_
Machine to draw on the canvas.
std::vector< Figure * > moveFigures_
Move figures to be drawn on the canvas.
double zoomFactor_
Zoom factor of the canvas.
void setTool(MachineCanvasTool *tool)
MachineCanvasTool * tool()
void select(EditPart *part)
MachineCanvasTool * tool_
Tool which handles mouse events on the MachineCanvas.
void addMove(const TTAMachine::Bus *bus, const TTAMachine::Port *source, const TTAMachine::Port *target)
bool hasEditPart(const EditPart *part) const
bool saveEPS(const std::string &filename, const std::string &title, const std::string &creator="")
wxRect toolBounds_
Bounding box of the last tool figure drawn.
EditPart * findEditPart(int x, int y)
virtual void OnDraw(wxDC &dc)
void refreshToolFigure()
void refreshLogicalRect(const wxRect &rectangle)
EditPart * selection_
Pointer to the the selected component.
ChildFrame * parent_
Parent frame which holds the MachineCanvas.
bool dirty_
Tells if the figures need to be laid out before next draw.
double zoomFactor()
MachineCanvasOptions options_
MachineCanvasOptions & options()
void setMachine(TTAMachine::Machine *machine)
void setZoomFactor(double factor)