fromcompas.geometryimportPoint,Polyline,Bezierfromcompas.colorsimportColorfrommatplotlib.pyplotimporttitlefromcompas_view2.appimportAppfromcompas_view2.appimportControllerconfig={"messages":{"about":"COMPAS View2 is the second generation of standalone viewers for the COMPAS framework."},"menubar":[{"type":"menu","text":"COMPASVIEW 2","items":[{"type":"action","text":"About","action":"about"},{"type":"separator"},{"type":"action","text":"OpenGL Version","action":"opengl_version"},{"type":"action","text":"GLSL Version","action":"glsl_version"}]},{"type":"menu","text":"View","items":[{"type":"radio","items":[{"type":"action","text":"Shaded","checked":False,"action":"view_shaded"},{"type":"action","text":"Ghosted","checked":False,"action":"view_ghosted"},{"type":"action","text":"Wireframe","checked":False,"action":"view_wireframe"},{"type":"action","text":"Lighted","checked":False,"action":"view_lighted"}]},{"type":"separator"},{"type":"action","text":"Capture","action":"view_capture"},{"type":"separator"},{"type":"action","text":"Front","action":"view_front"},{"type":"action","text":"Right","action":"view_right"},{"type":"action","text":"Top","action":"view_top"},{"type":"action","text":"Perspective","action":"view_perspective"}]},{"type":"menu","text":"Custom Menu","items":[{"type":"action","text":"Open side dock 1","action":"open_dock1"},{"type":"action","text":"Open side dock 2","action":"open_dock2"},]},],"toolbar":[{"type":"action","text":"Capture","action":"view_capture"},{"type":"separator"},{"type":"action","text":"Front","action":"view_front"},{"type":"action","text":"Right","action":"view_right"},{"type":"action","text":"Top","action":"view_top"},{"type":"action","text":"Perspective","action":"view_perspective"},{"type":"separator"},{"type":"action","text":"Open side dock 3","action":"open_dock3"},]}classCustomController(Controller):defopen_dock1(self):viewer=self.appdock=viewer.sidedock(title='Menu 1',slot='A',location="right")@viewer.checkbox(text="Show Point",checked=True,parent=dock._layout)defcheck(checked):pointobj.is_visible=checkedviewer.view.update()dock._layout.addStretch()defopen_dock2(self):viewer=self.appdock=viewer.sidedock(title='Menu 2',slot='A',location="right")@viewer.slider(title="Slide Point",maxval=100,step=1,bgcolor=Color.white(),parent=dock._layout)defslide(value):value=value/100pointobj._data=curve.point(value)pointobj.update()viewer.view.update()@viewer.button(text="Reset",parent=dock._layout)defclick():ifviewer.confirm('This will reset the point to parameter t=0.'):pointobj._data=curve.point(0)pointobj.update()slide.value=0viewer.view.update()dock._layout.addStretch()defopen_dock3(self):viewer=self.appdock=viewer.sidedock(title='Menu 1',location="left")@viewer.checkbox(text="Do nothing",checked=True,parent=dock._layout)defcheck(checked):passdock._layout.addStretch()viewer=App(viewmode="shaded",width=1600,height=900,config=config,controller_class=CustomController)curve=Bezier([[0,0,0],[3,6,0],[5,-3,0],[10,0,0]])pointobj=viewer.add(Point(*curve.point(0)),pointsize=20,pointcolor=(1,0,0))curveobj=viewer.add(Polyline(curve.locus()),linewidth=2)viewer.run()