Skip to content

Commit 60c409c

Browse files
committed
Add VrmlNodeViewPoint to swith viewpoints from vrml
1 parent 6cc3a27 commit 60c409c

5 files changed

Lines changed: 101 additions & 1 deletion

File tree

src/OpenCOVER/plugins/general/ViewPoint/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
if(NOT COVISE_USE_QT)
22
return()
33
endif()
4+
USING(VRML)
45

56
SET(HEADERS
67
BezierCurveVisualizer.h
@@ -10,6 +11,7 @@ SET(HEADERS
1011
coVRDOMDocument.h
1112
Interpolator.h
1213
ViewDesc.h
14+
VrmlNodeViewPoint.h
1315
)
1416
SET(SOURCES
1517
BezierCurveVisualizer.cpp
@@ -19,6 +21,7 @@ ViewPoint.cpp
1921
coVRDOMDocument.cpp
2022
Interpolator.cpp
2123
ViewDesc.cpp
24+
VrmlNodeViewPoint.cpp
2225
)
2326
cover_add_plugin(ViewPoint ${COVISE_GRMSG_LIBRARY})
2427
qt_use_modules(ViewPoint Xml)

src/OpenCOVER/plugins/general/ViewPoint/ViewPoint.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ bool ViewPoints::init()
294294
}
295295
});
296296

297-
auto speedSlider = new ui::Slider(viewPointMenu_, "animDuration");
297+
speedSlider = new ui::Slider(viewPointMenu_, "animDuration");
298298
speedSlider->setBounds(MinFlightTime, MaxFlightTime);
299299
speedSlider->setValue(flightTime);
300300
speedSlider->setIntegral(false);
@@ -2531,6 +2531,19 @@ bool ViewPoints::isClipPlaneChecked()
25312531
return useClipPlanesCheck_->state();
25322532
}
25332533

2534+
void ViewPoints::setName(const std::string &name)
2535+
{
2536+
for (vector<ViewDesc *>::iterator it = viewpoints.begin(); it < viewpoints.end(); it++)
2537+
{
2538+
if ((*it)->getName() == name)
2539+
{
2540+
loadViewpoint(*it);
2541+
(*it)->activate(useClipPlanesCheck_->state());
2542+
break;
2543+
}
2544+
}
2545+
}
2546+
25342547
bool ViewPoints::isOn(const char *vp)
25352548
{
25362549
if ((strncasecmp(vp, "true", 4) == 0) || (strncasecmp(vp, "on", 2) == 0) || (strncasecmp(vp, "1", 1) == 0))

src/OpenCOVER/plugins/general/ViewPoint/ViewPoint.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ class ViewPoints : public coVRPlugin, public ui::Owner
134134
static ViewPoints *instance(){return inst;}
135135
bool dataChanged = false;
136136
bool isClipPlaneChecked();
137+
ui::Slider *speedSlider;
138+
void setName(const std::string &name); // set viewpoint by name;
137139

138140
private:
139141
Vec3 eyepoint;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/* This file is part of COVISE.
2+
3+
You can use it under the terms of the GNU Lesser General Public License
4+
version 2.1 or later, see lgpl-2.1.txt.
5+
6+
* License: LGPL 2+ */
7+
#include "VrmlNodeViewPoint.h"
8+
9+
#include "ViewPoint.h"
10+
11+
static VrmlNode *creator(VrmlScene *scene)
12+
{
13+
return new VrmlNodeViewPoint(scene);
14+
}
15+
16+
VrmlNodeViewPoint::VrmlNodeViewPoint(VrmlScene *scene)
17+
: VrmlNodeChild(scene, typeName())
18+
{
19+
}
20+
21+
VrmlNodeViewPoint::VrmlNodeViewPoint(const VrmlNodeViewPoint &n)
22+
: VrmlNodeChild(n)
23+
{
24+
}
25+
26+
void VrmlNodeViewPoint::initFields(VrmlNodeViewPoint *node, VrmlNodeType *t)
27+
{
28+
VrmlNodeChild::initFields(node, t); // Parent class
29+
initFieldsHelper(node, t,
30+
field("transitionDuration", node->d_transitionDuration, [node](auto f)
31+
{ opencover::ViewPoint::instance()->speedSlider.setValue(f); opencover::ViewPoint::instance()->flightTime = f; }),
32+
field("viewPointName", node->d_viewPointName, [node](auto n)
33+
{ ViewPoint::instance()->setName(n); }));
34+
}
35+
36+
const char *VrmlNodeViewPoint::typeName()
37+
{
38+
return "ViewPoint";
39+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/* This file is part of COVISE.
2+
3+
You can use it under the terms of the GNU Lesser General Public License
4+
version 2.1 or later, see lgpl-2.1.txt.
5+
6+
* License: LGPL 2+ */
7+
8+
//
9+
// Vrml 97 library
10+
// Copyright (C) 2001 Uwe Woessner
11+
//
12+
// %W% %G%
13+
// VrmlNodeViewPoint.h
14+
15+
#ifndef _VrmlNodeViewPoint_
16+
#define _VrmlNodeViewPoint_
17+
18+
#include <util/coTypes.h>
19+
20+
#include <vrml97/vrml/VrmlNode.h>
21+
#include <vrml97/vrml/VrmlSFFloat.h>
22+
#include <vrml97/vrml/VrmlSFString.h>
23+
#include <vrml97/vrml/VrmlNodeChild.h>
24+
#include <vrml97/vrml/VrmlScene.h>
25+
26+
using namespace vrml;
27+
28+
#define ALL_REGIONS_STRING "all"
29+
30+
class VrmlNodeViewPoint : public VrmlNodeChild
31+
{
32+
public:
33+
VrmlNodeViewPoint(VrmlScene *scene = 0);
34+
VrmlNodeViewPoint(const VrmlNodeViewPoint &n);
35+
36+
static void initFields(VrmlNodeViewPoint *node, vrml::VrmlNodeType *t);
37+
static const char *typeName();
38+
39+
private:
40+
VrmlSFFloat d_transitionDuration;
41+
VrmlSFString d_viewPointName;
42+
};
43+
#endif //_VrmlNodeViewPoint_

0 commit comments

Comments
 (0)