polyline_ROI.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------
00012 //---------------------------------------------------
00013 
00014 #include "polyline_ROI.h"
00015 
00016 namespace imedgine 
00017 {
00018   PolylineROI::PolylineROI(SoSeparator* root)
00019   : ROIBase(root),
00020   point_index_(0) 
00021   {
00022     point_set_ = new SoCoordinate3;
00023     root_->addChild(point_set_);  
00024     
00025     polyline_set_ = new SoLineSet;  
00026     root_->addChild(polyline_set_);
00027     
00028     polyline_set_->numVertices = 0;    
00029   }
00030   
00031   //--------------------------------------------------- 
00032   
00033   PolylineROI::~PolylineROI()
00034   {
00035   }
00036 
00037   //--------------------------------------------------- 
00038   
00039   void PolylineROI::addPoint(SbVec3f point)
00040   {
00041     point_set_->point.set1Value(point_index_,
00042                                 point[X_DIMENSION],
00043                                 point[Y_DIMENSION], 0.1f);
00044 
00045     point_index_++;  
00046     ROIBase::addPoint(point);  
00047   }    
00048   
00049   //--------------------------------------------------- 
00050     
00051   void PolylineROI::drawROI()
00052   {
00053     int current_point_count = current_ROI_.size();
00054     int ROI_count = ROI_container_.size();
00055 
00056     
00057     polyline_set_->numVertices = -1;  
00058     
00059     //draw old ROIs that are stored in the ROI container
00060     for (int ROI_index = 0; ROI_index < ROI_count; ROI_index++)
00061     {
00062       polyline_set_->numVertices.set1Value(ROI_index, (ROI_container_.at(ROI_index)).size());
00063     }
00064     
00065     //not enough points set to draw line
00066     if (current_point_count < 2)
00067     {
00068       return;
00069     }
00070 
00071     std::cout << "Current point count: " << current_point_count << std::endl;  
00072     
00073     //draw the current ROI that is now drawn by the user
00074     polyline_set_->numVertices.set1Value(ROI_count, current_point_count);
00075 
00076     root_->touch();
00077   } 
00078    
00079   //---------------------------------------------------  
00080   
00081   void PolylineROI::autoCloseROI()
00082   {
00083     //add the starting point to the end of the list
00084     addPoint(current_ROI_[0]);
00085     finishROI();  
00086   }  
00087 }

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