PlaneObject.cc
00001
00002
00003
00004
00005
00006
00007 #define PLANEOBJECT_C
00008
00009
00010
00011 #include <OpenFlipper/common/Types.hh>
00012 #include "Plane.hh"
00013
00014
00015
00016
00017
00018
00019
00026 PlaneObject::PlaneObject( ) :
00027 BaseObjectData( ),
00028 planeNode_(NULL)
00029 {
00030 setDataType(DATA_PLANE);
00031 setTypeIcon(DATA_PLANE,"PlaneType.png");
00032 init();
00033 }
00034
00035
00036
00037
00041 PlaneObject::PlaneObject(const PlaneObject & _object) :
00042 BaseObjectData(_object)
00043 {
00044
00045 init(_object.planeNode_);
00046
00047 setName( name() );
00048 }
00049
00053 PlaneObject::~PlaneObject()
00054 {
00055
00056
00057
00058
00059
00060 deleteData();
00061
00062
00063 planeNode_ = NULL;
00064 }
00065
00069 void PlaneObject::cleanup() {
00070
00071 BaseObjectData::cleanup();
00072
00073 planeNode_ = NULL;
00074
00075 setDataType(DATA_PLANE);
00076 setTypeIcon(DATA_PLANE,"PlaneType.png");
00077
00078 init();
00079
00080 }
00081
00085 BaseObject* PlaneObject::copy() {
00086 PlaneObject* object = new PlaneObject(*this);
00087 return dynamic_cast< BaseObject* >(object);
00088 }
00089
00092 void PlaneObject::init(PlaneNode* _plane) {
00093
00094 if ( materialNode() == NULL)
00095 std::cerr << "Error when creating Plane Object! materialNode is NULL!" << std::endl;
00096
00097 planeNode_ = new PlaneNode( materialNode() , "NEW PlaneNode");
00098
00099 if (_plane){
00100 planeNode_->setPosition( _plane->position(), _plane->normal() );
00101 planeNode_->setSize( _plane->xDirection().norm(), _plane->yDirection().norm() );
00102 } else {
00103 planeNode_->setPosition( ACG::Vec3f(0.0, 0.0, 0.0), ACG::Vec3f(0.0, 1.0, 0.0) );
00104 planeNode_->setSize( 5.0, 5.0 );
00105 }
00106 }
00107
00108
00109
00110
00111
00115 void PlaneObject::setName( QString _name ) {
00116 BaseObjectData::setName(_name);
00117
00118 std::string nodename = std::string("PlaneNode for Plane " + _name.toUtf8() );
00119 planeNode_->name( nodename );
00120 }
00121
00122
00123
00124
00125
00126 PlaneNode* PlaneObject::planeNode() {
00127 return planeNode_;
00128 }
00129
00130
00131
00132
00133
00139 QString PlaneObject::getObjectinfo() {
00140 QString output;
00141
00142 output += "========================================================================\n";
00143 output += BaseObjectData::getObjectinfo();
00144
00145 if ( dataType( DATA_PLANE ) )
00146 output += "Object Contains Plane : ";
00147
00148 ACG::Vec3f pos = planeNode_->position();
00149 ACG::Vec3f nor = planeNode_->normal();
00150
00151 output += " Position ( " + QString::number(pos[0]) + ", " + QString::number(pos[1]) + ", " + QString::number(pos[2]) + ")";
00152 output += " Normal ( " + QString::number(nor[0]) + ", " + QString::number(nor[1]) + ", " + QString::number(nor[2]) + ")";
00153
00154 output += "========================================================================\n";
00155 return output;
00156 }
00157
00158
00159
00160
00161
00168 bool PlaneObject::picked( uint _node_idx ) {
00169 return ( _node_idx == planeNode_->id() );
00170 }
00171
00172 void PlaneObject::enablePicking( bool _enable ) {
00173 planeNode_->enablePicking( _enable );
00174 }
00175
00176 bool PlaneObject::pickingEnabled() {
00177 return planeNode_->pickingEnabled();
00178 }
00179
00180
00181