Developer Documentation
Ruler.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41 
42 /*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49 #include <QObject>
50 #include <QString>
51 
52 #include <ACG/Scenegraph/LineNode.hh>
53 #include <ACG/Scenegraph/TextNode.hh>
55 
56 class Ruler : public QObject
57 {
58  Q_OBJECT
59 signals:
60  void updateView();
61 
62 public:
69  Ruler(BaseObjectData *_obj,const QString &_pluginName, unsigned _index);
70  ~Ruler();
71 
72  void setPoints(const ACG::Vec3d& _start,const ACG::Vec3d& _end);
73  void setStartPoint(const ACG::Vec3d& _start);
74  void setEndPoint(const ACG::Vec3d& _end);
75  void setTextOffset(const ACG::Vec3d& offset);
76 
77  const ACG::Vec3d* points() const{return points_;}
78 
79  const BaseObject* getBaseObj(){return obj_;}
80 
81  float textScale(){return textNode_->lastScale();}
82 
83 public slots:
84 
85  // set text size in pixels
86  void setTextSize(const unsigned _size){textNode_->setPixelSize(_size); emit updateView();}
87 
88 private:
89 
90  void updateNodes();
91 
92  const QString pluginName_;
93  const std::string lineNodeName_;
94  const std::string textNodeName_;
95  const std::string textTransformNodeName_;
96 
97  ACG::SceneGraph::LineNode* lineNode_;
98  ACG::SceneGraph::TextNode* textNode_;
99  ACG::SceneGraph::TransformNode* textTransformNode_;
100 
101  ACG::Vec3d points_[2];
102  ACG::Vec3d offset_;
103  BaseObjectData* obj_;
104 };
void setPixelSize(const unsigned int _size)
sets the pixelsize of the text (only available for the SCREEN_ALIGNED_STATIC_SIZE mode and only works...
Definition: TextNode.cc:679
Ruler(BaseObjectData *_obj, const QString &_pluginName, unsigned _index)
Definition: Ruler.cc:53
float lastScale()
returns the scaling factor for screen aligned text the text. returns 0, if textmode is not SCREEN_ALI...
Definition: TextNode.hh:172
Definition: Ruler.hh:56