ViewController.cpp
Go to the documentation of this file.
1/*
2* This file is part of ArmarX.
3*
4* ArmarX is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License version 2 as
6* published by the Free Software Foundation.
7*
8* ArmarX is distributed in the hope that it will be useful, but
9* WITHOUT ANY WARRANTY; without even the implied warranty of
10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11* GNU General Public License for more details.
12*
13* You should have received a copy of the GNU General Public License
14* along with this program. If not, see <http://www.gnu.org/licenses/>.
15*
16* \package RobotTrajectoryDesigner::gui-plugins::Controller::ViewController
17* \author Max Beddies
18* \date 2018
19* \copyright http://www.gnu.org/licenses/gpl-2.0.txt
20* GNU General Public License
21*/
22#include "ViewController.h"
23
24namespace armarx
25{
26 void
28 {
29 ARMARX_INFO << "RobotTrajectoryDesigner: ViewController on disconnect";
30
31 // Fill perspectives combo box with items
32 this->initPerspectivesCombobox();
33 numberViews = 1;
34 enableAddRemoveViewButton();
35 }
36
37 void
39 {
40 ARMARX_INFO << "RobotTrajectoryDesigner: ViewController on connect";
41
42 // Set perspective (index)
43 QObject::connect(guiPerspectives->getPerspectives()->perspectiveComboBox,
44 SIGNAL(activated(int)),
45 this,
46 SLOT(setViewPerspective(int)));
47
48 QObject::connect(guiPerspectives->getPerspectives()->addViewButton,
49 SIGNAL(clicked()),
50 this,
51 SLOT(addViewSlot()));
52 QObject::connect(guiPerspectives->getPerspectives()->deleteViewButton,
53 SIGNAL(clicked()),
54 this,
55 SLOT(removeViewSlot()));
56 }
57
58 void
60 {
61 ARMARX_INFO << "RobotTrajectoryDesigner: ViewController on disconnect";
62 }
63
64 void
66 {
67 ARMARX_INFO << "RobotTrajectoryDesigner: ViewController on exit";
68 }
69
71 guiPerspectives(guiPerspectives)
72 {
75 }
76
79 {
80 return this->guiPerspectives;
81 }
82
83 void
85 {
86 this->guiPerspectives = guiPerspectives;
87 }
88
89 void
94
95 void
97 {
98 throw("not yet implemented");
99 }
100
101 void
102 ViewController::addViewSlot()
103 {
104 numberViews++;
105 emit addView();
106 enableAddRemoveViewButton();
107 }
108
109 void
110 ViewController::removeViewSlot()
111 {
112 numberViews--;
113 emit removeView();
114 enableAddRemoveViewButton();
115 }
116
117 void
118 ViewController::initPerspectivesCombobox()
119 {
120 QComboBox* perspectives = guiPerspectives->getPerspectives()->perspectiveComboBox;
121
122 // Set focus to strong focus, add wheel event filter
123 perspectives->setFocusPolicy(Qt::StrongFocus);
124 perspectives->installEventFilter(new WheelEventFilter(this));
125
126 // Clear combo box, fill with items
127 perspectives->clear();
128 perspectives->addItem(QString::fromStdString("High Angle"));
129 perspectives->addItem(QString::fromStdString("Top"));
130 perspectives->addItem(QString::fromStdString("Front"));
131 perspectives->addItem(QString::fromStdString("Back"));
132 perspectives->addItem(QString::fromStdString("Left"));
133 perspectives->addItem(QString::fromStdString("Right"));
134 perspectives->setEnabled(true);
135 perspectives->setCurrentIndex(0);
136 }
137
138 void
139 ViewController::enableAddRemoveViewButton()
140 {
141 if (numberViews == 1)
142 {
143 guiPerspectives->getPerspectives()->addViewButton->setEnabled(true);
144 guiPerspectives->getPerspectives()->deleteViewButton->setEnabled(false);
145 }
146 else if (numberViews == 4)
147 {
148 guiPerspectives->getPerspectives()->addViewButton->setEnabled(false);
149 guiPerspectives->getPerspectives()->deleteViewButton->setEnabled(true);
150 }
151 else
152 {
153 guiPerspectives->getPerspectives()->addViewButton->setEnabled(true);
154 guiPerspectives->getPerspectives()->deleteViewButton->setEnabled(true);
155 }
156 }
157} // namespace armarx
uint8_t index
std::shared_ptr< Perspectives > PerspectivesPtr
void setViewPerspective(int index)
Sets the perspective on the displayed robot model.
void onInitComponent() override
void retranslateGui()
Retranslates the guiPerspectives.
void removeView()
Notifies RobotVisualizationController to delete a view.
void setGuiPerspectives(PerspectivesPtr guiPerspectives)
Setter for the Perspectives pointer to guiPerspectives.
void changedPerspective(int perspective)
Notifies other controllers about changes of the perspective.
void onDisconnectComponent() override
ViewController(PerspectivesPtr guiPerspectives)
Creates a new ViewController and assigns a Perspectives widget to handle.
void onConnectComponent() override
void onExitComponent() override
void addView()
Notifies RobotVisualizationController to add a view.
PerspectivesPtr getGuiPerspectives()
Getter for the Perspectives pointer to guiPerspectives.
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:181
This file offers overloads of toIce() and fromIce() functions for STL container types.