VPTissue Reference Manual
TissueGraphicsView.h
Go to the documentation of this file.
1 #ifndef SIMPT_EDITOR_TISSUE_GRAPHICS_VIEW_H_INCLUDED
2 #define SIMPT_EDITOR_TISSUE_GRAPHICS_VIEW_H_INCLUDED
3 /*
4  * Copyright 2011-2016 Universiteit Antwerpen
5  *
6  * Licensed under the EUPL, Version 1.1 or as soon they will be approved by
7  * the European Commission - subsequent versions of the EUPL (the "Licence");
8  * You may not use this work except in compliance with the Licence.
9  * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl5
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the Licence is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the Licence for the specific language governing
15  * permissions and limitations under the Licence.
16  */
22 #include "EditableCellItem.h"
23 #include "EditableEdgeItem.h"
24 #include "EditableNodeItem.h"
25 
27 #include "gui/PanAndZoomView.h"
28 
29 #include "model/ComponentTraits.h"
31 
32 #include <boost/property_tree/ptree.hpp>
33 #include <QGraphicsScene>
34 #include <list>
35 #include <memory>
36 #include <string>
37 
38 class QGraphicsPixmapItem;
39 class QWidget;
40 
41 namespace SimPT_Editor {
42 
43 class BackgroundDialog;
44 class EditableCellItem;
45 class EditableEdgeItem;
46 class EditableNodeItem;
47 class EditControlLogic;
48 class SelectByIDWidget;
49 class TissueSlicer;
50 
51 using namespace SimShell;
52 using namespace SimShell::Gui;
53 
57 enum struct Mode {
58  DISPLAY, //mode to display properties of the entities (immutable entities)
59  NODE, //mode to edit nodes
60  NODE_COPY, //submode to copy node attributes
61  EDGE, //mode to edit edges
62  EDGE_COPY, //submode to copy edge attributes
63  CELL, //mode to edit cells
64  CELL_COPY, //submode to copy cell attributes
65  CELL_CREATE, //submode to create a cell
66  CELL_SLICE, //submode to slice a cell
67  NONE
68 };
69 
74 {
75  Q_OBJECT
76 public:
82  TissueGraphicsView(QWidget* parent);
83 
87  virtual ~TissueGraphicsView();
88 
95  void Initialize(std::shared_ptr<EditControlLogic> tissue, Mode mode = Mode::DISPLAY);
96 
102  bool SelectedIsAtBoundary() const;
103 
110  bool SelectedIsDeletable() const;
111 
118  bool SelectedIsSplitable() const;
119 
128  EditableCellItem* AddCell(std::list<EditableNodeItem*> endpoints, std::list<EditableEdgeItem*> edges, SimPT_Sim::Cell* cell);
129 
137  EditableEdgeItem* AddEdge(EditableNodeItem* endpoint1, EditableNodeItem* endpoint2);
138 
144  EditableNodeItem* AddNode(SimPT_Sim::Node* node);
145 
149  Mode GetMode() const;
150 
154  SelectByIDWidget* GetSelectByIDWidget() const;
155 
160  void SetMode(Mode mode);
161 
165  void GenerateRegularPattern();
166 
170  void GenerateVoronoiPattern();
171 
177  void SetColorComponent(const boost::property_tree::ptree& parameters);
178 
183  void Cleanup();
184 
185 public slots:
189  void CancelAction();
190 
195  void CopyAttributes();
196 
200  void CreateCell();
201 
205  void DeleteItem();
206 
210  void SplitEdge();
211 
215  void SplitCell();
216 
220  void UpdateMovedNode();
221 
225  void SetBackground();
226 
231  void SetDisplayModePreferences();
232 
238  void SetTransparentCells(bool transparent);
239 
240 signals:
244  void ModeChanged();
245 
251  void ItemsSelected(unsigned int count);
252 
259  void StatusInfoChanged(const std::string& info);
260 
261 private slots:
265  void UpdateSelection();
266 
270  void FinishSliceAction();
271 
280  void SelectItems(const std::list<unsigned int>& ids, bool keepItemsSelected = false);
281 
282 private:
288  void DeleteNode(EditableNodeItem* node);
289 
295  void DeleteCell(EditableCellItem* cell);
296 
302  void EnsureVisible(const std::vector<QGraphicsItem*>& items);
303 
309  EditableNodeItem* GetEditableNode(SimPT_Sim::Node* node) const;
310 
316  void SetEditableItemFlags(bool enable = true);
317 
321  bool IsConsistent() const;
322 
326  virtual void mouseMoveEvent(QMouseEvent* event);
327 
331  virtual void mousePressEvent(QMouseEvent* event);
332 
336  virtual void mouseReleaseEvent(QMouseEvent* event);
337 
341  virtual void mouseDoubleClickEvent(QMouseEvent* event);
342 
343 private:
344  std::shared_ptr<EditControlLogic> m_tissue;
345  std::list<EditableCellItem*> m_cells;
346  std::list<EditableEdgeItem*> m_edges;
347  std::list<EditableNodeItem*> m_nodes;
348  QGraphicsPixmapItem* m_background_item;
349  QGraphicsScene m_scene;
350  Mode m_mode;
351 
352 private:
353  bool m_cells_transparent;
354 
355 private:
356  std::shared_ptr<SimPT_Sim::ComponentFactoryProxy> m_factory;
357  boost::property_tree::ptree m_ptree;
358  QString m_colorizer_pref;
359 
360 private:
361  TissueSlicer* m_tissue_slicer;
362  BackgroundDialog* m_background_dialog;
363  SelectByIDWidget* m_select_by_id;
364 
365 private:
366  static constexpr double g_node_radius = 1;
367 };
368 
369 } // namespace
370 
371 #endif // end_of_include_guard
Dialog for setting the background image.
QGraphicsView with the ability to pan and zoom.
A cell contains walls and nodes.
Definition: Cell.h:48
Namespace for SimPT tissue editor package.
Definition: Cell.h:32
Node in cell wall.
Definition: Node.h:39
The graphical view on the tissue.
Mode
Different modes for the graphicsview.
Namespace for graphical interface classes.
Functionality and visual representation of slicing a cell complex.
Definition: TissueSlicer.h:34
Class for selecting an item by ID.
Editable graphical representation for Edge.
Interface for PanAndZoomView.
Editable graphical representation for Node.
Proxy for dealing with the factories.
Interface for EditableNodeItem.
Editable graphical representation for Cell.
Interface for BitmapGraphicsExporter.
see the online Qt documentation
Model component .
Namespace for generic graphical shell for simulators.
Definition: SimSession.h:32
Interface for EditableEdgeItem.
Interface for EditableCellItem.