28#include <Inventor/SoPickedPoint.h>
29#include <Inventor/actions/SoRayPickAction.h>
30#include <Inventor/events/SoLocation2Event.h>
31#include <Inventor/events/SoMouseButtonEvent.h>
36 this->setBackgroundColor(SbColor(100 / 255.0f, 100 / 255.0f, 100 / 255.0f));
37 this->setAccumulationBuffer(
false);
38 this->setHeadlight(
true);
39 this->setViewing(
false);
40 this->setDecoration(
false);
43 this->setAntialiasing(
true, 4);
46 this->setTransparencyType(SoGLRenderAction::SORTED_OBJECT_BLEND);
47 this->setFeedbackVisibility(
true);
52scene3D::SceneViewer::processSoEvent(
const SoEvent*
const event)
54 const SoType type(event->getTypeId());
57 if (type.isDerivedFrom(SoMouseButtonEvent::getClassTypeId()))
59 SoMouseButtonEvent*
const ev = (SoMouseButtonEvent*)event;
60 const int button = ev->getButton();
61 const SbBool press = ev->getState() == SoButtonEvent::DOWN ? TRUE : FALSE;
64 if (button == SoMouseButtonEvent::BUTTON1)
68 if (!
controller->getScene()->getSelectionManager()->getCreateOperations())
71 return SoQtRenderArea::processSoEvent(ev);
84 SoRayPickAction rp(this->getViewportRegion());
86 rp.setPoint(event->getPosition());
87 rp.apply(this->getSceneGraph());
88 SoPickedPoint* picked = rp.getPickedPoint();
97 if (!ev->wasShiftDown())
101 if (controller->getScene()
102 ->getSelectionManager()
106 std::shared_ptr<std::vector<controller::OperationPtr>> operations(
107 new std::vector<controller::OperationPtr>());
111 ->getSelectionManager()
115 new controller::DeselectOperation(
116 controller->getMemoryXController(),
117 controller->getScene(),
118 object->getObjectId()));
119 operations->push_back(deselect);
139 SoFullPath* p = (SoFullPath*)picked->getPath();
141 for (
int i = 0; i < p->getLength(); i++)
143 SoNode*
n = p->getNode(i);
145 if (
n->isOfType(SoTransformManip::getClassTypeId()))
148 return SoQtRenderArea::processSoEvent(ev);
155 if (!ev->wasShiftDown())
163 if (controller->getScene()
164 ->getSelectionManager()
171 for (
int i = 0; i < picked->getPath()->getLength(); i++)
173 SoNode*
n = picked->getPath()->getNode(i);
175 if (
n->isOfType(SceneObject::getClassTypeId()))
182 if (controller->getScene()
183 ->getSelectionManager()
186 controller->getScene()->getSelectionManager()->isSelected(obj))
189 return SoQtRenderArea::processSoEvent(ev);
194 std::shared_ptr<std::vector<controller::OperationPtr>>
195 operations(
new std::vector<controller::OperationPtr>());
199 controller->getScene()
200 ->getSelectionManager()
204 new controller::DeselectOperation(
205 controller->getMemoryXController(),
206 controller->getScene(),
207 object->getObjectId()));
208 operations->push_back(deselect);
218 return SoQtRenderArea::processSoEvent(ev);
224 return SoQtRenderArea::processSoEvent(ev);
234 return SoQtRenderArea::processSoEvent(ev);
240 return SoQtRenderArea::processSoEvent(ev);
245 if (button == SoMouseButtonEvent::BUTTON2)
252 if (button == SoMouseButtonEvent::BUTTON3)
261 if (!this->isViewing())
263 this->setViewing(
true);
268 if (this->isViewing())
270 this->setViewing(
false);
275 ev->setButton(SoMouseButtonEvent::BUTTON1);
281 if (this->isViewing())
283 return SoQtExaminerViewer::processSoEvent(ev);
288 if (button == SoMouseButtonEvent::BUTTON4 || button == SoMouseButtonEvent::BUTTON5)
294 ev->setButton(button == SoMouseButtonEvent::BUTTON4 ? SoMouseButtonEvent::BUTTON5
295 : SoMouseButtonEvent::BUTTON4);
299 if (!this->isViewing())
301 if (!this->isViewing())
303 this->setViewing(
true);
306 SoQtExaminerViewer::processSoEvent(ev);
308 if (this->isViewing())
310 this->setViewing(
false);
315 SoQtExaminerViewer::processSoEvent(ev);
323 if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId()))
325 const SoKeyboardEvent*
const ev = (
const SoKeyboardEvent*)event;
331 if (ev->getKey() == SoKeyboardEvent::ESCAPE || ev->getKey() == 65513)
335 else if (ev->getKey() == SoKeyboardEvent::S && ev->getState() == SoButtonEvent::DOWN)
337 if (!this->isSeekMode())
339 if (!this->isViewing())
341 this->setViewing(
true);
344 SoQtExaminerViewer::processSoEvent(ev);
345 this->setSeekTime(0.5);
346 this->seekToPoint(ev->getPosition());
348 if (this->isViewing())
350 this->setViewing(
false);
356 SoQtExaminerViewer::processSoEvent(ev);
359 SoQtExaminerViewer::processSoEvent(ev);
363 if (type.isDerivedFrom(SoLocation2Event::getClassTypeId()))
365 return SoQtExaminerViewer::processSoEvent(event);
static const int UNDOABLE
A flag to save the executed operations to the history.
static const int EXECUTE_ON_WM
A Flag to execute operations on the WorkingMemory.
static const int EXECUTE_ON_SCENE
A flag to execute operations on the Scene.
SceneViewer(const controller::ControllerPtr &control, QWidget *widget)
Constructor Creates an Instance of the Class.
This file is part of ArmarX.
std::shared_ptr< Controller > ControllerPtr
std::shared_ptr< Operation > OperationPtr
constexpr auto n() noexcept
boost::intrusive_ptr< SceneObject > SceneObjectPtr