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 
24 namespace armarx
25 {
27  {
28  ARMARX_INFO << "RobotTrajectoryDesigner: ViewController on disconnect";
29 
30  // Fill perspectives combo box with items
31  this->initPerspectivesCombobox();
32  numberViews = 1;
33  enableAddRemoveViewButton();
34  }
35 
37  {
38  ARMARX_INFO << "RobotTrajectoryDesigner: ViewController on connect";
39 
40  // Set perspective (index)
41  QObject::connect(guiPerspectives->getPerspectives()->perspectiveComboBox,
42  SIGNAL(activated(int)),
43  this, SLOT(setViewPerspective(int)));
44 
45  QObject::connect(guiPerspectives->getPerspectives()->addViewButton,
46  SIGNAL(clicked()), this, SLOT(addViewSlot()));
47  QObject::connect(guiPerspectives->getPerspectives()->deleteViewButton,
48  SIGNAL(clicked()), this, SLOT(removeViewSlot()));
49  }
50 
52  {
53  ARMARX_INFO << "RobotTrajectoryDesigner: ViewController on disconnect";
54  }
55 
57  {
58  ARMARX_INFO << "RobotTrajectoryDesigner: ViewController on exit";
59  }
60 
62  guiPerspectives(guiPerspectives)
63  {
66  }
67 
69  {
70  return this->guiPerspectives;
71  }
72 
74  {
75  this->guiPerspectives = guiPerspectives;
76  }
77 
79  {
81  }
82 
84  {
85  throw ("not yet implemented");
86  }
87 
88  void ViewController::addViewSlot()
89  {
90  numberViews++;
91  emit addView();
92  enableAddRemoveViewButton();
93  }
94 
95  void ViewController::removeViewSlot()
96  {
97  numberViews--;
98  emit removeView();
99  enableAddRemoveViewButton();
100  }
101 
102  void ViewController::initPerspectivesCombobox()
103  {
104  QComboBox* perspectives = guiPerspectives->getPerspectives()->perspectiveComboBox;
105 
106  // Set focus to strong focus, add wheel event filter
107  perspectives->setFocusPolicy(Qt::StrongFocus);
108  perspectives->installEventFilter(new WheelEventFilter(this));
109 
110  // Clear combo box, fill with items
111  perspectives->clear();
112  perspectives->addItem(QString::fromStdString("High Angle"));
113  perspectives->addItem(QString::fromStdString("Top"));
114  perspectives->addItem(QString::fromStdString("Front"));
115  perspectives->addItem(QString::fromStdString("Back"));
116  perspectives->addItem(QString::fromStdString("Left"));
117  perspectives->addItem(QString::fromStdString("Right"));
118  perspectives->setEnabled(true);
119  perspectives->setCurrentIndex(0);
120  }
121 
122  void ViewController::enableAddRemoveViewButton()
123  {
124  if (numberViews == 1)
125  {
126  guiPerspectives->getPerspectives()->addViewButton->setEnabled(true);
127  guiPerspectives->getPerspectives()->deleteViewButton->setEnabled(false);
128  }
129  else if (numberViews == 4)
130  {
131  guiPerspectives->getPerspectives()->addViewButton->setEnabled(false);
132  guiPerspectives->getPerspectives()->deleteViewButton->setEnabled(true);
133  }
134  else
135  {
136  guiPerspectives->getPerspectives()->addViewButton->setEnabled(true);
137  guiPerspectives->getPerspectives()->deleteViewButton->setEnabled(true);
138  }
139  }
140 }
armarx::ViewController::retranslateGui
void retranslateGui()
Retranslates the guiPerspectives.
Definition: ViewController.cpp:83
ViewController.h
armarx::ViewController::addView
void addView()
Notifies RobotVisualizationController to add a view.
armarx::ViewController::onExitComponent
void onExitComponent() override
Definition: ViewController.cpp:56
armarx::ViewController::ViewController
ViewController(PerspectivesPtr guiPerspectives)
Creates a new ViewController and assigns a Perspectives widget to handle.
Definition: ViewController.cpp:61
index
uint8_t index
Definition: EtherCATFrame.h:59
armarx::ViewController::onInitComponent
void onInitComponent() override
Definition: ViewController.cpp:26
armarx::ViewController::changedPerspective
void changedPerspective(int perspective)
Notifies other controllers about changes of the perspective.
armarx::ViewController::onDisconnectComponent
void onDisconnectComponent() override
Definition: ViewController.cpp:51
armarx::ViewController::setGuiPerspectives
void setGuiPerspectives(PerspectivesPtr guiPerspectives)
Setter for the Perspectives pointer to guiPerspectives.
Definition: ViewController.cpp:73
armarx::ViewController::getGuiPerspectives
PerspectivesPtr getGuiPerspectives()
Getter for the Perspectives pointer to guiPerspectives.
Definition: ViewController.cpp:68
armarx::ViewController::removeView
void removeView()
Notifies RobotVisualizationController to delete a view.
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
armarx::ViewController::setViewPerspective
void setViewPerspective(int index)
Sets the perspective on the displayed robot model.
Definition: ViewController.cpp:78
PerspectivesPtr
std::shared_ptr< Perspectives > PerspectivesPtr
Definition: Perspectives.h:51
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::ViewController::onConnectComponent
void onConnectComponent() override
Definition: ViewController.cpp:36