VPTissue Reference Manual
EditControlLogic.h
Go to the documentation of this file.
1 #ifndef SIMPT_EDITOR_EDIT_CONTROL_LOGIC_H_INCLUDED
2 #define SIMPT_EDITOR_EDIT_CONTROL_LOGIC_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 "EditableMesh.h"
23 
24 #include "bio/Cell.h"
25 #include "bio/Edge.h"
26 #include "bio/Mesh.h"
27 #include "bio/Node.h"
28 #include "bio/Wall.h"
29 
30 #include <QObject>
31 #include <boost/property_tree/ptree_fwd.hpp>
32 #include <list>
33 #include <memory>
34 #include <string>
35 #include <vector>
36 
37 class QPointF;
38 class QPolygonF;
39 
40 namespace SimPT_Editor {
41 
42 using namespace SimPT_Sim;
43 
47 class EditControlLogic : public QObject
48 {
49  Q_OBJECT
50 public:
55  EditControlLogic(unsigned int chemical_count);
56 
62  EditControlLogic(const boost::property_tree::ptree& pt);
63 
67  virtual ~EditControlLogic();
68 
73  void ChangeAttributes(const boost::property_tree::ptree& pt);
74 
76  void CopyAttributes(const boost::property_tree::ptree& pt);
77 
79  Cell* CreateCell(Node* node1, Node* node2, const QPointF& newPoint);
80 
87  bool DeleteCell(Cell* cell);
88 
94  void DeleteCells(const std::list<Cell*>& cells);
95 
102  bool DeleteNode(Node* node);
103 
105  void Deselect();
106 
108  const std::vector<Cell*>& GetCells() const {return m_mesh->GetMesh()->GetCells();}
109 
111  EditableMesh* GetMesh() {return m_mesh;}
112 
113  // Get parameters ptree.
114  const boost::property_tree::ptree& GetParameters() const;
115 
117  const std::vector<Node*>& GetNodes() const {return m_mesh->GetMesh()->GetNodes();}
118 
120  const std::vector<Wall*>& GetWalls() const {return m_mesh->GetMesh()->GetWalls();}
121 
123  bool MoveNode(Node* node, double x, double y);
124 
126  const boost::property_tree::ptree& ToPTree();
127 
129  void ReplaceCell(Cell* cell, std::list<QPolygonF> newCells);
130 
132  const std::list<Cell*>& SelectedCells() const {return m_selected_cells;}
133 
135  const std::list<Node*>& SelectedNodes() const {return m_selected_nodes;}
136 
138  const std::list<Wall*>& SelectedWalls() const {return m_selected_walls;}
139 
141  void SelectCells(const std::list<Cell*>& cells);
142 
144  void SelectEdges(const std::list<Edge>& edges);
145 
147  void SelectNodes(const std::list<Node*>& nodes);
148 
150  void SetParameters(const boost::property_tree::ptree&);
151 
153  void StopMoveNode();
154 
156  std::vector<Cell*> SplitCell(Cell* cell,
157  Node* node1, Node* node2, bool modified = false);
158 
160  std::vector<Cell*> SplitCell(Node* node1, Node* node2);
161 
167  Node* SplitEdge(const Edge& edge);
168 
169 signals:
171  void Modified();
172 
179  void Moved(Node* node, double x, double y);
180 
182  void SelectionChanged();
183 
189  void StatusInfoChanged(const std::string& info);
190 
192  void StoppedMoving();
193 
194 private:
196  Mesh BuildTwoSquaresMesh(unsigned int chemical_count);
197 
207  static boost::property_tree::ptree UpdatePTree(boost::property_tree::ptree pt1, boost::property_tree::ptree pt2);
208 
209 private:
210  EditableMesh* m_mesh;
211  bool m_moving_node;
212  boost::property_tree::ptree m_ptree;
213  bool m_ptree_dirty;
214  std::list<Cell*> m_selected_cells;
215  std::list<Node*> m_selected_nodes;
216  std::list<Wall*> m_selected_walls;
217 
218 };
219 
220 } // namespace
221 
222 #endif // end_of_include_guard
const std::list< Cell * > & SelectedCells() const
Get the selected cells.
const std::list< Node * > & SelectedNodes() const
Get the selected nodes.
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
Class for the composition of a tissue, containing its properties.
const std::list< Wall * > & SelectedWalls() const
Get the selected walls.
Interface for EditableMesh.
EditableMesh * GetMesh()
Get the mesh.
Namespace for the core simulator.
An Edge connects two nodes and is ambidextrous.
Definition: Edge.h:31
Interface for Cell.
const std::vector< Node * > & GetNodes() const
Get all nodes.
Interface for Node.
Interface for Edge.
const std::vector< Cell * > & GetCells() const
Get all cells.
Structure of cells; key data structure.
Definition: Mesh.h:62
see the online Qt documentation
An editable mesh with actions to alter the construction of the mesh.
Definition: EditableMesh.h:35
const std::vector< Wall * > & GetWalls() const
Get all walls.
Interface for Wall.
Interface for Mesh.