VPTissue Reference Manual
DiamondTile.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2016 Universiteit Antwerpen
3  *
4  * Licensed under the EUPL, Version 1.1 or as soon they will be approved by
5  * the European Commission - subsequent versions of the EUPL (the "Licence");
6  * You may not use this work except in compliance with the Licence.
7  * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl5
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the Licence is distributed on an "AS IS" basis,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the Licence for the specific language governing
13  * permissions and limitations under the Licence.
14  */
20 #include "DiamondTile.h"
21 
22 #include <cmath>
23 
24 namespace SimPT_Editor {
25 
26 const double DiamondTile::g_diagonal_length = 10.0;
27 const QPolygonF DiamondTile::g_start_polygon(QPolygonF() << QPointF(0, 0) << QPointF(g_diagonal_length / 2, g_diagonal_length / 2) << QPointF(g_diagonal_length, 0) << QPointF(g_diagonal_length / 2, -g_diagonal_length / 2));
28 
29 namespace {
30 
31 QPainterPath PolygonToPath(const QPolygonF &polygon)
32 {
33  QPainterPath path;
34  path.moveTo(polygon.first());
35  path.lineTo(polygon.at(1));
36  path.lineTo(polygon.at(2));
37  return path;
38 }
39 
40 }
41 
43  : DiamondTile(g_start_polygon, nullptr)
44 {
45 }
46 
48 {
49 }
50 
52 {
53  return new DiamondTile(m_polygon.translated(-g_diagonal_length, 0), parentItem());
54 }
55 
57 {
58  return new DiamondTile(m_polygon.translated(g_diagonal_length, 0), parentItem());
59 }
60 
62 {
63  return new DiamondTile(m_polygon.translated(-g_diagonal_length / 2, -g_diagonal_length / 2), parentItem());
64 }
65 
67 {
68  return new DiamondTile(m_polygon.translated(g_diagonal_length / 2, g_diagonal_length / 2), parentItem());
69 }
70 
71 DiamondTile::DiamondTile(const QPolygonF &polygon, QGraphicsItem *parentItem)
72  : Tile(polygon, PolygonToPath(polygon))
73 {
74  setParentItem(parentItem);
75 }
76 
77 } // namespace
A diamond shaped tile.
Definition: DiamondTile.h:31
Namespace for SimPT tissue editor package.
Definition: Cell.h:32
virtual DiamondTile * Up() const
Creates a new tile on the row under this tile (should normally be the opposite of Tile::Down()) Paren...
Definition: DiamondTile.cpp:61
Interface for DiamondTile.
virtual DiamondTile * Down() const
Creates a new tile on the row under this tile (should normally be the opposite of Tile::Up()) Parent ...
Definition: DiamondTile.cpp:66
virtual ~DiamondTile()
Destructor.
Definition: DiamondTile.cpp:47
DiamondTile()
Constructor.
Definition: DiamondTile.cpp:42
virtual DiamondTile * Right() const
Creates a new tile to the right of this tile (should normally be the opposite of Tile::Left()) Parent...
Definition: DiamondTile.cpp:56
virtual DiamondTile * Left() const
Creates a new tile to the left of this tile (should normally be the opposite of Tile::Right()) Parent...
Definition: DiamondTile.cpp:51
Abstract base class for cell pattern tiles.
Definition: Tile.h:29
see the online Qt documentation