@@ -80,12 +80,20 @@ Viewer::Viewer(QWidget* parent, Qt::WindowFlags f) :
80
80
linesMaterial(new SoVRMLMaterial()),
81
81
linesShape(new SoVRMLShape()),
82
82
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()),
89
97
path3(new SoVRMLSwitch()),
90
98
path3Appearance(new SoVRMLAppearance()),
91
99
path3Coordinate(new SoVRMLCoordinate()),
@@ -270,20 +278,47 @@ Viewer::Viewer(QWidget* parent, Qt::WindowFlags f) :
270
278
this ->path ->setName (" path" );
271
279
this ->path ->whichChoice = SO_SWITCH_ALL;
272
280
273
- this ->pathDrawStyle ->lineWidth = 3 .0f ;
274
- this ->pathDrawStyle ->pointSize = 0 .0f ;
275
- this ->path ->addChild (this ->pathDrawStyle );
281
+ this ->root ->addChild (this ->path );
276
282
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
280
284
281
- this ->pathIndexedLineSet -> coord = this -> pathCoordinate ;
282
- this ->pathShape -> geometry = this -> pathIndexedLineSet ;
285
+ this ->pathEdges -> setName ( " pathEdges " ) ;
286
+ this ->pathEdges -> whichChoice = SO_SWITCH_ALL ;
283
287
284
- this ->path ->addChild (this ->pathShape );
288
+ this ->pathEdgesDrawStyle ->lineWidth = 3 .0f ;
289
+ this ->pathEdgesDrawStyle ->pointSize = 0 .0f ;
290
+ this ->pathEdges ->addChild (this ->pathEdgesDrawStyle );
285
291
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 );
287
322
288
323
// path3
289
324
@@ -505,8 +540,10 @@ Viewer::drawConfigurationPath(const rl::plan::VectorList& path)
505
540
{
506
541
this ->path ->enableNotify (false );
507
542
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 );
510
547
511
548
rl::math::Vector inter (this ->model ->getDofPosition ());
512
549
@@ -520,16 +557,23 @@ Viewer::drawConfigurationPath(const rl::plan::VectorList& path)
520
557
this ->model ->setPosition (*i);
521
558
this ->model ->updateFrames ();
522
559
523
- this ->pathCoordinate ->point .set1Value (
524
- this ->pathCoordinate ->point .getNum (),
560
+ this ->pathEdgesCoordinate ->point .set1Value (
561
+ this ->pathEdgesCoordinate ->point .getNum (),
525
562
this ->model ->forwardPosition (l)(0 , 3 ),
526
563
this ->model ->forwardPosition (l)(1 , 3 ),
527
564
this ->model ->forwardPosition (l)(2 , 3 )
528
565
);
529
566
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 )
533
577
);
534
578
}
535
579
@@ -544,22 +588,29 @@ Viewer::drawConfigurationPath(const rl::plan::VectorList& path)
544
588
this ->model ->setPosition (inter);
545
589
this ->model ->updateFrames (false );
546
590
547
- this ->pathCoordinate ->point .set1Value (
548
- this ->pathCoordinate ->point .getNum (),
591
+ this ->pathEdgesCoordinate ->point .set1Value (
592
+ this ->pathEdgesCoordinate ->point .getNum (),
549
593
this ->model ->forwardPosition (l)(0 , 3 ),
550
594
this ->model ->forwardPosition (l)(1 , 3 ),
551
595
this ->model ->forwardPosition (l)(2 , 3 )
552
596
);
553
597
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
557
601
);
558
602
}
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
+ );
559
610
}
560
611
561
- this ->pathIndexedLineSet ->coordIndex .set1Value (
562
- this ->pathIndexedLineSet ->coordIndex .getNum (),
612
+ this ->pathEdgesIndexedLineSet ->coordIndex .set1Value (
613
+ this ->pathEdgesIndexedLineSet ->coordIndex .getNum (),
563
614
SO_END_FACE_INDEX
564
615
);
565
616
}
@@ -855,13 +906,11 @@ Viewer::reset()
855
906
{
856
907
this ->resetEdges ();
857
908
this ->resetLines ();
909
+ this ->resetPath ();
910
+ this ->resetPath3 ();
858
911
this ->resetPoints ();
859
912
this ->resetSpheres ();
860
913
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 );
865
914
this ->sweptGroup ->removeAllChildren ();
866
915
this ->workTransform ->setMatrix (SbMatrix::identity ());
867
916
}
@@ -884,6 +933,21 @@ Viewer::resetLines()
884
933
this ->linesIndexedLineSet ->coordIndex .setNum (0 );
885
934
}
886
935
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
+
887
951
void
888
952
Viewer::resetPoints ()
889
953
{
@@ -1015,15 +1079,28 @@ Viewer::toggleLines(const bool& doOn)
1015
1079
}
1016
1080
1017
1081
void
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)
1019
1096
{
1020
1097
if (doOn)
1021
1098
{
1022
- this ->path ->whichChoice = SO_SWITCH_ALL;
1099
+ this ->pathVertices ->whichChoice = SO_SWITCH_ALL;
1023
1100
}
1024
1101
else
1025
1102
{
1026
- this ->path ->whichChoice = SO_SWITCH_NONE;
1103
+ this ->pathVertices ->whichChoice = SO_SWITCH_NONE;
1027
1104
}
1028
1105
}
1029
1106
0 commit comments