Commit 6acf681a authored by Emmanuel Promayon's avatar Emmanuel Promayon
Browse files

FIXED cell vector data specific representation

Now fully functionnal feature
parent 97d8b40c
......@@ -65,32 +65,32 @@
namespace camitk {
// -------------------- constructor --------------------
MeshComponent::MeshComponent ( const QString& file ) throw ( AbortException ) : Component ( file, "Mesh", Component::GEOMETRY ) {
MeshComponent::MeshComponent(const QString& file) throw (AbortException) : Component(file, "Mesh", Component::GEOMETRY) {
init();
}
MeshComponent::MeshComponent ( vtkSmartPointer<vtkPointSet> aPointSet, const QString& name ) : Component ( "", name, Component::GEOMETRY ) {
MeshComponent::MeshComponent(vtkSmartPointer<vtkPointSet> aPointSet, const QString& name) : Component("", name, Component::GEOMETRY) {
init();
initRepresentation ( aPointSet );
initRepresentation(aPointSet);
setModified();
}
MeshComponent::MeshComponent ( Component* parentComponent, vtkSmartPointer<vtkPointSet> aPointSet, const QString& name ) : Component ( parentComponent, name, Component::GEOMETRY ) {
MeshComponent::MeshComponent(Component* parentComponent, vtkSmartPointer<vtkPointSet> aPointSet, const QString& name) : Component(parentComponent, name, Component::GEOMETRY) {
init();
initRepresentation ( aPointSet );
initRepresentation(aPointSet);
}
// -------------------- destructor --------------------
MeshComponent::~MeshComponent() {
if ( getPointSet() != NULL ) {
if (getPointSet() != NULL) {
setDataRepresentationOff();
}
if ( selectionWidget != nullptr ) {
if (selectionWidget != nullptr) {
delete selectionWidget;
}
if ( dataWidget != nullptr ) {
if (dataWidget != nullptr) {
delete dataWidget;
}
}
......@@ -104,121 +104,121 @@ void MeshComponent::init() {
// selection widget
selectionWidget = new QWidget();
selectionWidget->setObjectName ( "Selection" );
selectionWidget->setObjectName("Selection");
// selection actions
removeSelections = new QAction ( QPixmap ( ":/delete" ), tr ( "Remove selection(s)" ), this );
removeSelections->setStatusTip ( tr ( "Remove the selected selections" ) );
removeSelections->setWhatsThis ( tr ( "Remove the selected selections" ) );
connect ( removeSelections, SIGNAL ( triggered() ), this, SLOT ( removeSelectedSelections() ) );
removeSelections = new QAction(QPixmap(":/delete"), tr("Remove selection(s)"), this);
removeSelections->setStatusTip(tr("Remove the selected selections"));
removeSelections->setWhatsThis(tr("Remove the selected selections"));
connect(removeSelections, SIGNAL(triggered()), this, SLOT(removeSelectedSelections()));
inspectSelection = new QAction ( QPixmap ( ":/settings" ), tr ( "Inspect the selection" ), this );
inspectSelection->setStatusTip ( tr ( "Inspect the selection" ) );
inspectSelection->setWhatsThis ( tr ( "Inspect the selection" ) );
inspectSelection = new QAction(QPixmap(":/settings"), tr("Inspect the selection"), this);
inspectSelection->setStatusTip(tr("Inspect the selection"));
inspectSelection->setWhatsThis(tr("Inspect the selection"));
mergeSelection = new QAction ( QPixmap ( ":/refresh" ), tr ( "Merge the selections" ), this );
mergeSelection->setStatusTip ( tr ( "Merge the selected selection" ) );
mergeSelection->setWhatsThis ( tr ( "Merge the selected delections (selection types must be identical)" ) );
mergeSelection = new QAction(QPixmap(":/refresh"), tr("Merge the selections"), this);
mergeSelection->setStatusTip(tr("Merge the selected selection"));
mergeSelection->setWhatsThis(tr("Merge the selected delections (selection types must be identical)"));
// selection model
selectionModel = new MeshSelectionModel ( this );
selectionModel = new MeshSelectionModel(this);
// selection view
selectionView = new MeshSelectionView ( selectionWidget );
selectionView->setSelectionBehavior ( QAbstractItemView::SelectRows );
selectionView->setModel ( selectionModel );
selectionView->setSelectionMode ( QAbstractItemView::ExtendedSelection );
selectionView->setEditTriggers ( QAbstractItemView::DoubleClicked );
selectionView = new MeshSelectionView(selectionWidget);
selectionView->setSelectionBehavior(QAbstractItemView::SelectRows);
selectionView->setModel(selectionModel);
selectionView->setSelectionMode(QAbstractItemView::ExtendedSelection);
selectionView->setEditTriggers(QAbstractItemView::DoubleClicked);
// if the selection changes, the meshComponent needs to be notified
connect ( selectionView->selectionModel(), SIGNAL ( selectionChanged ( const QItemSelection&, const QItemSelection& ) ), this, SLOT ( changeSelectedSelection ( const QItemSelection&, const QItemSelection& ) ) );
connect(selectionView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), this, SLOT(changeSelectedSelection(const QItemSelection&, const QItemSelection&)));
insertionPolicyBox = new QComboBox ( selectionView );
insertionPolicyBox->setStatusTip ( tr ( "Insertion policy" ) );
insertionPolicyBox->setWhatsThis ( tr ( "Insertion policy" ) );
insertionPolicyBox->addItem ( "Replace", MeshSelectionModel::REPLACE );
insertionPolicyBox->addItem ( "Merge", MeshSelectionModel::MERGE );
insertionPolicyBox->addItem ( "Substract", MeshSelectionModel::SUBSTRACT );
insertionPolicyBox->addItem ( "Discard", MeshSelectionModel::DISCARD );
insertionPolicyBox = new QComboBox(selectionView);
insertionPolicyBox->setStatusTip(tr("Insertion policy"));
insertionPolicyBox->setWhatsThis(tr("Insertion policy"));
insertionPolicyBox->addItem("Replace", MeshSelectionModel::REPLACE);
insertionPolicyBox->addItem("Merge", MeshSelectionModel::MERGE);
insertionPolicyBox->addItem("Substract", MeshSelectionModel::SUBSTRACT);
insertionPolicyBox->addItem("Discard", MeshSelectionModel::DISCARD);
// build the selection widget
QVBoxLayout* hbox = new QVBoxLayout ( selectionWidget );
QToolBar* selectionToolBar = new QToolBar ( selectionWidget );
selectionToolBar->addAction ( removeSelections );
selectionToolBar->addAction ( mergeSelection );
selectionToolBar->addAction ( inspectSelection );
selectionToolBar->addWidget ( insertionPolicyBox );
hbox->addWidget ( selectionView );
hbox->addWidget ( selectionToolBar );
selectionWidget->setLayout ( hbox );
QVBoxLayout* hbox = new QVBoxLayout(selectionWidget);
QToolBar* selectionToolBar = new QToolBar(selectionWidget);
selectionToolBar->addAction(removeSelections);
selectionToolBar->addAction(mergeSelection);
selectionToolBar->addAction(inspectSelection);
selectionToolBar->addWidget(insertionPolicyBox);
hbox->addWidget(selectionView);
hbox->addWidget(selectionToolBar);
selectionWidget->setLayout(hbox);
// data widget
dataWidget = new QWidget();
dataWidget->setObjectName ( "Data" );
dataWidget->setObjectName("Data");
// selection actions
removeData = new QAction ( QPixmap ( ":/delete" ), tr ( "Remove data" ), this );
removeData->setStatusTip ( tr ( "Remove the selected data" ) );
removeData->setWhatsThis ( tr ( "Remove the selected data" ) );
connect ( removeData, SIGNAL ( triggered() ), this, SLOT ( removeSelectedData() ) );
removeData = new QAction(QPixmap(":/delete"), tr("Remove data"), this);
removeData->setStatusTip(tr("Remove the selected data"));
removeData->setWhatsThis(tr("Remove the selected data"));
connect(removeData, SIGNAL(triggered()), this, SLOT(removeSelectedData()));
inspectData = new QAction ( QPixmap ( ":/settings" ), tr ( "Inspect data" ), this );
inspectData->setStatusTip ( tr ( "Inspect data" ) );
inspectData->setWhatsThis ( tr ( "Inspect data" ) );
inspectData->setEnabled ( false ); // TODO implement a data inspector widget
inspectData = new QAction(QPixmap(":/settings"), tr("Inspect data"), this);
inspectData->setStatusTip(tr("Inspect data"));
inspectData->setWhatsThis(tr("Inspect data"));
inspectData->setEnabled(false); // TODO implement a data inspector widget
// data model
dataModel = new MeshDataModel ( this );
dataModel = new MeshDataModel(this);
// data view
dataView = new MeshDataView();
dataView->setSelectionBehavior ( QAbstractItemView::SelectRows );
dataView->setModel ( dataModel );
dataView->setSelectionMode ( QAbstractItemView::ExtendedSelection );
dataView->setSelectionBehavior(QAbstractItemView::SelectRows);
dataView->setModel(dataModel);
dataView->setSelectionMode(QAbstractItemView::ExtendedSelection);
displayTypePolicyBox = new QComboBox ( dataView );
displayTypePolicyBox->setStatusTip ( tr ( "Display type policy for 3D data" ) );
displayTypePolicyBox->setWhatsThis ( tr ( "Display type policy for 3D data" ) );
displayTypePolicyBox->addItem ( "3D Vector", HEDGE_HOG );
displayTypePolicyBox->addItem ( "Norm", NORM );
displayTypePolicyBox->addItem ( "1st Component", FIRST_COMPONENT );
displayTypePolicyBox->addItem ( "2nd Component", SECOND_COMPONENT );
displayTypePolicyBox->addItem ( "3nd Component", THIRD_COMPONENT );
displayTypePolicyBox = new QComboBox(dataView);
displayTypePolicyBox->setStatusTip(tr("Display type policy for 3D data"));
displayTypePolicyBox->setWhatsThis(tr("Display type policy for 3D data"));
displayTypePolicyBox->addItem("3D Vector", HEDGE_HOG);
displayTypePolicyBox->addItem("Norm", NORM);
displayTypePolicyBox->addItem("1st Component", FIRST_COMPONENT);
displayTypePolicyBox->addItem("2nd Component", SECOND_COMPONENT);
displayTypePolicyBox->addItem("3nd Component", THIRD_COMPONENT);
connect ( displayTypePolicyBox, SIGNAL ( currentIndexChanged ( int ) ), this, SLOT ( displayTypePolicyChanged ( int ) ) );
connect(displayTypePolicyBox, SIGNAL(currentIndexChanged(int)), this, SLOT(displayTypePolicyChanged(int)));
// build the data widget
QVBoxLayout* dataBox = new QVBoxLayout ( dataWidget );
QToolBar* dataToolBar = new QToolBar ( dataWidget );
dataToolBar->addAction ( removeData );
dataToolBar->addAction ( inspectData );
dataToolBar->addWidget ( displayTypePolicyBox );
dataBox->addWidget ( dataView );
dataBox->addWidget ( dataToolBar );
dataWidget->setLayout ( dataBox );
QVBoxLayout* dataBox = new QVBoxLayout(dataWidget);
QToolBar* dataToolBar = new QToolBar(dataWidget);
dataToolBar->addAction(removeData);
dataToolBar->addAction(inspectData);
dataToolBar->addWidget(displayTypePolicyBox);
dataBox->addWidget(dataView);
dataBox->addWidget(dataToolBar);
dataWidget->setLayout(dataBox);
}
// -------------------- initRepresentation --------------------
void MeshComponent::initRepresentation ( vtkSmartPointer<vtkPointSet> originalPointSet ) {
void MeshComponent::initRepresentation(vtkSmartPointer<vtkPointSet> originalPointSet) {
// if there is no point set yet, just do nothing
if ( originalPointSet == NULL ) {
if (originalPointSet == NULL) {
return;
}
// else replace the point set
if ( myGeometry ) {
myGeometry->setPointSet ( originalPointSet );
if (myGeometry) {
myGeometry->setPointSet(originalPointSet);
}
else {
myGeometry = new Geometry ( this->getName(), originalPointSet );
myGeometry = new Geometry(this->getName(), originalPointSet);
}
myGeometry->setMeshWorldTransform ( getTransformFromWorld() );
myGeometry->setMeshWorldTransform(getTransformFromWorld());
// add it in the InteractiveViewer (automatically)
setVisibility ( InteractiveViewer::get3DViewer(), true );
setVisibility(InteractiveViewer::get3DViewer(), true);
// initialize selection
initSelection();
......@@ -236,20 +236,20 @@ void MeshComponent::initSelection() {
vtkSmartPointer<vtkActor> selectionActor = vtkSmartPointer<vtkActor>::New();
vtkSmartPointer<vtkDataSetMapper> selectionMapper = vtkSmartPointer<vtkDataSetMapper>::New();
selectionExtractor->SetInputConnection ( 0, this->getDataPort() );
selectionExtractor->SetInputData ( 1, currentSelection );
selectionExtractor->SetInputConnection(0, this->getDataPort());
selectionExtractor->SetInputData(1, currentSelection);
selectionMapper->SetInputConnection ( selectionExtractor->GetOutputPort() );
selectionMapper->SetInputConnection(selectionExtractor->GetOutputPort());
selectionActor->SetPickable ( false );
selectionActor->SetPickable(false);
selectionActor->GetProperty()->SetRepresentationToSurface();
selectionActor->GetProperty()->SetLineWidth ( 5 );
selectionActor->GetProperty()->SetColor ( 1, 0, 0 );
selectionActor->GetProperty()->SetPointSize ( 10 );
selectionActor->GetProperty()->SetOpacity ( 0.2 );
selectionActor->SetMapper ( selectionMapper );
selectionActor->GetProperty()->SetLineWidth(5);
selectionActor->GetProperty()->SetColor(1, 0, 0);
selectionActor->GetProperty()->SetPointSize(10);
selectionActor->GetProperty()->SetOpacity(0.2);
selectionActor->SetMapper(selectionMapper);
addProp ( "Selection", selectionActor );
addProp("Selection", selectionActor);
}
// -------------------- initData --------------------
......@@ -258,12 +258,12 @@ void MeshComponent::initData() {
}
// -------------------- cellPicked --------------------
void MeshComponent::cellPicked ( vtkIdType cellId, bool ) {
void MeshComponent::cellPicked(vtkIdType cellId, bool) {
pickedCellId = cellId;
}
// -------------------- pointPicked --------------------
void MeshComponent::pointPicked ( vtkIdType pointId, bool ) {
void MeshComponent::pointPicked(vtkIdType pointId, bool) {
pickedPointId = pointId;
}
......@@ -281,33 +281,33 @@ vtkIdType MeshComponent::getPickedPointId() {
void MeshComponent::initDynamicProperties() {
vtkIdType count = 0;
if ( getPointSet() != NULL ) {
if (getPointSet() != NULL) {
count = getPointSet()->GetNumberOfPoints();
}
Property* nbPoints = new Property ( "Number Of Points", QVariant ( QString ( "%1" ).arg ( count ) ), "Number of 3D Points composing the geometry", "" );
nbPoints->setReadOnly ( true );
addProperty ( nbPoints );
Property* nbPoints = new Property("Number Of Points", QVariant(QString("%1").arg(count)), "Number of 3D Points composing the geometry", "");
nbPoints->setReadOnly(true);
addProperty(nbPoints);
if ( getPointSet() != NULL ) {
if (getPointSet() != NULL) {
count = getPointSet()->GetNumberOfCells();
}
Property* nbCells = new Property ( "Number Of Cells", QVariant ( QString ( "%1" ).arg ( count ) ), "Number of Cells composing the geometry", "" );
nbCells->setReadOnly ( true );
addProperty ( nbCells );
Property* nbCells = new Property("Number Of Cells", QVariant(QString("%1").arg(count)), "Number of Cells composing the geometry", "");
nbCells->setReadOnly(true);
addProperty(nbCells);
if ( getPointSet() != NULL ) {
if (getPointSet() != NULL) {
// add a dynamic property to manage the surface color
// setProperty("position point #1", QVector3D(1.0,0.0,0.0));
vtkSmartPointer<vtkGenericCell> cell = vtkGenericCell::New();
std::map<unsigned char, int> elementsMap;
std::map<unsigned char, int>::iterator elementsMapIt;
for ( int i = 0; i < getPointSet()->GetNumberOfCells(); i++ ) {
getPointSet()->GetCell ( i, cell );
for (int i = 0; i < getPointSet()->GetNumberOfCells(); i++) {
getPointSet()->GetCell(i, cell);
if ( !elementsMap.count ( cell->GetCellType() ) ) {
if (!elementsMap.count(cell->GetCellType())) {
elementsMap[ cell->GetCellType()] = 0;
}
......@@ -316,97 +316,97 @@ void MeshComponent::initDynamicProperties() {
}
// the list of all possible cell types is defined in VTKCellType enum of the VTKCellType class
for ( elementsMapIt = elementsMap.begin(); elementsMapIt != elementsMap.end(); elementsMapIt++ ) {
for (elementsMapIt = elementsMap.begin(); elementsMapIt != elementsMap.end(); elementsMapIt++) {
Property* cellProp;
switch ( elementsMapIt->first ) {
switch (elementsMapIt->first) {
case VTK_EMPTY_CELL:
cellProp = new Property ( "Empty Cells", elementsMapIt->second, tr ( "Number Of Empty Cells" ), "" );
cellProp = new Property("Empty Cells", elementsMapIt->second, tr("Number Of Empty Cells"), "");
break;
case VTK_VERTEX:
cellProp = new Property ( "Vertex", elementsMapIt->second, tr ( "Number Of Vertex Cells" ), "" );
cellProp = new Property("Vertex", elementsMapIt->second, tr("Number Of Vertex Cells"), "");
break;
case VTK_POLY_VERTEX:
cellProp = new Property ( "Edges", elementsMapIt->second, tr ( "Number Of Edge Cells" ), "" );
cellProp = new Property("Edges", elementsMapIt->second, tr("Number Of Edge Cells"), "");
break;
case VTK_LINE :
cellProp = new Property ( "Lines", elementsMapIt->second, tr ( "Number Of Line Cells" ), "" );
cellProp = new Property("Lines", elementsMapIt->second, tr("Number Of Line Cells"), "");
break;
case VTK_POLY_LINE:
cellProp = new Property ( "Polylines", elementsMapIt->second, tr ( "Number Of Polylines Cells" ), "" );
cellProp = new Property("Polylines", elementsMapIt->second, tr("Number Of Polylines Cells"), "");
break;
case VTK_TRIANGLE :
cellProp = new Property ( "Triangles", elementsMapIt->second, tr ( "Number Of Triangle Cells" ), "" );
cellProp = new Property("Triangles", elementsMapIt->second, tr("Number Of Triangle Cells"), "");
break;
case VTK_TRIANGLE_STRIP:
cellProp = new Property ( "Triangle Strips", elementsMapIt->second, tr ( "Number Of Triangle Strip Cells" ), "" );
cellProp = new Property("Triangle Strips", elementsMapIt->second, tr("Number Of Triangle Strip Cells"), "");
break;
case VTK_POLYGON:
cellProp = new Property ( "Polygons", elementsMapIt->second, tr ( "Number Of Polygon Cells" ), "" );
cellProp = new Property("Polygons", elementsMapIt->second, tr("Number Of Polygon Cells"), "");
break;
case VTK_PIXEL:
cellProp = new Property ( "Pixels", elementsMapIt->second, tr ( "Number Of Pixel Cells" ), "" );
cellProp = new Property("Pixels", elementsMapIt->second, tr("Number Of Pixel Cells"), "");
break;
case VTK_QUAD:
cellProp = new Property ( "Quads", elementsMapIt->second, tr ( "Number Of Quad Cells" ), "" );
cellProp = new Property("Quads", elementsMapIt->second, tr("Number Of Quad Cells"), "");
break;
case VTK_TETRA :
cellProp = new Property ( "Tetrahedra", elementsMapIt->second, tr ( "Number Of Tetrahedral Cells" ), "" );
cellProp = new Property("Tetrahedra", elementsMapIt->second, tr("Number Of Tetrahedral Cells"), "");
break;
case VTK_VOXEL:
cellProp = new Property ( "Voxels", elementsMapIt->second, tr ( "Number Of Voxel Cells" ), "" );
cellProp = new Property("Voxels", elementsMapIt->second, tr("Number Of Voxel Cells"), "");
break;
case VTK_HEXAHEDRON :
cellProp = new Property ( "Hexahedra", elementsMapIt->second, tr ( "Number Of Hexahedral Cells" ), "" );
cellProp = new Property("Hexahedra", elementsMapIt->second, tr("Number Of Hexahedral Cells"), "");
break;
case VTK_WEDGE :
cellProp = new Property ( "Wedges", elementsMapIt->second, tr ( "Number Of Wedge Cells" ), "" );
cellProp = new Property("Wedges", elementsMapIt->second, tr("Number Of Wedge Cells"), "");
break;
case VTK_PYRAMID :
cellProp = new Property ( "Pyramids", elementsMapIt->second, tr ( "Number Of Pyramid Cells" ), "" );
cellProp = new Property("Pyramids", elementsMapIt->second, tr("Number Of Pyramid Cells"), "");
break;
case VTK_PENTAGONAL_PRISM:
cellProp = new Property ( "Pentagonal Prisms", elementsMapIt->second, tr ( "Number Of Pentagonal Prism Cells" ), "" );
cellProp = new Property("Pentagonal Prisms", elementsMapIt->second, tr("Number Of Pentagonal Prism Cells"), "");
break;
case VTK_HEXAGONAL_PRISM:
cellProp = new Property ( "Hexagonal Prisms", elementsMapIt->second, tr ( "Number Of Hexagonal Prism Cells" ), "" );
cellProp = new Property("Hexagonal Prisms", elementsMapIt->second, tr("Number Of Hexagonal Prism Cells"), "");
break;
default:
cellProp = new Property ( "Others", elementsMapIt->second, tr ( "Number Of <i>Other Type Of Cells</i>. <br/>It can be quadratic isoparametric cells, Cubic isoparametric cells, <br/>convex group of points, higher order cells in parametric form, <br/>higher order cells (see VTKCellType enum for more information)" ), "" );
cellProp = new Property("Others", elementsMapIt->second, tr("Number Of <i>Other Type Of Cells</i>. <br/>It can be quadratic isoparametric cells, Cubic isoparametric cells, <br/>convex group of points, higher order cells in parametric form, <br/>higher order cells (see VTKCellType enum for more information)"), "");
break;
}
cellProp->setReadOnly ( true );
addProperty ( cellProp );
cellProp->setReadOnly(true);
addProperty(cellProp);
}
}
unsigned long memUsage = 0;
if ( getPointSet() != NULL ) {
if (getPointSet() != NULL) {
memUsage = getPointSet()->GetActualMemorySize();
}
Property* memoryUsage = new Property ( "Size In Memory", QVariant ( QString ( "%1" ).arg ( memUsage ) ), tr ( "Actual size of the data in kilobytes. <br/>This number is valid only after the pipeline has updated. <br/>The memory size returned is guaranteed to be greater than or <br/>equal to the memory required to represent the data<br/> (e.g., extra space in arrays, etc. are not included in the return value)." ), "Kb" );
memoryUsage->setReadOnly ( true );
addProperty ( memoryUsage );
Property* memoryUsage = new Property("Size In Memory", QVariant(QString("%1").arg(memUsage)), tr("Actual size of the data in kilobytes. <br/>This number is valid only after the pipeline has updated. <br/>The memory size returned is guaranteed to be greater than or <br/>equal to the memory required to represent the data<br/> (e.g., extra space in arrays, etc. are not included in the return value)."), "Kb");
memoryUsage->setReadOnly(true);
addProperty(memoryUsage);
}
// -------------------- getSelections --------------------
......@@ -425,11 +425,11 @@ vtkSmartPointer<vtkSelection> MeshComponent::getActiveSelection() const {
}
// -------------------- getSelection --------------------
vtkSmartPointer< vtkSelectionNode > MeshComponent::getSelection ( const QString& name ) const {
int indexOfSelection = getSelectionIndex ( name );
vtkSmartPointer< vtkSelectionNode > MeshComponent::getSelection(const QString& name) const {
int indexOfSelection = getSelectionIndex(name);
if ( indexOfSelection >= 0 && indexOfSelection < selectionList.size() ) {
return getSelectionAt ( indexOfSelection );
if (indexOfSelection >= 0 && indexOfSelection < selectionList.size()) {
return getSelectionAt(indexOfSelection);
}
else {
return NULL;
......@@ -437,18 +437,18 @@ vtkSmartPointer< vtkSelectionNode > MeshComponent::getSelection ( const QString&
}
// -------------------- getSelectionAt --------------------
vtkSmartPointer< vtkSelectionNode > MeshComponent::getSelectionAt ( unsigned int index ) const {
return selectionList.at ( index );
vtkSmartPointer< vtkSelectionNode > MeshComponent::getSelectionAt(unsigned int index) const {
return selectionList.at(index);
}
// -------------------- getSelectionIndex --------------------
int MeshComponent::getSelectionIndex ( const QString& name ) const {
int MeshComponent::getSelectionIndex(const QString& name) const {
QList< vtkSmartPointer< vtkSelectionNode > >::const_iterator it = selectionList.constBegin();
int index = 0;
bool found = false;
while ( it != selectionList.end() && !found ) {
if ( ( *it )->GetSelectionList() && !QString::compare ( QString ( ( *it )->GetSelectionList()->GetName() ), name ) ) {
while (it != selectionList.end() && !found) {
if ((*it)->GetSelectionList() && !QString::compare(QString((*it)->GetSelectionList()->GetName()), name)) {
found = true;
}
else {
......@@ -457,7 +457,7 @@ int MeshComponent::getSelectionIndex ( const QString& name ) const {
}
}
if ( found ) {
if (found) {
return index;
}
else {
......@@ -466,40 +466,40 @@ int MeshComponent::getSelectionIndex ( const QString& name ) const {
}
// -------------------- addSelection --------------------
int MeshComponent::addSelection ( const QString& name, int fieldType, int contentType, vtkSmartPointer< vtkAbstractArray > array, MeshSelectionModel::InsertionPolicy policy ) {
int index = selectionModel->insertSelection ( name, fieldType, contentType, array, policy );
int MeshComponent::addSelection(const QString& name, int fieldType, int contentType, vtkSmartPointer< vtkAbstractArray > array, MeshSelectionModel::InsertionPolicy policy) {
int index = selectionModel->insertSelection(name, fieldType, contentType, array, policy);
return index;
}
// -------------------- addToSelectedSelection --------------------
int MeshComponent::addToSelectedSelection ( int fieldType, int contentType, vtkSmartPointer< vtkAbstractArray > array, MeshSelectionModel::InsertionPolicy policy ) {
int MeshComponent::addToSelectedSelection(int fieldType, int contentType, vtkSmartPointer< vtkAbstractArray > array, MeshSelectionModel::InsertionPolicy policy) {
// use the current index to handle the case of multiple selection
int index = selectionView->selectionModel()->currentIndex().row();
// TODO : for now, we don't care about the policy parameter and use the one of the combo box
// but in the future, the policy should be selected by pressing modifiers keys
policy = ( MeshSelectionModel::InsertionPolicy ) insertionPolicyBox->itemData ( insertionPolicyBox->currentIndex() ).toInt();
policy = (MeshSelectionModel::InsertionPolicy) insertionPolicyBox->itemData(insertionPolicyBox->currentIndex()).toInt();
// check if the current selection is selected (maybe it is not necessary ...)
if ( selectionView->selectionModel()->isRowSelected ( index, QModelIndex() ) ) {
index = addSelection ( selectionList.at ( index )->GetSelectionList()->GetName(), fieldType, contentType, array, policy );
if (selectionView->selectionModel()->isRowSelected(index, QModelIndex())) {
index = addSelection(selectionList.at(index)->GetSelectionList()->GetName(), fieldType, contentType, array, policy);
}
else {
index = addSelection ( "Picked Selection", fieldType, contentType, array, policy );
index = addSelection("Picked Selection", fieldType, contentType, array, policy);
}
// forced clearing even if the selected index stay the same
// if not, display will not be updated
selectionView->clearSelection();
// select the added selection and set the current index
selectionView->selectionModel()->setCurrentIndex ( selectionModel->index ( index, 0, QModelIndex() ), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows );
selectionView->selectionModel()->setCurrentIndex(selectionModel->index(index, 0, QModelIndex()), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
return index;
}
// -------------------- changeSelectedSelection --------------------
// TODO : rename updateSelection
void MeshComponent::changeSelectedSelection ( const QItemSelection& selected, const QItemSelection& deselected ) {
void MeshComponent::changeSelectedSelection(const QItemSelection& selected, const QItemSelection& deselected) {
// remove all the selection nodes from the selection
currentSelection->RemoveAllNodes();
......@@ -509,14 +509,14 @@ void MeshComponent::changeSelectedSelection ( const QItemSelection& selected, co
QModelIndexList items = selectionView->selectionModel()->selectedRows();
// Select the PropertyExplorer 'Selection' tab for the currently selected component