Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
CoordsysObject.cc
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
50 //=============================================================================
51 //
52 // Plane Object
53 //
54 //=============================================================================
55
56 #define PLANEOBJECT_C
57
58 //== INCLUDES =================================================================
59
60 #include <OpenFlipper/common/Types.hh>
61 #include "Coordsys.hh"
62
63 //== DEFINES ==================================================================
64
65 //== TYPEDEFS =================================================================
66
67 //== CLASS DEFINITION =========================================================
68
75 CoordsysObject::CoordsysObject( ) :
76 BaseObjectData( ),
77 coordsysNode_(NULL)
78 {
79 setDataType(DATA_COORDSYS);
80 init();
81 }
82
83 //=============================================================================
84
85
89 CoordsysObject::CoordsysObject(const CoordsysObject & _object) :
90 BaseObjectData(_object)
91 {
92
93 init(_object.coordsysNode_);
94
95 setName( name() );
96 }
97
101 CoordsysObject::~CoordsysObject()
102 {
103 // Delete the data attached to this object ( this will remove all perObject data)
104 // Not the best way to do it but it will work.
105 // This is only necessary if people use references to the coordsys below and
106 // they do something with the coordsys in the destructor of their
107 // perObjectData.
108 deleteData();
109
110 // No need to delete the scenegraph Nodes as this will be managed by baseplugin
111 coordsysNode_ = NULL;
112 }
113
117 void CoordsysObject::cleanup() {
118
119 BaseObjectData::cleanup();
120
121 coordsysNode_ = NULL;
122
123 setDataType(DATA_COORDSYS);
124 setTypeIcon(DATA_COORDSYS,"CoordsysType.png");
125
126 init();
127
128 }
129
133 BaseObject* CoordsysObject::copy() {
134 CoordsysObject* object = new CoordsysObject(*this);
135 return dynamic_cast< BaseObject* >(object);
136 }
137
140 void CoordsysObject::init(CoordsysNode* _coordsys) {
141
142 if ( materialNode() == NULL)
143 std::cerr << "Error when creating Coordsys Object! materialNode is NULL!" << std::endl;
144
145 coordsysNode_ = new CoordsysNode( materialNode() , "NEW CoordsysNode");
146
147 if (_coordsys){
148 coordsysNode_->position( _coordsys->position() );
149 coordsysNode_->size( _coordsys->size() );
150 } else {
151 coordsysNode_->position( ACG::Vec3d(0.0, 0.0, 0.0) );
152 coordsysNode_->size( 1.0 );
153 }
154 }
155
156 // ===============================================================================
157 // Name/Path Handling
158 // ===============================================================================
159
163 void CoordsysObject::setName( QString _name ) {
164 BaseObjectData::setName(_name);
165
166 std::string nodename = std::string("CoordsysNode for Coordinate system " + _name.toUtf8() );
167 coordsysNode_->name( nodename );
168 }
169
170 // ===============================================================================
171 // Visualization
172 // ===============================================================================
173
174 CoordsysNode* CoordsysObject::coordsysNode() {
175 return coordsysNode_;
176 }
177
178 // ===============================================================================
179 // Object information
180 // ===============================================================================
181
187 QString CoordsysObject::getObjectinfo() {
188 QString output;
189
190 output += "========================================================================\n";
191 output += BaseObjectData::getObjectinfo();
192
193 if ( dataType( DATA_COORDSYS ) )
194 output += "Object Contains a coordinate system : ";
195
196 ACG::Vec3d pos = coordsysNode_->position();
197 double size = coordsysNode_->size();
198
199 output += " Position ( " + QString::number(pos[0]) + ", " + QString::number(pos[1]) + ", " + QString::number(pos[2]) + ")";
200 output += " Size ( "+ QString::number(size) + ")";
201
202 output += "========================================================================\n";
203 return output;
204 }
205
206 // ===============================================================================
207 // Picking
208 // ===============================================================================
209
216 bool CoordsysObject::picked( uint _node_idx ) {
217 return ( _node_idx == coordsysNode_->id() );
218 }
219
220 void CoordsysObject::enablePicking( bool _enable ) {
221 coordsysNode_->enablePicking( _enable );
222 }
223
224 bool CoordsysObject::pickingEnabled() {
225 return coordsysNode_->pickingEnabled();
226 }
227
228 // ===============================================================================
229 // Update
230 // ===============================================================================
231
232
233 void CoordsysObject::update(UpdateType _type) {
234 BaseObject::update(_type);
235 }
236
237
238 //=============================================================================
239
CoordsysObject::coordsysNode_
CoordsysNode * coordsysNode_
Get the scenegraph Node.
Definition: CoordsysObject.hh:128
setTypeIcon
DLLEXPORT void setTypeIcon(DataType _id, QString _icon)
Set an Icon for a given DataType.
Definition: Types.cc:234
ACG::SceneGraph::ACG::SceneGraph::BaseNode::name
std::string name() const
Returns: name of node (needs not be unique)
Definition: MeshNode2T.cc:391
ACG::SceneGraph::CoordinateSystemNode::size
void size(const double _size)
set size of the coordsys ( Size is length of one of the axis )
Definition: CoordinateSystemNode.cc:313
CoordsysObject::copy
BaseObject * copy()
Definition: CoordsysObject.cc:133
BaseObject::getObjectinfo
virtual QString getObjectinfo()
Get all Info for the Object as a string.
Definition: BaseObject.cc:255
BaseObjectData
Definition: BaseObjectData.hh:105
BaseObject::name
QString name() const
return the name of the object. The name defaults to NONAME if unset.
Definition: BaseObject.cc:741
CoordsysObject::getObjectinfo
QString getObjectinfo()
Get all Info for the Object as a string.
Definition: CoordsysObject.cc:187
BaseObject::deleteData
void deleteData()
Delete all data attached to this object ( calls delete on each object )
Definition: BaseObject.cc:823
UpdateType
Update type class.
Definition: UpdateType.hh:70
BaseObject::update
virtual void update(UpdateType _type=UPDATE_ALL)
This function is called to update the object.
Definition: BaseObject.cc:756
ACG::SceneGraph::ACG::SceneGraph::BaseNode::pickingEnabled
bool pickingEnabled()
Definition: MeshNode2T.cc:245
BaseObjectData::setName
virtual void setName(QString _name)
path to the file from which the object is loaded ( defaults to "." )
Definition: BaseObjectData.cc:357
BaseObjectData::materialNode
MaterialNode * materialNode()
get a pointer to the materialnode
Definition: BaseObjectData.cc:269
BaseObject::dataType
DataType dataType() const
Definition: BaseObject.cc:240
CoordsysObject::init
virtual void init(CoordsysNode *_coordsys=0)
Initialize current object, including all related nodes.
Definition: CoordsysObject.cc:140
BaseObjectData::cleanup
virtual void cleanup()
Definition: BaseObjectData.cc:108
CoordsysObject::picked
bool picked(uint _node_idx)
detect if the node has been picked
Definition: CoordsysObject.cc:216
ACG::SceneGraph::CoordinateSystemNode
Node for displaying coordinate systems.
Definition: CoordinateSystemNode.hh:87
Coordsys.hh
CoordsysNode
ACG::SceneGraph::CoordinateSystemNode CoordsysNode
Simple Name for CoordsysNode.
Definition: CoordsysTypes.hh:72
CoordsysObject::coordsysNode
CoordsysNode * coordsysNode()
Get the scenegraph Node.
Definition: CoordsysObject.cc:174
ACG::SceneGraph::ACG::SceneGraph::BaseNode::id
unsigned int id() const
Definition: MeshNode2T.cc:399
ACG::SceneGraph::CoordinateSystemNode::position
void position(const Vec3d &_pos)
set position of the coordsys
Definition: CoordinateSystemNode.cc:288
BaseObject
Definition: BaseObject.hh:94
CoordsysObject::~CoordsysObject
virtual ~CoordsysObject()
destructor
Definition: CoordsysObject.cc:101
OpenMesh::VectorT
Definition: Vector11T.hh:83
CoordsysObject::CoordsysObject
CoordsysObject()
constructor
Definition: CoordsysObject.cc:75
BaseObject::setDataType
void setDataType(DataType _type)
Definition: BaseObject.cc:244
CoordsysObject::update
virtual void update(UpdateType _type=UPDATE_ALL)
Update the whole Object (Selection,Topology,...)
Definition: CoordsysObject.cc:233
CoordsysObject::pickingEnabled
bool pickingEnabled()
Check if picking is enabled for this Object.
Definition: CoordsysObject.cc:224
CoordsysObject::setName
void setName(QString _name)
Set the name of the Object.
Definition: CoordsysObject.cc:163
CoordsysObject::enablePicking
void enablePicking(bool _enable)
Enable or disable picking for this Object.
Definition: CoordsysObject.cc:220
CoordsysObject
Definition: CoordsysObject.hh:79
Types.hh
CoordsysObject::cleanup
virtual void cleanup()
Reset current object, including all related nodes.
Definition: CoordsysObject.cc:117
DATA_COORDSYS
#define DATA_COORDSYS
Definition: Coordsys.hh:64
ACG::SceneGraph::ACG::SceneGraph::BaseNode::enablePicking
void enablePicking(bool _enable)
Definition: MeshNode2T.cc:241