1 #include "DistanceMeasureControl.hh"
3 #include <Base/Math/Vector3.hh>
4 #include <Gui/biasgl.h>
14 bDistMeasureActivated_ =
false;
16 bIsInitialized_ =
false;
17 firstHomgPoint_.Set(0.0,0.0,0.0,1.0);
18 secondHomgPoint_.Set(0.0,0.0,0.0,1.0);
24 bDistMeasureActivated_=on;
29 return bDistMeasureActivated_;
35 if (! UseLeftDouble_) {
38 if(bDistMeasureActivated_){
40 if(!controlledObject_->GetViewportCoordinates(x, y)) {
41 BIASERR(
"outside used viewport!");
47 if (!(homgPoint[3] == 0.0)) {
52 if(dNumClick_==0 || dNumClick_ ==2){
54 firstHomgPoint_ = homgPoint;
55 secondHomgPoint_.
Set(0.0,0.0,0.0,1.0);
57 else if(dNumClick_==1){
59 secondHomgPoint_ = homgPoint;
60 double dist = secondHomgPoint_.
Distance(firstHomgPoint_);
61 cout<<
"Final Distance: "<<dist<<endl;
84 if (!bIsInitialized_) {
85 #ifdef BIAS_HAVE_FONTGL
86 if (drawer_.InitFont(NULL) != 0){
87 cerr<<
"init of font failed ..."<<endl;
91 BIASWARNONCE(
"FontGL is disabled in BIAS.");
94 bIsInitialized_ =
true;
97 if(bDistMeasureActivated_ && dNumClick_==1){
99 if (!(homgPoint[3] == 0.0)) {
100 double dist = homgPoint.
Distance(firstHomgPoint_);
102 float red[4] = {1.0, 0.0, 0.0, 1.0};
103 float white[4] = {1.0, 1.0, 1.0, 1.0};
104 float black[4] = {0.0, 0.0, 0.0, 1.0};
105 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, black);
106 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, red);
107 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, white);
109 glColor3f(1.0, 0.0, 0.0);
111 glVertex3d(firstHomgPoint_[0],firstHomgPoint_[1], firstHomgPoint_[2]);
112 glVertex3d(homgPoint[0],homgPoint[1], homgPoint[2]);
115 stringstream text; text<<dist<<endl;
117 #ifdef BIAS_HAVE_FONTGL
118 glDisable(GL_DEPTH_TEST);
119 drawer_.Print3D(text.str(),homgPoint[0],homgPoint[1],homgPoint[2]);
120 glEnable(GL_DEPTH_TEST);
bool GetDistanceMeasure()
Return if the measurement mode is activated.
bool LeftMouseDoubleClicked(int x, int y, int m)
Sets first or second click measurement positions.
virtual bool LeftMouseDoubleClicked(int x, int y, int m)
Computes from the coordinates x,y a 3D point in the scene and tries to set it to the point of interes...
void Set(const HOMGPOINT3D_TYPE &x, const HOMGPOINT3D_TYPE &y, const HOMGPOINT3D_TYPE &z)
set elementwise with given 3 euclidean scalar values.
bool MouseMoved(int x, int y)
Sets intermediate coords.
virtual void Draw()
overloaded method from SceneBase.
HOMGPOINT3D_TYPE Distance(const HomgPoint3D &point) const
class HomgPoint3D describes a point with 3 degrees of freedom in projective coordinates.
void SetDistanceMeasure(bool on)
Activate or deactivate distance measurement.