25 #include <Inventor/events/SoMouseButtonEvent.h>
26 #include <Inventor/events/SoLocation2Event.h>
27 #include <Inventor/actions/SoRayPickAction.h>
28 #include <Inventor/SoPickedPoint.h>
30 #include "../controller/DeselectOperation.h"
31 #include "../controller/SelectOperation.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);
51 SbBool scene3D::SceneViewer::processSoEvent(
const SoEvent*
const event)
53 const SoType type(event->getTypeId());
56 if (type.isDerivedFrom(SoMouseButtonEvent::getClassTypeId()))
58 SoMouseButtonEvent*
const ev = (SoMouseButtonEvent*) event;
59 const int button = ev->getButton();
60 const SbBool press = ev->getState() == SoButtonEvent::DOWN ? TRUE : FALSE;
63 if (button == SoMouseButtonEvent::BUTTON1)
67 if (!
controller->getScene()->getSelectionManager()->getCreateOperations())
70 return SoQtRenderArea::processSoEvent(ev);
83 SoRayPickAction rp(this->getViewportRegion());
85 rp.setPoint(event->getPosition());
86 rp.apply(this->getSceneGraph());
87 SoPickedPoint* picked = rp.getPickedPoint();
96 if (!ev->wasShiftDown())
100 if (
controller->getScene()->getSelectionManager()->getAllSelected().size() != 0)
102 std::shared_ptr<std::vector<controller::OperationPtr>> operations(
new std::vector<controller::OperationPtr>());
108 operations->push_back(deselect);
125 SoFullPath* p = (SoFullPath*) picked->getPath();
127 for (
int i = 0; i < p->getLength(); i++)
129 SoNode* n = p->getNode(i);
131 if (n->isOfType(SoTransformManip::getClassTypeId()))
134 return SoQtRenderArea::processSoEvent(ev);
141 if (!ev->wasShiftDown())
149 if (
controller->getScene()->getSelectionManager()->getAllSelected().size() > 0)
154 for (
int i = 0; i < picked->getPath()->getLength(); i++)
156 SoNode* n = picked->getPath()->getNode(i);
158 if (n->isOfType(SceneObject::getClassTypeId()))
160 obj.reset((SceneObject*) n);
165 if (
controller->getScene()->getSelectionManager()->getAllSelected().size() == 1
166 &&
controller->getScene()->getSelectionManager()->isSelected(obj))
169 return SoQtRenderArea::processSoEvent(ev);
174 std::shared_ptr<std::vector<controller::OperationPtr>> operations(
new std::vector<controller::OperationPtr>());
180 operations->push_back(deselect);
186 return SoQtRenderArea::processSoEvent(ev);
192 return SoQtRenderArea::processSoEvent(ev);
202 return SoQtRenderArea::processSoEvent(ev);
208 return SoQtRenderArea::processSoEvent(ev);
213 if (button == SoMouseButtonEvent::BUTTON2)
220 if (button == SoMouseButtonEvent::BUTTON3)
229 if (!this->isViewing())
231 this->setViewing(
true);
236 if (this->isViewing())
238 this->setViewing(
false);
243 ev->setButton(SoMouseButtonEvent::BUTTON1);
249 if (this->isViewing())
251 return SoQtExaminerViewer::processSoEvent(ev);
256 if (button == SoMouseButtonEvent::BUTTON4 || button == SoMouseButtonEvent::BUTTON5)
262 ev->setButton(button == SoMouseButtonEvent::BUTTON4 ?
263 SoMouseButtonEvent::BUTTON5 : SoMouseButtonEvent::BUTTON4);
267 if (!this->isViewing())
269 if (!this->isViewing())
271 this->setViewing(
true);
274 SoQtExaminerViewer::processSoEvent(ev);
276 if (this->isViewing())
278 this->setViewing(
false);
283 SoQtExaminerViewer::processSoEvent(ev);
291 if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId()))
293 const SoKeyboardEvent*
const ev = (
const SoKeyboardEvent*) event;
299 if (ev->getKey() == SoKeyboardEvent::ESCAPE || ev->getKey() == 65513)
303 else if (ev->getKey() == SoKeyboardEvent::S && ev->getState() == SoButtonEvent::DOWN)
305 if (!this->isSeekMode())
307 if (!this->isViewing())
309 this->setViewing(
true);
312 SoQtExaminerViewer::processSoEvent(ev);
313 this->setSeekTime(0.5);
314 this->seekToPoint(ev->getPosition());
316 if (this->isViewing())
318 this->setViewing(
false);
324 SoQtExaminerViewer::processSoEvent(ev);
327 SoQtExaminerViewer::processSoEvent(ev);
331 if (type.isDerivedFrom(SoLocation2Event::getClassTypeId()))
333 return SoQtExaminerViewer::processSoEvent(event);