25 #include <vtkCommand.h>
26 #include <vtkCellArray.h>
27 #include <vtkGlyph3D.h>
29 #include <vtkIntArray.h>
30 #include <vtkLookupTable.h>
31 #include <vtkObjectFactory.h>
32 #include <vtkPoints.h>
33 #include <vtkPointData.h>
34 #include <vtkPolyData.h>
35 #include <vtkPolyDataMapper.h>
36 #include <vtkProperty.h>
37 #include <vtkSmartPointer.h>
38 #include <vtkSphereSource.h>
39 #include <vtkVertex.h>
46 class axlActorPointSetPrivate
51 vtkSmartPointer<vtkSphereSource> sphere;
52 vtkSmartPointer<vtkGlyph3D> glyph;
69 d->pointSet = axlPointSet;
71 this->
setPoints(vtkSmartPointer<vtkPoints>::New());
72 this->
setMapper(vtkSmartPointer<vtkPolyDataMapper>::New());
73 this->
setActor(vtkSmartPointer<vtkActor>::New());
74 this->
setPolyData(vtkSmartPointer<vtkPolyData>::New());
75 this->
setCellArray(vtkSmartPointer<vtkCellArray>::New());
78 vtkSmartPointer<vtkIntArray> scalarArray = vtkSmartPointer<vtkIntArray>::New();
79 scalarArray->SetName(
"mapperCollorArrayDefaultField");
80 scalarArray->SetNumberOfComponents(1);
81 scalarArray->SetNumberOfTuples(d->pointSet->numberOfPoints());
83 vtkSmartPointer<vtkLookupTable> lookupTable = vtkSmartPointer<vtkLookupTable>::New();
84 lookupTable->SetRange(0.0, d->pointSet->numberOfPoints());
85 lookupTable->SetNumberOfTableValues(d->pointSet->numberOfPoints());
87 for(
int i = 0; i < d->pointSet->numberOfPoints(); i++)
89 this->
getPoints()->InsertNextPoint(d->pointSet->value(i)->x(), d->pointSet->value(i)->y(), d->pointSet->value(i)->z());
90 scalarArray->SetTuple1(i, i);
97 vtkSmartPointer<vtkVertex> currentVertex = vtkSmartPointer<vtkVertex>::New();
99 for(
int i = 0; i < d->pointSet->numberOfPoints(); i++)
101 currentVertex->GetPointIds()->SetId(0, i);
105 if(!d->pointSet->isUniqueColor())
107 for(
int i = 0; i < d->pointSet->numberOfPoints(); i++)
109 lookupTable->SetTableValue(i , d->pointSet->value(i)->color().redF(),d->pointSet->value(i)->color().greenF(), d->pointSet->value(i)->color().blueF(), 1.0);
121 if(!d->pointSet->isUniqueColor())
123 this->
getPolyData()->GetPointData()->AddArray(scalarArray);
124 this->
getPolyData()->GetPointData()->SetActiveScalars(
"mapperCollorArrayDefaultField");
126 this->
getMapper()->SetLookupTable(lookupTable);
127 this->
getMapper()->SetInterpolateScalarsBeforeMapping(
true);
128 this->
getMapper()->UseLookupTableScalarRangeOn();
129 this->
getMapper()->SetScalarModeToUsePointData();
153 if(d->pointSet->isUniqueColor())
155 QColor color = d->pointSet->color();
156 this->
getActor()->GetProperty()->SetColor(color.redF(), color.greenF(), color.blueF());
158 QString shader = d->pointSet->shader();
159 if(!shader.isEmpty())
165 this->
setSize(d->pointSet->size());
171 qDebug()<<
"no axlPointSet available";
194 QColor color =
data->color();
195 this->
getActor()->GetProperty()->SetColor(color.redF(), color.greenF(), color.blueF());
204 vtkProperty *prop = this->
getActor()->GetProperty();
208 QColor color =
data->color();
209 qreal *h =
new qreal(0.0);
210 qreal *s =
new qreal(0.0);
211 qreal *l =
new qreal(0.0);
212 color.getHslF(h, s, l);
213 color.setHslF(*h, *s, *l + (1.0 - *l) / 2.0);
214 prop->SetColor(color.redF(), color.greenF(), color.blueF());
222 vtkProperty *prop = this->
getActor()->GetProperty();
225 QColor color =
data->color();
226 qreal *h =
new qreal(0.0);
227 qreal *s =
new qreal(0.0);
228 qreal *l =
new qreal(0.0);
229 color.getHslF(h, s, l);
230 color.setHslF(*h, *s, *l + (1.0 - *l)/2.0);
231 prop->SetColor(color.redF(), color.greenF(), color.blueF());
240 this->
getActor()->GetProperty()->SetPointSize(size);
dtkAbstractData * data(void)
vtkSmartPointer< vtkCellArray > getCellArray(void)
void stateChanged(dtkAbstractData *data, int mode)
vtkSmartPointer< vtkPolyData > getPolyData(void)
void onModeChanged(int state)
virtual void setState(int state)
void setCellArray(vtkSmartPointer< vtkCellArray > cellArray)
vtkCxxRevisionMacro(axlActorPointSet,"$Revision: 0.0.1 $")
vtkStandardNewMacro(axlActorPointSet)
vtkSmartPointer< vtkPoints > getPoints(void)
void setPointSet(axlPointSet *axlPointsSet)
virtual void setShader(QString vsfile)
virtual void setOpacity(double opacity)
void setPolyData(vtkSmartPointer< vtkPolyData > polyData)
void setMapper(vtkSmartPointer< vtkPolyDataMapper > mapper)
void setActor(vtkSmartPointer< vtkActor > actor)
vtkSmartPointer< vtkActor > getActor(void)
vtkSmartPointer< vtkPolyDataMapper > getMapper(void)
void setSize(double size)
Class axlAbstractData defines an API for all type of axel data.
void setPoints(vtkSmartPointer< vtkPoints > points)