35 #ifndef __TraceContainerBase_h
36 #define __TraceContainerBase_h
42 #include "vtkProperty.h"
44 #include "QGoGUILibConfigure.h"
46 #include "vtkIntArray.h"
48 #include "vtkMapper.h"
49 #include "vtkDataSet.h"
50 #include "vtkPointData.h"
54 #include "boost/multi_index_container.hpp"
55 #include "boost/multi_index/member.hpp"
56 #include "boost/multi_index/hashed_index.hpp"
57 #include "boost/multi_index/ordered_index.hpp"
58 #include "boost/numeric/conversion/cast.hpp"
59 #include "boost/lexical_cast.hpp"
104 iStructure.ActorXY =
actor[0];
105 iStructure.ActorXZ =
actor[1];
106 iStructure.ActorYZ =
actor[2];
107 iStructure.ActorXYZ =
actor[3];
143 template<
class TContainer >
150 typedef typename MultiIndexContainerType::template index< TraceID >::type::iterator
153 typedef typename MultiIndexContainerType::template index< CollectionID >::type::iterator
156 typedef typename MultiIndexContainerType::template index< Highlighted >::type::iterator
159 typedef typename MultiIndexContainerType::template index< Visible >::type::iterator
186 template<
class TIterator >
187 void Print(TIterator iBegin, TIterator iEnd)
189 TIterator it = iBegin;
194 std::cout <<
"***" << std::endl;
195 std::cout << std::endl;
205 template<
class TIndex >
208 using boost::multi_index::get;
238 template<
class TList >
241 using boost::multi_index::get;
243 typename TList::iterator it = iList.begin();
245 while ( it != iList.end() )
248 m_Container.get< TraceID >().find( static_cast< unsigned int >( *it ) );
258 vtkProperty *tproperty = vtkProperty::New();
259 tproperty->SetColor(id_it->rgba[0], id_it->rgba[1], id_it->rgba[2]);
260 tproperty->SetOpacity(id_it->rgba[3]);
265 bool test2 = id_it->Visible;
269 std::vector< vtkActor * > actor =
275 typedef void (
QGoImageView3D::*ImageViewMember )(
const int &, vtkActor *);
278 if ( id_it->Visible )
288 for (
int i = 0; i < 4; i++ )
312 template<
class TIndex >
314 typename MultiIndexContainerType::template index< TIndex >::type::iterator& iIt,
315 std::vector< vtkActor * > iActors,
316 const bool & iHighlighted,
317 const bool & iVisible)
320 using boost::multi_index::get;
322 if ( iActors.size() == 4 )
327 bool highlighted = iHighlighted;
328 bool visible = iVisible;
334 typedef void (
QGoImageView3D::*ImageViewMember )(
const int &, vtkActor *);
347 for (
int i = 0; i < 4; i++ )
372 bool IsVisible =
false);
399 template<
class TIndex >
401 typename MultiIndexContainerType::template index< TIndex >::type::iterator iIt )
403 using boost::multi_index::get;
432 const unsigned int & iId);
496 const std::map< unsigned int, std::string >& iValues );
507 template<
typename TValue >
509 const std::map< unsigned int, TValue >& iValues )
511 typedef TValue ValueType;
512 typedef typename std::map< unsigned int, ValueType > MapType;
513 typedef typename MapType::const_iterator MapConstIterator;
515 using boost::multi_index::get;
517 if( iColumnName.empty() || iValues.empty() )
523 MapConstIterator it = iValues.begin();
528 temp = boost::numeric_cast<
double >( it->second );
530 catch( boost::numeric::bad_numeric_cast& e )
532 std::cout << e.what() <<std::endl;
536 double min_value = temp;
537 double max_value = temp;
539 while( it != iValues.end() )
542 trace_it = this->
m_Container.get<TraceID>().find( it->first );
544 if( trace_it != this->
m_Container.get<TraceID>().end() )
551 temp = boost::numeric_cast<
double >( it->second );
553 catch( boost::numeric::bad_numeric_cast& e )
555 std::cout << e.what() <<std::endl;
559 if( temp > max_value )
563 if( temp < min_value )
568 trace_it->SetScalarData( iColumnName, temp );
583 const std::map< unsigned int, unsigned int >& iIds );
586 const std::map< unsigned int, std::string >& iValues );
604 const Qt::CheckState& iCheck );
611 const Qt::CheckState& iCheck );
622 const bool& iHighlighted,
623 const bool& iVisible );
634 const unsigned int& oTraceId,
635 Qt::CheckState& oState )
637 using boost::multi_index::get;
639 typedef typename MultiIndexContainerType::template index< TraceID >::type::iterator
641 IteratorType it =
m_Container.get< TraceID >().find(oTraceId);
643 vtkProperty *temp_property = vtkProperty::New();
645 assert ( it !=
m_Container.get< TraceID >().end() );
647 if ( it->Highlighted )
649 temp_property->SetColor(it->rgba[0],
652 temp_property->SetOpacity(it->rgba[3]);
660 it->SetActorProperties( temp_property );
662 temp_property->Delete();
665 bool checked =
false;
666 if ( !it->Highlighted )
668 oState = Qt::Checked;
673 oState = Qt::Unchecked;
685 const unsigned int& oTraceId,
688 using boost::multi_index::get;
690 typedef typename MultiIndexContainerType::template index< TraceID >::type::iterator
692 IteratorType it =
m_Container.get< TraceID >().find(oTraceId);
694 assert ( it !=
m_Container.get< TraceID >().end() );
696 if ( it->Visible != iState )
698 it->SetActorVisibility( iState );
705 #include "TraceContainerBase.txx"
707 #endif // __TraceContainerBase_h
MultiIndexContainerType::value_type MultiIndexContainerElementType
vtkPolyData * GetCurrentElementNodes()
Get the polydata representing the current element track.
std::list< unsigned int > GetHighlightedElementsCollectionID()
void Print()
Print the container content in the application output according to the template parameter.
virtual std::list< unsigned int > DeleteAllHighlightedElements()=0
Delete all highlighted elements.
void SetColorCode(const std::string &iColumnName, const std::map< unsigned int, std::string > &iValues)
Color code contour / mesh according to values provided.
void operator()(T &iStructure)
void UpdateElementVisibilityWithTraceID(const unsigned int &oTraceId, const bool &iState)
std::vector< vtkActor * > actor
void UpdateRenderWindows()
Update only the visualization.
double * GetCurrentElementColor()
Get the color of the current element track.
void UpdateCurrentElementFromDB(unsigned int iTraceID, double irgba[4], bool IsVisible=false)
Update Current Element from te database.
bool UpdateCurrentElementFromExistingOne(unsigned int iTraceID, bool iErase=true)
put the information of the existing element into m_CurrentElement and remove the existing element fro...
std::list< unsigned int > UpdateAllHighlightedElementsWithGivenColor(QColor iColor)
Update all highlighted elements in the container with a given color.
MultiIndexContainerType::template index< TraceID >::type::iterator MultiIndexContainerTraceIDIterator
change_highlighted(bool &iHighlight)
MultiIndexContainerType m_Container
Trace Contaienr.
bool RemoveElementFromVisualizationWithGivenTraceID(const unsigned int &iId)
Remove element from visualization.
virtual void UpdateElementHighlightingWithGivenTraceIDsBase(const QStringList &iList, const Qt::CheckState &iCheck)
Change elements highlighting property given a list of TraceIDs and the new status.
unsigned int GetCollectionIDOfGivenTraceID(unsigned int iTraceID)
Get the CollectionID given a TraceID.
void SetScalarRangeForAllElements(const double &iMin, const double &iMax)
Set the scalar range.
std::vector< vtkActor * > AddContour(vtkPolyData *iDataset, vtkProperty *iProperty=NULL)
Add contour with given property into the visualization.
void Insert(const MultiIndexContainerElementType &iE)
Insert one element in the container.
change_visible(const bool &iVisibile)
TContainer MultiIndexContainerType
void UpdateVisualizationForGivenIDs(TList iList)
Update Visualization of the given TraceIDs.
virtual ~TraceContainerBase()
Destructor.
vtkProperty * m_HighlightedProperty
std::vector< vtkActor * > GetActorGivenTraceID(unsigned int iTraceID)
vtkProperty * GetHighlightedProperty()
Get property for highlighted traces.
MultiIndexContainerType::template index< Highlighted >::type::iterator MultiIndexContainerHighlightedIterator
class for the visualization of 3D Image represented by one vtkImageData*.
virtual void RemoveActor(const int &iId, vtkActor *iActor)
std::list< unsigned int > GetHighlightedElementsTraceID()
Get the list of highlighted elements TraceID.
void UpdateCurrentElementCollection(unsigned int iCollectionID)
void operator()(T &iStructure)
Generic interface for trace container. More specific container should inherit from this class and get...
void UpdateVisualizationForGivenElement(typename MultiIndexContainerType::template index< TIndex >::type::iterator &iIt, std::vector< vtkActor * > iActors, const bool &iHighlighted, const bool &iVisible)
Update Actors, Highlighted, Visibility (properties) of given a element.
bool UpdateElementVisibilityWithGivenTraceID(const unsigned int &iId)
Update element visibility given it TraceId.
virtual bool DeleteElement(const unsigned int &iId)=0
Remove the element which TraceId = iId.
bool UpdateCurrentElementFromExistingOne(typename MultiIndexContainerType::template index< TIndex >::type::iterator iIt)
virtual void UpdateElementVisibilityWithGivenTraceIDsBase(const QStringList &iList, const Qt::CheckState &iCheck)
Change elements visibility property given a list of TraceIDs and the new status.
MultiIndexContainerType::template index< Visible >::type::iterator MultiIndexContainerVisibleIterator
virtual void AddActor(const int &iId, vtkActor *iActor)
void operator()(T &iStructure)
QGoImageView3D * m_ImageView
Link to the visualization.
void Print(TIterator iBegin, TIterator iEnd)
Print the container content in the application output.
void ResetCurrentElement()
Reset Current Element to a default state.
MultiIndexContainerElementType m_CurrentElement
Current Element of the trace type.
void SetHighlightedProperty(vtkProperty *iProperty)
Set property whenever the trace is highlighted.
MultiIndexContainerType::template index< CollectionID >::type::iterator MultiIndexContainerCollectionIDIterator
change_actors(std::vector< vtkActor * > &iActors)
void SetIntersectionLineWidth(const float &iWidth)
TraceContainerBase(QObject *iParent, QGoImageView3D *iView)
Constructor.
void UpdateCurrentElementFromVisuBase(std::vector< vtkActor * > &iActors, vtkPolyData *iNodes, const bool &iHighlighted, const bool &iVisible)
float m_IntersectionLineWidth
void SetLookupTableForColorCoding(vtkLookupTable *iLut)
Apply the given lookup table to all traces in the container.
void UpdateElementHighlightingWithTraceID(const unsigned int &oTraceId, Qt::CheckState &oState)
Update highlighting property of one element given one actor.
void operator()(T &iStructure)
void RenderAllElementsWithOriginalColors()
Render with original colors.
void SetColorCode(const std::string &iColumnName, const std::map< unsigned int, TValue > &iValues)
Color code contour / mesh according to values provided.
std::list< vtkPolyData * > GetHighlightedElements()
Get all highlighted elements by pair<ID, Polydata>.
void SetRandomColor(const std::string &iColumnName, const std::map< unsigned int, unsigned int > &iIds)
change_color(QColor iColor)
void InsertCurrentElement()
Insert Current Element in the container.
bool UpdateElementHighlightingWithGivenTraceID(const unsigned int &iId)
Update element highlighting given it TraceId.