Commit 4004b1cc authored by Emmanuel Promayon's avatar Emmanuel Promayon
Browse files

FIXED stretch columns to automatically show all the names

parent c5bd334d
......@@ -61,6 +61,8 @@
#include <vtkSphereSource.h>
#include <vtkCellCenters.h>
#include <vtkDoubleArray.h>
#include <vtkArrowSource.h>
#include <vtkGlyph3D.h>
namespace camitk {
......@@ -179,7 +181,7 @@ void MeshComponent::init() {
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("3D Vector", VECTOR_3D);
displayTypePolicyBox->addItem("Norm", NORM);
displayTypePolicyBox->addItem("1st Component", FIRST_COMPONENT);
displayTypePolicyBox->addItem("2nd Component", SECOND_COMPONENT);
......@@ -572,100 +574,134 @@ void MeshComponent::createDataRepresentation(FieldType field, const QString& nam
// nothing to do, scalar data already preseng in the array and representation managed by the mapper
break;
case VECTORS:
switch (representation) {
case HEDGE_HOG: {
if (representation == VECTOR_3D) {
if (vectorRepresentation == HEDGE_HOG) {
// add the corresponding prop, but not visible
vtkSmartPointer<vtkHedgeHog> hedgeHog = vtkSmartPointer<vtkHedgeHog>::New();
vtkSmartPointer<vtkDataSetMapper> dataMapper = vtkSmartPointer< vtkDataSetMapper >::New();
vtkSmartPointer<vtkActor> dataActor = vtkSmartPointer< vtkActor >::New();
if (field == POINTS) {
hedgeHog->SetInputConnection(myGeometry->getDataPort());
hedgeHog->SetInputConnection(getDataPort());
hedgeHog->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, name.toUtf8().constData());
}
else
if (field == CELLS) {
vtkSmartPointer<vtkCellCenters> cellCentersFilter = vtkSmartPointer<vtkCellCenters>::New();
cellCentersFilter->SetInputConnection(myGeometry->getDataPort());
cellCentersFilter->SetInputConnection(getDataPort());
hedgeHog->SetInputConnection(cellCentersFilter->GetOutputPort());
hedgeHog->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_CELLS, name.toUtf8().constData());
}
hedgeHog->SetScaleFactor(getBoundingRadius() / 10.0);
dataMapper->SetInputConnection(hedgeHog->GetOutputPort());
dataActor->SetMapper(dataMapper);
dataActor->GetProperty()->SetColor(0, 1, 0);
dataActor->GetProperty()->SetColor(0.0, 0.7, 0.0);
dataActor->VisibilityOff();
addProp(getDataPropName(field, name), dataActor);
}
break;
default: {
// create 1D representation
QString specificName(name + getSpecificRepresentationName(representation));
vtkSmartPointer<vtkDoubleArray> dataArrayToDisplay = vtkSmartPointer<vtkDoubleArray>::New();
dataArrayToDisplay->SetName(specificName.toUtf8().constData());
int numberOfValues;
else {
// representation as ARROW
// add the corresponding prop, but not visible
vtkSmartPointer<vtkDataSetMapper> dataMapper = vtkSmartPointer< vtkDataSetMapper >::New();
vtkSmartPointer<vtkActor> dataActor = vtkSmartPointer< vtkActor >::New();
vtkSmartPointer<vtkArrowSource> arrowSource = vtkSmartPointer<vtkArrowSource>::New();
vtkSmartPointer<vtkGlyph3D> arrowGlyph = vtkSmartPointer<vtkGlyph3D>::New();
arrowGlyph->ScalingOn();
//arrowGlyph->SetScaleFactor(getBoundingRadius() / 10.0);
//arrowGlyph->SetScaleFactor(getBoundingRadius() / 10.0);
arrowGlyph->SetScaleModeToScaleByVector();
//arrowGlyph->SetScaleModeToDataScalingOff();
//arrowGlyph->ScalingOff();
arrowGlyph->SetVectorModeToUseVector();
//arrowGlyph->OrientOn();
arrowGlyph->SetSourceConnection(arrowSource->GetOutputPort());
// Next line should be able to color the arrow depending on the field,
// but the color LUT is inversed, so comment for now
// arrowGlyph->SetColorModeToColorByScalar();
if (field == POINTS) {
numberOfValues = getPointSet()->GetNumberOfPoints();
}
else {
// this is cell field
numberOfValues = getPointSet()->GetNumberOfCells();
arrowGlyph->SetInputConnection(getDataPort());
}
// fill the data array
dataArrayToDisplay->SetNumberOfValues(numberOfValues);
// use the representation flag to tranform the point's 3D vector to a scalar
for (vtkIdType i = 0; i < numberOfValues; ++i) {
double val[3];
dataArray->GetTuple(i, val);
switch (representation) {
case FIRST_COMPONENT:
dataArrayToDisplay->SetValue(i, val[0]);
break;
case SECOND_COMPONENT:
dataArrayToDisplay->SetValue(i, val[1]);
break;
case THIRD_COMPONENT:
dataArrayToDisplay->SetValue(i, val[2]);
break;
case NORM:
default:
// compute 3D norm
dataArrayToDisplay->SetValue(i, sqrt(val[0]*val[0] + val[1]*val[1] + val[2]*val[2]));
break;
else
if (field == CELLS) {
vtkSmartPointer<vtkCellCenters> cellCentersFilter = vtkSmartPointer<vtkCellCenters>::New();
cellCentersFilter->SetInputConnection(getDataPort());
arrowGlyph->SetInputConnection(cellCentersFilter->GetOutputPort());
}
}
dataMapper->SetInputConnection(arrowGlyph->GetOutputPort());
dataActor->SetMapper(dataMapper);
dataActor->GetProperty()->SetColor(0, 1, 0);
dataActor->VisibilityOff();
addProp(getDataPropName(field, name), dataActor);
}
}
else {
// create 1D representation
QString specificName(name + getSpecificRepresentationName(representation));
vtkSmartPointer<vtkDoubleArray> dataArrayToDisplay = vtkSmartPointer<vtkDoubleArray>::New();
dataArrayToDisplay->SetName(specificName.toUtf8().constData());
int numberOfValues;
// add it to the pointset field data directly, but NOT to the mesh component (it will stay hidden)
getFieldData(field)->AddArray(dataArrayToDisplay);
// insert it in the specific map
specific3DDataRepresentation.insert(specificName, dataArrayToDisplay);
// update the cell specific representation counter so that getNumberOfDataArray answer is up-to-date
if (field == CELLS) {
numberOfCellDataSpecificRepresentation++;
if (field == POINTS) {
numberOfValues = getPointSet()->GetNumberOfPoints();
}
else {
// this is cell field
numberOfValues = getPointSet()->GetNumberOfCells();
}
// fill the data array
dataArrayToDisplay->SetNumberOfValues(numberOfValues);
// use the representation flag to tranform the point's 3D vector to a scalar
for (vtkIdType i = 0; i < numberOfValues; ++i) {
double val[3];
dataArray->GetTuple(i, val);
switch (representation) {
case FIRST_COMPONENT:
dataArrayToDisplay->SetValue(i, val[0]);
break;
case SECOND_COMPONENT:
dataArrayToDisplay->SetValue(i, val[1]);
break;
case THIRD_COMPONENT:
dataArrayToDisplay->SetValue(i, val[2]);
break;
case NORM:
default:
// compute 3D norm
dataArrayToDisplay->SetValue(i, sqrt(val[0]*val[0] + val[1]*val[1] + val[2]*val[2]));
break;
}
}
break;
// add it to the pointset field data directly, but NOT to the mesh component (it will stay hidden)
getFieldData(field)->AddArray(dataArrayToDisplay);
// insert it in the specific map
specific3DDataRepresentation.insert(specificName, dataArrayToDisplay);
// update the cell specific representation counter so that getNumberOfDataArray answer is up-to-date
if (field == CELLS) {
numberOfCellDataSpecificRepresentation++;
}
}
break;
case TENSORS: {
double boundingRadius = getBoundingRadius();
vtkSmartPointer<vtkTensorGlyph> tensorGlyph = vtkSmartPointer<vtkTensorGlyph>::New();
vtkSmartPointer<vtkDataSetMapper> dataMapper = vtkSmartPointer< vtkDataSetMapper >::New();
vtkSmartPointer<vtkActor> dataActor = vtkSmartPointer< vtkActor >::New();
vtkSmartPointer<vtkSphereSource> glyphSphere = vtkSmartPointer<vtkSphereSource>::New();
glyphSphere->SetRadius(myGeometry->getBoundingRadius() / 50.0);
glyphSphere->SetRadius(boundingRadius / 10.0);
if (field == POINTS) {
tensorGlyph->SetInputConnection(myGeometry->getDataPort());
tensorGlyph->SetInputConnection(getDataPort());
tensorGlyph->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, name.toUtf8().constData());
}
else
if (field == CELLS) {
vtkSmartPointer<vtkCellCenters> cellCentersFilter = vtkSmartPointer<vtkCellCenters>::New();
cellCentersFilter->SetInputConnection(myGeometry->getDataPort());
cellCentersFilter->SetInputConnection(getDataPort());
tensorGlyph->SetInputConnection(cellCentersFilter->GetOutputPort());
tensorGlyph->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_CELLS, name.toUtf8().constData());
}
......@@ -676,6 +712,7 @@ void MeshComponent::createDataRepresentation(FieldType field, const QString& nam
tensorGlyph->SetScaling(1);
tensorGlyph->SetMaxScaleFactor(2);
tensorGlyph->SetClampScaling(1);
tensorGlyph->SetScaleFactor(boundingRadius / 10.0);
dataMapper->SetInputConnection(tensorGlyph->GetOutputPort());
dataActor->SetMapper(dataMapper);
dataActor->GetProperty()->SetColor(0, 1, 0);
......@@ -699,12 +736,12 @@ bool MeshComponent::getDataRepresentationVisibility(FieldType field, const QStri
return false;
}
// if type is 1D, 9D or 3D as HEDGE_HOG, just check if the data are shown or not
if ((type == SCALARS) || (type == VECTORS && representation == HEDGE_HOG) || (type == TENSORS)) {
// if type is 1D, 9D or 3D as VECTOR_3D, just check if the data are shown or not
if ((type == SCALARS) || (type == VECTORS && representation == VECTOR_3D) || (type == TENSORS)) {
return dataRepresentationVisibility.value(dataArray);
}
else {
// if this is a 3D data with a specific data representation (i.e., different than HEDGE_HOG
// if this is a 3D data with a specific data representation (i.e., different than VECTOR_3D)
// Then check if the specific data array exists first
if (specific3DDataRepresentation.contains(name + getSpecificRepresentationName(representation))) {
// and if it exists, check if it is shown
......@@ -804,7 +841,7 @@ void MeshComponent::setDataRepresentationVisibility(FieldType fieldType, const Q
DataType type = getDataType(dataArray);
if (!visibility) {
if ((type == SCALARS) || (type == VECTORS && representation == HEDGE_HOG) || (type == TENSORS)) {
if ((type == SCALARS) || (type == VECTORS && representation == VECTOR_3D) || (type == TENSORS)) {
setDataRepresentationOff(type);
}
else {
......@@ -835,7 +872,7 @@ void MeshComponent::setDataRepresentationVisibility(FieldType fieldType, const Q
case VECTORS:
if (representation != HEDGE_HOG) {
if (representation != VECTOR_3D) {
// first remove all other scalar color map (only one possible color at at time
setDataRepresentationOff(SCALARS);
......@@ -1122,7 +1159,7 @@ const QString MeshComponent::getDataTypeName(vtkSmartPointer<vtkDataArray> array
const QString MeshComponent::getSpecificRepresentationName(const SpecificRepresentation displayType) {
switch (displayType) {
case MeshComponent::NORM:
return "/norm";
return " norm";
break;
case MeshComponent::FIRST_COMPONENT:
return "[0]";
......@@ -1133,7 +1170,7 @@ const QString MeshComponent::getSpecificRepresentationName(const SpecificReprese
case MeshComponent::THIRD_COMPONENT:
return "[2]";
break;
case MeshComponent::HEDGE_HOG:
case MeshComponent::VECTOR_3D:
default:
return "";
break;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment