Go to the documentation of this file.
35 #include <wx/dcclient.h>
54 #if wxCHECK_VERSION(3, 0, 0)
72 wxScrolledWindow(parent), tool_(NULL), machine_(NULL),
73 editPolicyFactory_(policyFactory), parent_(parentFrame),
74 zoomFactor_(1.0), dirty_(true), root_(NULL),
75 selection_(NULL), toolBounds_(0, 0, 0, 0) {
79 SetScrollRate(20, 20);
80 SetVirtualSize(1000, 800);
103 wxBrush backgroundBrush(*wxLIGHT_GREY, wxSOLID);
104 dc.SetBackground(backgroundBrush);
106 #if wxCHECK_VERSION(3, 0, 0)
109 (void)
dynamic_cast<wxSVGFileDC&
> (dc);
110 }
catch (
const std::bad_cast& e) {
118 dc.SetFont(wxFont(10, wxDEFAULT, wxNORMAL, wxNORMAL));
129 SetVirtualSize(
int(bounds.GetWidth() *
zoomFactor()),
139 if (
tool() != NULL) {
141 if (toolFigure != NULL) {
143 toolFigure->
draw(&dc);
172 if (toolFigure != NULL) {
204 int scrollUnitX, scrollUnitY;
205 GetScrollPixelsPerUnit(&scrollUnitX, &scrollUnitY);
206 GetViewStart(&x, &y);
209 GetSize(&xSize, &ySize);
212 x = std::max(
static_cast<int>(xPos * factor) - (xSize >> 1), 0);
213 y =
static_cast<int>(yPos * factor);
214 Scroll((x + (scrollUnitX >> 1)) / scrollUnitX,
215 (y + (scrollUnitY >> 1)) / scrollUnitY);
272 if (event.GetEventType() == wxEVT_MOUSEWHEEL) {
275 if (event.GetWheelRotation() > 0) {
333 CalcScrolledPosition(
int(rectangle.x *
zoomFactor_),
335 wxRect zoomed(x, y,
int(rectangle.width *
zoomFactor_),
364 wxString text(_T(
""));
368 int width = bem->
width();
369 text = wxString::Format(_T(
"Instruction width: %u"), width);
371 text = _T(
"BEM could not be generated");
455 std::vector<EditPart*>& found) {
458 static_cast<float>(range), found);
494 if (segment != NULL) {
511 const wxColour& colour) {
518 if (editPart != NULL && editPart->
figure() != NULL) {
542 std::string procName =
"MachineCanvas::addMove";
545 if (busEditPart == NULL) {
550 Figure* sourceFigure = NULL;
551 Figure* targetFigure = NULL;
553 if (source != NULL) {
555 if (sourceEditPart == NULL) {
558 sourceFigure = sourceEditPart->
figure();
561 if (target != NULL) {
563 if (targetEditPart == NULL) {
566 targetFigure = targetEditPart->
figure();
570 new MoveFigure(busFigure, sourceFigure, targetFigure));
581 #if wxCHECK_VERSION(3, 0, 0)
589 MachineCanvas::saveSVG(
const std::string& filename) {
591 wxClientDC clientDC(
this);
596 int width = clientDC.MaxX() + clientDC.MinX();
597 int height = clientDC.MaxY() + clientDC.MinY();
599 wxSVGFileDC svg(filename, width, height);
618 const std::string& creator) {
628 std::ofstream file(filename.c_str());
651 wxClientDC clientDC(
this);
656 int width = clientDC.MaxX() + clientDC.MinX();
657 int height = clientDC.MaxY() + clientDC.MinY();
661 wxBitmap bitmap(width, height);
662 bitmapDC.SelectObject(bitmap);
668 if (bitmap.SaveFile(file, wxBITMAP_TYPE_PNG)) {
wxSize getFigureSize() const
EditPart * findEditPart(int x, int y)
void onMouseEvent(wxMouseEvent &event)
void setStatus(const wxString text, int field=0)
static wxString toWxString(const std::string &source)
MachineCanvasOptions options_
void setZoomFactor(double factor)
TTAMachine::Machine * machine
the architecture definition of the estimated processor
EditPart * find(wxPoint point)
virtual EditPart * createEditPart(TTAMachine::MachinePart *component)
void refreshLogicalRect(const wxRect &rectangle)
static const double MAX_ZOOM_FACTOR
Maximum zoom factor.
wxRect toolBounds_
Bounding box of the last tool figure drawn.
EditPart * selection_
Pointer to the the selected component.
EditPolicyFactory * editPolicyFactory_
EditPolicyFactory which creates edit policies for machine components.
static const double MIN_ZOOM_FACTOR
Minimum zoom factor.
ChildFrame * parent_
Parent frame which holds the MachineCanvas.
bool saveEPS(const std::string &filename, const std::string &title, const std::string &creator="")
bool hasEditPartRecursive(const EditPart *part) const
void setTool(MachineCanvasTool *tool)
double zoomFactor_
Zoom factor of the canvas.
EditPart * contents() const
TTAMachine::Machine * machine_
Machine to draw on the canvas.
#define assert(condition)
void setTitle(const std::string &title)
void writeToStream(std::ostream &stream)
static const double ZOOM_STEP
Step between zoom levels.
MachineCanvasTool * tool_
Tool which handles mouse events on the MachineCanvas.
void setContents(EditPart *contents)
virtual int width(const TCEString &templateName) const
MachineCanvasTool * tool()
std::vector< Figure * > moveFigures_
Move figures to be drawn on the canvas.
TTAMachine::MachinePart * model() const
void select(EditPart *part)
MachineCanvasOptions & options()
EditPart * parent() const
int findInRange(wxPoint point, float radius, std::vector< EditPart * > &found)
RootEditPart * root_
Root of the machine EditPart hierarchy.
void setMachine(TTAMachine::Machine *machine)
int findEditPartsInRange(int x, int y, int range, std::vector< EditPart * > &found)
void addMove(const TTAMachine::Bus *bus, const TTAMachine::Port *source, const TTAMachine::Port *target)
void setSelected(bool select)
void highlight(TTAMachine::MachinePart *model, const wxColour &colour)
bool savePNG(const std::string &filename)
bool dirty_
Tells if the figures need to be laid out before next draw.
virtual void OnDraw(wxDC &dc)
void setCreator(const std::string &creator)
bool hasEditPart(const EditPart *part) const
BinaryEncoding * generate()
END_EVENT_TABLE() using namespace IDF