VPTissue Reference Manual
HexagonalTile.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 "HexagonalTile.h"
21 
22 #include <cmath>
23 
24 namespace SimPT_Editor {
25 
26 const double HexagonalTile::g_side_length = 5.0;
27 const double HexagonalTile::g_half_height = std::sqrt(3.0) * g_side_length / 2;
28 const QPolygonF HexagonalTile::g_start_polygon(QPolygonF() << QPointF(0, 0) << QPointF(g_side_length / 2, g_half_height) << QPointF(3 * g_side_length / 2, g_half_height) << QPointF(2 * g_side_length, 0) << QPointF(3 * g_side_length / 2, -g_half_height) << QPointF(g_side_length / 2, -g_half_height));
29 
30 namespace {
31 
32 QPainterPath PolygonToPath(const QPolygonF &polygon)
33 {
34  QPainterPath path;
35  path.moveTo(polygon.first());
36  path.lineTo(polygon.at(1));
37  path.lineTo(polygon.at(2));
38  path.lineTo(polygon.at(3));
39  return path;
40 }
41 
42 }
43 
45  : HexagonalTile(g_start_polygon, nullptr)
46 {
47 }
48 
50 {
51 }
52 
54 {
55  return new HexagonalTile(m_polygon.translated(-3 * g_side_length, 0), parentItem());
56 }
57 
59 {
60  return new HexagonalTile(m_polygon.translated(3 * g_side_length, 0), parentItem());
61 }
62 
64 {
65  return new HexagonalTile(m_polygon.translated(-3 * g_side_length / 2, -g_half_height), parentItem());
66 }
67 
69 {
70  return new HexagonalTile(m_polygon.translated(3 * g_side_length / 2, g_half_height), parentItem());
71 }
72 
73 HexagonalTile::HexagonalTile(const QPolygonF &polygon, QGraphicsItem *parentItem)
74  : Tile(polygon, PolygonToPath(polygon))
75 {
76  setParentItem(parentItem);
77 }
78 
79 } // namespace
Namespace for SimPT tissue editor package.
Definition: Cell.h:32
virtual HexagonalTile * Left() const
Creates a new tile to the left of this tile (should normally be the opposite of Tile::Right()) Parent...
virtual ~HexagonalTile()
Destructor.
Interface for HexagonalTile.
A hexagonal tile.
Definition: HexagonalTile.h:31
virtual HexagonalTile * Right() const
Creates a new tile to the right of this tile (should normally be the opposite of Tile::Left()) Parent...
virtual HexagonalTile * Up() const
Creates a new tile on the row under this tile (should normally be the opposite of Tile::Down()) Paren...
Abstract base class for cell pattern tiles.
Definition: Tile.h:29
virtual HexagonalTile * Down() const
Creates a new tile on the row under this tile (should normally be the opposite of Tile::Up()) Parent ...
see the online Qt documentation