MinimapWidget.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package MemoryX::gui-plugins::SceneEditor
19  * @date 2015
20  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21  * GNU General Public License
22  */
23 
24 #include "MinimapWidget.h"
25 
26 #include <QGridLayout>
27 
29  QWidget(parent), control(control), camera(new SoOrthographicCamera)
30 {
31  //setPalette(Qt::transparent);
32  //setAttribute(Qt::WA_TransparentForMouseEvents);
33 
34  this->setContentsMargins(1, 1, 1, 1);
35 
36  QGridLayout* grid = new QGridLayout();
37  grid->setContentsMargins(0, 0, 0, 0);
38  this->setLayout(grid);
39  this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
40 
41  QWidget* view1 = new QWidget(this);
42  view1->setMinimumSize(100, 100);
43  view1->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
44 
45  viewer.reset(new scene3D::MinimapViewer(control, view1));
46  viewer->setSceneGraph(control->getScene()->registerCamera(camera));
47 
48  //View whole scene from top
49  camera->position.setValue(0, 0, 0);
50  camera->pointAt(SbVec3f(0, 0, -1));
51  control->getScene()->makeCameraViewAll(camera, viewer->getViewportRegion());
52 
53  //Apply custom highlighting and make viewer redraw on selection changes
54  viewer->setGLRenderAction(new scene3D::SoGLHighlightRenderAction(viewer->getViewportRegion(),
55  control->getScene().get()));
56  viewer->redrawOnSelectionChange(control->getScene()->selectionRootNode);
57 
58  // show everything
59  // Show the viewer causes, that the gui show a window on loading the plugin. This window does not close.
60  // However everything works if this method is not called.
61  // viewer->show();
62 
63  grid->addWidget(view1, 0, 0, 1, 2);
64 
65  setMinimumWidth(200);
66 
67  connect(control.get(), SIGNAL(reloadScene()), this, SLOT(updateMinimap()));
68  connect(control.get(),
69  SIGNAL(operationExecuted(controller::vector_string)),
70  this,
71  SLOT(updateMinimap()));
72 }
73 
74 void
75 gui::MinimapWidget::updateMinimap()
76 {
77  camera->position.setValue(0, 0, 0);
78  camera->pointAt(SbVec3f(0, 0, -1));
79 
81  {
82  controller->getScene()->makeCameraViewAll(camera, viewer->getViewportRegion());
83  }
84 }
MinimapWidget.h
gui::MinimapWidget::MinimapWidget
MinimapWidget(const controller::ControllerPtr control, QWidget *parent=0)
Constructor.
Definition: MinimapWidget.cpp:28
scene3D::SoGLHighlightRenderAction
Definition: SoGLHighlightRenderAction.h:56
controller::vector_string
std::vector< std::string > vector_string
Definition: Controller.h:47
controller
Definition: AddOperation.h:39
controller::ControllerPtr
std::shared_ptr< Controller > ControllerPtr
Definition: ClassDefinitions.h:41
control
This file is part of ArmarX.
scene3D::MinimapViewer
Definition: MinimapViewer.h:32