OpenASIP  2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
MDFView Class Reference

#include <MDFView.hh>

Inheritance diagram for MDFView:
Inheritance graph
Collaboration diagram for MDFView:
Collaboration graph

Public Member Functions

 MDFView ()
 
virtual ~MDFView ()
 
virtual bool OnCreate (wxDocument *doc, long)
 
virtual bool OnClose (bool deleteWindow)
 
virtual void OnUpdate (wxView *sender, wxObject *hint)
 
virtual void OnDraw (wxDC *dc)
 
void clearSelection ()
 
EditPartselection ()
 
virtual void OnActivateView (bool activate, wxView *activateView, wxView *deactivateView)
 
virtual void OnChangeFilename ()
 
virtual wxPrintout * OnCreatePrintout ()
 
MachineCanvascanvas () const
 

Private Member Functions

 MDFView (const MDFView &)
 Copying forbidden. More...
 
MDFViewoperator= (const MDFView &)
 Assignment forbidden. More...
 

Private Attributes

MachineCanvascanvas_
 The window where the figures are drawn. More...
 
ChildFrameframe_
 ChildFrame for displaying the view. More...
 

Detailed Description

Viewing and editing component of a MDFDocument.

Part of the wxWidgets document/view framework. View of a Machine Object Model consists of EditParts defining the editing behaviour of the model components. For each EditPart in the view exists a figure defining the visualization of the component. The EditParts form a tree hierarchy starting from the top level contents EditPart, which is a child of the RootEditPart. This class also keeps track of the selected EditParts.

Definition at line 59 of file MDFView.hh.

Constructor & Destructor Documentation

◆ MDFView() [1/2]

MDFView::MDFView ( )

The Constructor.

Definition at line 60 of file MDFView.cc.

60  :
61  wxView(),
62  canvas_(NULL),
63  frame_(NULL) {
64 }

◆ ~MDFView()

MDFView::~MDFView ( )
virtual

The Destructor.

Definition at line 70 of file MDFView.cc.

70  {
71 }

◆ MDFView() [2/2]

MDFView::MDFView ( const MDFView )
private

Copying forbidden.

Member Function Documentation

◆ canvas()

MachineCanvas * MDFView::canvas ( ) const

◆ clearSelection()

void MDFView::clearSelection ( )

Clears the component selection.

Definition at line 182 of file MDFView.cc.

182  {
184 }

References canvas_, and MachineCanvas::clearSelection().

Referenced by SelectCmd::Do(), EditConnectionsCmd::Do(), and ConnectTool::leftClick().

Here is the call graph for this function:

◆ OnActivateView()

void MDFView::OnActivateView ( bool  activate,
wxView *  activateView,
wxView *  deactivateView 
)
virtual

Sets the main frame title when the view is activated.

Definition at line 191 of file MDFView.cc.

192  {
193 
194  if (!activate) {
195  wxString title = ProDeConstants::EDITOR_NAME;
196  wxGetApp().mainFrame()->SetTitle(title);
197  return;
198  }
199 
200  OnUpdate(NULL, NULL);
201 
202  // Update main frame title.
204  wxGetApp().mainFrame()->updateUI();
205 }

References ProDeConstants::EDITOR_NAME, OnChangeFilename(), and OnUpdate().

Here is the call graph for this function:

◆ OnChangeFilename()

void MDFView::OnChangeFilename ( )
virtual

Updates the main and child frame titles when the filename changes.

Definition at line 212 of file MDFView.cc.

212  {
213  string path = WxConversion::toString(GetDocument()->GetFilename());
214  string filename = FileSystem::fileOfPath(path);
215  wxString title = ProDeConstants::EDITOR_NAME;
216  title.Append(_T(" - "));
217  title.Append(WxConversion::toWxString(filename));
218  wxGetApp().mainFrame()->SetTitle(title);
219  frame_->SetTitle(WxConversion::toWxString(filename));
220 }

References ProDeConstants::EDITOR_NAME, FileSystem::fileOfPath(), frame_, WxConversion::toString(), and WxConversion::toWxString().

Referenced by OnActivateView().

Here is the call graph for this function:

◆ OnClose()

bool MDFView::OnClose ( bool  deleteWindow)
virtual

Implements closing behaviour.

Closes the associated document.

Parameters
deleteWindowIf true, deletes the frame associated with the view.
Returns
true if the associated document was succesfully closed.

Definition at line 83 of file MDFView.cc.

83  {
84 
85  if (!GetDocument()->Close()) {
86  return false;
87  }
88 
89  Activate(false);
90 
91  if (deleteWindow) {
92  delete canvas_;
93  canvas_ = NULL;
94  delete frame_;
95  frame_ = NULL;
96  }
97  return true;
98 }

References canvas_, and frame_.

◆ OnCreate()

bool MDFView::OnCreate ( wxDocument *  doc,
long   
)
virtual

Creates a ChildFrame and a Canvas for the document when a new view is created.

Parameters
docPointer to the document which this view visualizes.
Returns
True if the ChildFrame and the Canvas was succesfully created.

Definition at line 110 of file MDFView.cc.

110  {
111 
112  if (doc == NULL) {
113  return false;
114  }
115 
116  // create a childframe for the view
117  wxDocMDIParentFrame* mainFrame = wxGetApp().mainFrame();
118  frame_ = new ChildFrame(doc, this, mainFrame);
119  SetFrame(frame_);
120  frame_->Show(true);
121 
122  // create a canvas for the child frame
124  // create select tool and set it as active tool for the canvas
125  SelectTool* selectTool = new SelectTool(frame_, this);
126  canvas_->setTool(selectTool);
127 
128  Activate(true);
129  return true;
130 }

References canvas_, frame_, and MachineCanvas::setTool().

Here is the call graph for this function:

◆ OnCreatePrintout()

wxPrintout * MDFView::OnCreatePrintout ( )
virtual

Creates printout of the machine figure.

Returns
Printout object of the machine figure for printing.

Definition at line 251 of file MDFView.cc.

251  {
252  return new ADFPrintout(*canvas_, GetDocument()->GetFilename());
253 }

References canvas_.

◆ OnDraw()

void MDFView::OnDraw ( wxDC *  dc)
virtual

Handles paint events of the view.

Parameters
dcDevice context to draw the machine on.

Definition at line 240 of file MDFView.cc.

240  {
241  canvas_->OnDraw(*dc);
242 }

References canvas_, and MachineCanvas::OnDraw().

Here is the call graph for this function:

◆ OnUpdate()

void MDFView::OnUpdate ( wxView *  sender,
wxObject *  hint 
)
virtual

Updates the model visualization.

Parameters
senderView that sent the update request, or NULL if no single view requested the update (for instance, when the document is opened).
hintUnused at the moment but may in future contain application-specific information for making updating more efficient.

Definition at line 144 of file MDFView.cc.

144  {
145 
146  wxDocument* doc = GetDocument();
147  assert(doc != NULL);
148  MDFDocument* mdfdoc = dynamic_cast<MDFDocument*>(doc);
149  assert(mdfdoc != NULL);
150 
151  Model* model = mdfdoc->getModel();
152  if (model == NULL) {
153  // The model is NULL if document opening fails.
154  // View is updated even if the document opening fails.
155  return;
156  }
157 
158  Machine* machine = model->getMachine();
159  assert(machine != NULL);
161 }

References assert, canvas_, Model::getMachine(), MDFDocument::getModel(), machine, and MachineCanvas::setMachine().

Referenced by OnActivateView().

Here is the call graph for this function:

◆ operator=()

MDFView& MDFView::operator= ( const MDFView )
private

Assignment forbidden.

◆ selection()

EditPart * MDFView::selection ( )

Returns selected component of the view.

Returns
Pointer to the selected EditPart.

Definition at line 169 of file MDFView.cc.

169  {
170  if (canvas_ != NULL) {
171  return canvas_->selection();
172  } else {
173  return NULL;
174  }
175 }

References canvas_, and MachineCanvas::selection().

Referenced by CopyComponentCmd::isEnabled(), CutComponentCmd::isEnabled(), DeleteComponentCmd::isEnabled(), ModifyComponentCmd::isEnabled(), and ConnectTool::leftClick().

Here is the call graph for this function:

Member Data Documentation

◆ canvas_

MachineCanvas* MDFView::canvas_
private

The window where the figures are drawn.

Definition at line 85 of file MDFView.hh.

Referenced by canvas(), clearSelection(), OnClose(), OnCreate(), OnCreatePrintout(), OnDraw(), OnUpdate(), and selection().

◆ frame_

ChildFrame* MDFView::frame_
private

ChildFrame for displaying the view.

Definition at line 87 of file MDFView.hh.

Referenced by OnChangeFilename(), OnClose(), and OnCreate().


The documentation for this class was generated from the following files:
MDFDocument::getModel
Model * getModel()
Definition: MDFDocument.cc:229
MachineCanvas
Definition: MachineCanvas.hh:64
WxConversion::toWxString
static wxString toWxString(const std::string &source)
SelectTool
Definition: SelectTool.hh:47
MachineCanvas::clearSelection
void clearSelection()
Definition: MachineCanvas.cc:395
machine
TTAMachine::Machine * machine
the architecture definition of the estimated processor
Definition: EstimatorCmdLineUI.cc:59
FileSystem::fileOfPath
static std::string fileOfPath(const std::string pathName)
Definition: FileSystem.cc:101
ChildFrame
Definition: ChildFrame.hh:42
MachineCanvas::setTool
void setTool(MachineCanvasTool *tool)
Definition: MachineCanvas.cc:305
assert
#define assert(condition)
Definition: Application.hh:86
MachineCanvas::selection
EditPart * selection()
Definition: MachineCanvas.cc:409
MDFView::OnChangeFilename
virtual void OnChangeFilename()
Definition: MDFView.cc:212
ProDeEditPolicyFactory
Definition: ProDeEditPolicyFactory.hh:42
ProDeConstants::EDITOR_NAME
static const wxString EDITOR_NAME
Full name of the Editor.
Definition: ProDeConstants.hh:386
MDFDocument
Definition: MDFDocument.hh:51
MDFView::frame_
ChildFrame * frame_
ChildFrame for displaying the view.
Definition: MDFView.hh:87
MDFView::canvas_
MachineCanvas * canvas_
The window where the figures are drawn.
Definition: MDFView.hh:85
MachineCanvas::setMachine
void setMachine(TTAMachine::Machine *machine)
Definition: MachineCanvas.cc:386
Model
Definition: Model.hh:50
MDFView::OnUpdate
virtual void OnUpdate(wxView *sender, wxObject *hint)
Definition: MDFView.cc:144
MachineCanvas::OnDraw
virtual void OnDraw(wxDC &dc)
Definition: MachineCanvas.cc:101
WxConversion::toString
static std::string toString(const wxString &source)
ADFPrintout
Definition: ADFPrintout.hh:45
Model::getMachine
TTAMachine::Machine * getMachine()
Definition: Model.cc:88
TTAMachine::Machine
Definition: Machine.hh:73