@@ -80,12 +80,20 @@ Viewer::Viewer(QWidget* parent, Qt::WindowFlags f) :
8080 linesMaterial(new SoVRMLMaterial()),
8181 linesShape(new SoVRMLShape()),
8282 path(new SoVRMLSwitch()),
83- pathAppearance(new SoVRMLAppearance()),
84- pathCoordinate(new SoVRMLCoordinate()),
85- pathDrawStyle(new SoDrawStyle()),
86- pathIndexedLineSet(new SoVRMLIndexedLineSet()),
87- pathMaterial(new SoVRMLMaterial()),
88- pathShape(new SoVRMLShape()),
83+ pathEdges(new SoVRMLSwitch()),
84+ pathEdgesAppearance(new SoVRMLAppearance()),
85+ pathEdgesCoordinate(new SoVRMLCoordinate()),
86+ pathEdgesDrawStyle(new SoDrawStyle()),
87+ pathEdgesIndexedLineSet(new SoVRMLIndexedLineSet()),
88+ pathEdgesMaterial(new SoVRMLMaterial()),
89+ pathEdgesShape(new SoVRMLShape()),
90+ pathVertices(new SoVRMLSwitch()),
91+ pathVerticesAppearance(new SoVRMLAppearance()),
92+ pathVerticesCoordinate(new SoVRMLCoordinate()),
93+ pathVerticesDrawStyle(new SoDrawStyle()),
94+ pathVerticesPointSet(new SoVRMLPointSet()),
95+ pathVerticesMaterial(new SoVRMLMaterial()),
96+ pathVerticesShape(new SoVRMLShape()),
8997 path3(new SoVRMLSwitch()),
9098 path3Appearance(new SoVRMLAppearance()),
9199 path3Coordinate(new SoVRMLCoordinate()),
@@ -270,20 +278,47 @@ Viewer::Viewer(QWidget* parent, Qt::WindowFlags f) :
270278 this ->path ->setName (" path" );
271279 this ->path ->whichChoice = SO_SWITCH_ALL;
272280
273- this ->pathDrawStyle ->lineWidth = 3 .0f ;
274- this ->pathDrawStyle ->pointSize = 0 .0f ;
275- this ->path ->addChild (this ->pathDrawStyle );
281+ this ->root ->addChild (this ->path );
276282
277- this ->pathMaterial ->diffuseColor .setValue (55 .0f / 255 .0f , 176 .0f / 255 .0f , 55 .0f / 255 .0f );
278- this ->pathAppearance ->material = this ->pathMaterial ;
279- this ->pathShape ->appearance = this ->pathAppearance ;
283+ // path edges
280284
281- this ->pathIndexedLineSet -> coord = this -> pathCoordinate ;
282- this ->pathShape -> geometry = this -> pathIndexedLineSet ;
285+ this ->pathEdges -> setName ( " pathEdges " ) ;
286+ this ->pathEdges -> whichChoice = SO_SWITCH_ALL ;
283287
284- this ->path ->addChild (this ->pathShape );
288+ this ->pathEdgesDrawStyle ->lineWidth = 3 .0f ;
289+ this ->pathEdgesDrawStyle ->pointSize = 0 .0f ;
290+ this ->pathEdges ->addChild (this ->pathEdgesDrawStyle );
285291
286- this ->root ->addChild (this ->path );
292+ this ->pathEdgesMaterial ->diffuseColor .setValue (55 .0f / 255 .0f , 176 .0f / 255 .0f , 55 .0f / 255 .0f );
293+ this ->pathEdgesAppearance ->material = this ->pathEdgesMaterial ;
294+ this ->pathEdgesShape ->appearance = this ->pathEdgesAppearance ;
295+
296+ this ->pathEdgesIndexedLineSet ->coord = this ->pathEdgesCoordinate ;
297+ this ->pathEdgesShape ->geometry = this ->pathEdgesIndexedLineSet ;
298+
299+ this ->pathEdges ->addChild (this ->pathEdgesShape );
300+
301+ this ->path ->addChild (this ->pathEdges );
302+
303+ // path vertices
304+
305+ this ->pathVertices ->setName (" pathVertices" );
306+ this ->pathVertices ->whichChoice = SO_SWITCH_NONE;
307+
308+ this ->pathVerticesDrawStyle ->lineWidth = 0 .0f ;
309+ this ->pathVerticesDrawStyle ->pointSize = 8 .0f ;
310+ this ->pathVertices ->addChild (this ->pathVerticesDrawStyle );
311+
312+ this ->pathVerticesMaterial ->emissiveColor .setValue (55 .0f / 255 .0f , 176 .0f / 255 .0f , 55 .0f / 255 .0f );
313+ this ->pathVerticesAppearance ->material = this ->pathVerticesMaterial ;
314+ this ->pathVerticesShape ->appearance = this ->pathVerticesAppearance ;
315+
316+ this ->pathVerticesPointSet ->coord = this ->pathVerticesCoordinate ;
317+ this ->pathVerticesShape ->geometry = this ->pathVerticesPointSet ;
318+
319+ this ->pathVertices ->addChild (this ->pathVerticesShape );
320+
321+ this ->path ->addChild (this ->pathVertices );
287322
288323 // path3
289324
@@ -505,8 +540,10 @@ Viewer::drawConfigurationPath(const rl::plan::VectorList& path)
505540{
506541 this ->path ->enableNotify (false );
507542
508- this ->pathCoordinate ->point .setNum (0 );
509- this ->pathIndexedLineSet ->coordIndex .setNum (0 );
543+ this ->pathEdgesCoordinate ->point .setNum (0 );
544+ this ->pathEdgesIndexedLineSet ->coordIndex .setNum (0 );
545+
546+ this ->pathVerticesCoordinate ->point .setNum (0 );
510547
511548 rl::math::Vector inter (this ->model ->getDofPosition ());
512549
@@ -520,16 +557,23 @@ Viewer::drawConfigurationPath(const rl::plan::VectorList& path)
520557 this ->model ->setPosition (*i);
521558 this ->model ->updateFrames ();
522559
523- this ->pathCoordinate ->point .set1Value (
524- this ->pathCoordinate ->point .getNum (),
560+ this ->pathEdgesCoordinate ->point .set1Value (
561+ this ->pathEdgesCoordinate ->point .getNum (),
525562 this ->model ->forwardPosition (l)(0 , 3 ),
526563 this ->model ->forwardPosition (l)(1 , 3 ),
527564 this ->model ->forwardPosition (l)(2 , 3 )
528565 );
529566
530- this ->pathIndexedLineSet ->coordIndex .set1Value (
531- this ->pathIndexedLineSet ->coordIndex .getNum (),
532- this ->pathCoordinate ->point .getNum () - 1
567+ this ->pathEdgesIndexedLineSet ->coordIndex .set1Value (
568+ this ->pathEdgesIndexedLineSet ->coordIndex .getNum (),
569+ this ->pathEdgesCoordinate ->point .getNum () - 1
570+ );
571+
572+ this ->pathVerticesCoordinate ->point .set1Value (
573+ this ->pathVerticesCoordinate ->point .getNum (),
574+ this ->model ->forwardPosition (l)(0 , 3 ),
575+ this ->model ->forwardPosition (l)(1 , 3 ),
576+ this ->model ->forwardPosition (l)(2 , 3 )
533577 );
534578 }
535579
@@ -544,22 +588,29 @@ Viewer::drawConfigurationPath(const rl::plan::VectorList& path)
544588 this ->model ->setPosition (inter);
545589 this ->model ->updateFrames (false );
546590
547- this ->pathCoordinate ->point .set1Value (
548- this ->pathCoordinate ->point .getNum (),
591+ this ->pathEdgesCoordinate ->point .set1Value (
592+ this ->pathEdgesCoordinate ->point .getNum (),
549593 this ->model ->forwardPosition (l)(0 , 3 ),
550594 this ->model ->forwardPosition (l)(1 , 3 ),
551595 this ->model ->forwardPosition (l)(2 , 3 )
552596 );
553597
554- this ->pathIndexedLineSet ->coordIndex .set1Value (
555- this ->pathIndexedLineSet ->coordIndex .getNum (),
556- this ->pathCoordinate ->point .getNum () - 1
598+ this ->pathEdgesIndexedLineSet ->coordIndex .set1Value (
599+ this ->pathEdgesIndexedLineSet ->coordIndex .getNum (),
600+ this ->pathEdgesCoordinate ->point .getNum () - 1
557601 );
558602 }
603+
604+ this ->pathVerticesCoordinate ->point .set1Value (
605+ this ->pathVerticesCoordinate ->point .getNum (),
606+ this ->model ->forwardPosition (l)(0 , 3 ),
607+ this ->model ->forwardPosition (l)(1 , 3 ),
608+ this ->model ->forwardPosition (l)(2 , 3 )
609+ );
559610 }
560611
561- this ->pathIndexedLineSet ->coordIndex .set1Value (
562- this ->pathIndexedLineSet ->coordIndex .getNum (),
612+ this ->pathEdgesIndexedLineSet ->coordIndex .set1Value (
613+ this ->pathEdgesIndexedLineSet ->coordIndex .getNum (),
563614 SO_END_FACE_INDEX
564615 );
565616 }
@@ -855,13 +906,11 @@ Viewer::reset()
855906{
856907 this ->resetEdges ();
857908 this ->resetLines ();
909+ this ->resetPath ();
910+ this ->resetPath3 ();
858911 this ->resetPoints ();
859912 this ->resetSpheres ();
860913 this ->resetVertices ();
861- this ->pathCoordinate ->point .setNum (0 );
862- this ->pathIndexedLineSet ->coordIndex .setNum (0 );
863- this ->path3Coordinate ->point .setNum (0 );
864- this ->path3IndexedLineSet ->coordIndex .setNum (0 );
865914 this ->sweptGroup ->removeAllChildren ();
866915 this ->workTransform ->setMatrix (SbMatrix::identity ());
867916}
@@ -884,6 +933,21 @@ Viewer::resetLines()
884933 this ->linesIndexedLineSet ->coordIndex .setNum (0 );
885934}
886935
936+ void
937+ Viewer::resetPath ()
938+ {
939+ this ->pathEdgesCoordinate ->point .setNum (0 );
940+ this ->pathEdgesIndexedLineSet ->coordIndex .setNum (0 );
941+ this ->pathVerticesCoordinate ->point .setNum (0 );
942+ }
943+
944+ void
945+ Viewer::resetPath3 ()
946+ {
947+ this ->path3Coordinate ->point .setNum (0 );
948+ this ->path3IndexedLineSet ->coordIndex .setNum (0 );
949+ }
950+
887951void
888952Viewer::resetPoints ()
889953{
@@ -1015,15 +1079,28 @@ Viewer::toggleLines(const bool& doOn)
10151079}
10161080
10171081void
1018- Viewer::togglePath (const bool & doOn)
1082+ Viewer::togglePathEdges (const bool & doOn)
1083+ {
1084+ if (doOn)
1085+ {
1086+ this ->pathEdges ->whichChoice = SO_SWITCH_ALL;
1087+ }
1088+ else
1089+ {
1090+ this ->pathEdges ->whichChoice = SO_SWITCH_NONE;
1091+ }
1092+ }
1093+
1094+ void
1095+ Viewer::togglePathVertices (const bool & doOn)
10191096{
10201097 if (doOn)
10211098 {
1022- this ->path ->whichChoice = SO_SWITCH_ALL;
1099+ this ->pathVertices ->whichChoice = SO_SWITCH_ALL;
10231100 }
10241101 else
10251102 {
1026- this ->path ->whichChoice = SO_SWITCH_NONE;
1103+ this ->pathVertices ->whichChoice = SO_SWITCH_NONE;
10271104 }
10281105}
10291106
0 commit comments