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 #include <QGridLayout>
26 
28  QWidget(parent),
30  camera(new SoOrthographicCamera)
31 {
32  //setPalette(Qt::transparent);
33  //setAttribute(Qt::WA_TransparentForMouseEvents);
34 
35  this->setContentsMargins(1, 1, 1, 1);
36 
37  QGridLayout* grid = new QGridLayout();
38  grid->setContentsMargins(0, 0, 0, 0);
39  this->setLayout(grid);
40  this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
41 
42  QWidget* view1 = new QWidget(this);
43  view1->setMinimumSize(100, 100);
44  view1->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
45 
46  viewer.reset(new scene3D::MinimapViewer(control, view1));
47  viewer->setSceneGraph(control->getScene()->registerCamera(camera));
48 
49  //View whole scene from top
50  camera->position.setValue(0, 0, 0);
51  camera->pointAt(SbVec3f(0, 0, -1));
52  control->getScene()->makeCameraViewAll(camera, viewer->getViewportRegion());
53 
54  //Apply custom highlighting and make viewer redraw on selection changes
55  viewer->setGLRenderAction(new scene3D::SoGLHighlightRenderAction(viewer->getViewportRegion(), 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(), SIGNAL(operationExecuted(controller::vector_string)), this, SLOT(updateMinimap()));
69 }
70 
71 void gui::MinimapWidget::updateMinimap()
72 {
73  camera->position.setValue(0, 0, 0);
74  camera->pointAt(SbVec3f(0, 0, -1));
75 
77  {
78  controller->getScene()->makeCameraViewAll(camera, viewer->getViewportRegion());
79  }
80 }
MinimapWidget.h
gui::MinimapWidget::MinimapWidget
MinimapWidget(const controller::ControllerPtr control, QWidget *parent=0)
Constructor.
Definition: MinimapWidget.cpp:27
scene3D::SoGLHighlightRenderAction
Definition: SoGLHighlightRenderAction.h:57
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