26 #include "../controller/DeselectOperation.h"
27 #include "../controller/SelectOperation.h"
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);
52 scene3D::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())
102 ->getSelectionManager()
106 std::shared_ptr<std::vector<controller::OperationPtr>> operations(
107 new std::vector<controller::OperationPtr>());
111 ->getSelectionManager()
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())
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()))
177 obj.reset((SceneObject*)n);
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>());
200 ->getSelectionManager()
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);