view.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------
00012 //---------------------------------------------------
00013 
00014 #include "view.h"
00015 #include "../controller/data_view_mediator.h"
00016 
00017 namespace imedgine 
00018 {
00019   unsigned int View::num_constructed_views_ = 0;
00020   
00021   //---------------------------------------------------
00022   
00023   View::View(view_type type)
00024   : view_parent_(0), 
00025     data_view_mediator_(0),
00026     type_(type),
00027     view_id_(num_constructed_views_++)
00028   {    
00029     root_ = new SoSeparator();
00030     root_->ref();   
00031     
00032     //light_ = new SoDirectionalLight;
00033     //root_->addChild(light_);   
00034     
00035     //transform_ = new SoTransform();
00036     //transform_->scaleFactor = SbVec3f(1, 1, 1); 
00037     //root_->addChild(transform_); 
00038   }
00039   
00040   //---------------------------------------------------
00041   
00042   View::View(View const& src)
00043   : view_parent_(0),
00044     type_(src.type_),
00045     view_id_(num_constructed_views_++)
00046   {
00047     root_ = new SoSeparator();
00048     root_->ref();
00049   }    
00050   
00051   //---------------------------------------------------
00052   
00053   View::~View()
00054   {
00055 #ifdef DEBUG
00056     std::cout << "Deleting View " << view_id_ << std::endl;
00057 #endif
00058     root_->unref(); 
00059   }
00060   
00061   //---------------------------------------------------
00062   
00063   unsigned int View::getViewID() const
00064   {
00065     return(view_id_);  
00066   }
00067   
00068   //---------------------------------------------------
00069   
00070   view_type View::getType() const
00071   {
00072     return(type_);
00073   } 
00074   
00075   //---------------------------------------------------
00076   
00077   void View::setParent(QWidget* view_parent)
00078   {
00079     view_parent_ = view_parent;
00080   }
00081   
00082   //---------------------------------------------------
00083   
00084   void View::setDataset(dataset_pointer_type dataset)
00085       throw(NullPointerException, InvalidCastException)
00086   {
00087     dataset_key_ = dataset->getDatasetKey();
00088   }
00089   
00090   //---------------------------------------------------
00091   
00092   void View::onDataChangedEvent(dataset_attribute_type)
00093   {
00094   }
00095   
00096   //---------------------------------------------------
00097   
00098   void View::registerDataViewMediator(DataViewMediator* data_view_mediator)
00099   {
00100     data_view_mediator_ = data_view_mediator;
00101   }
00102   
00103   //---------------------------------------------------
00104 
00105   void View::deregisterDataViewMediator()
00106   {
00107     data_view_mediator_ = 0;
00108   }
00109   
00110   //-------------------------------------------------- 
00111   
00112   void View::createSceneGraph()
00113   {
00114     dynamic_sep_ = new SoSeparator;
00115     root_->addChild(dynamic_sep_);    
00116          
00117     static_sep_ = new SoSeparator;
00118     root_->addChild(static_sep_);    
00119     static_camera_ = new SoOrthographicCamera();
00120     static_camera_->focalDistance = 10;  
00121     static_camera_->nearDistance = 0.5;
00122     static_camera_->farDistance = 10;    
00123     static_camera_->viewportMapping = SoCamera::LEAVE_ALONE;    
00124     static_sep_->addChild(static_camera_); 
00125   }
00126     
00127   //---------------------------------------------------
00128      
00129   void View::notifyDataChangedEvent(dataset_attribute_type changed_attribute)
00130   {
00131     if (data_view_mediator_ !=0)
00132     {
00133       data_view_mediator_->updateDataChanged(dataset_key_, changed_attribute);
00134     }
00135   }
00136 }

Generated on Sun Aug 13 18:19:41 2006 for iMEDgine by  doxygen 1.4.6