// function : RenderOpaqueGeometry
// purpose :
//==================================================================
-int VISU_FramedTextActor::RenderOpaqueGeometry(vtkViewport *viewport)
-{
- int renderedSomething=0;
- int size[2];
- int aTextSize[2], barWidth, barHeight;
- float x[3]={0.,0.,0.};
- //
- int numPts=4;
- vtkPoints *pts = vtkPoints::New();
- pts->SetNumberOfPoints(numPts);
- vtkCellArray *polys = vtkCellArray::New();
- polys->Allocate(polys->EstimateSize(1,4));
- //
+int
+VISU_FramedTextActor
+::RenderOpaqueGeometry(vtkViewport *theViewport)
+{
+ int anIsRenderedSomething = 0;
+ int* aViewportSize = theViewport->GetSize();
+ if(aViewportSize[0] == 1 || aViewportSize[1] == 1)
+ return anIsRenderedSomething;
+
myBar->Initialize();
- myBar->SetPoints(pts);
- myBar->SetPolys(polys);
- pts->Delete(); polys->Delete();
- //
- myTextMapper->GetSize(viewport, aTextSize);
- //
- barWidth =aTextSize[0];
- barHeight=aTextSize[1];
- //
+
+ int aNbPoints = 4;
+ vtkPoints *aPoints = vtkPoints::New();
+ aPoints->SetNumberOfPoints(aNbPoints);
+ myBar->SetPoints(aPoints);
+ aPoints->Delete();
+
+ vtkCellArray *aPolys = vtkCellArray::New();
+ aPolys->Allocate(aPolys->EstimateSize(1,4));
+ vtkIdType aPointsIds[4] = {0, 1, 3, 2};
+ aPolys->InsertNextCell(4,aPointsIds);
+ myBar->SetPolys(aPolys);
+ aPolys->Delete();
+
+ int aTextSize[2];
+ myTextMapper->GetSize(theViewport, aTextSize);
+ int aBarWidth = aTextSize[0];
+ int aBarHeight = aTextSize[1];
+
if (myModePosition==0) {
-
- float aSelectionPoint[3], u, v;
- //
- viewport->SetWorldPoint(myWorldPoint);
- viewport->WorldToDisplay();
- viewport->GetDisplayPoint(aSelectionPoint);
- u=aSelectionPoint[0];
- v=aSelectionPoint[1]-myDistance;
- viewport->ViewportToNormalizedViewport(u, v);
- //
+ theViewport->SetWorldPoint(myWorldPoint);
+ theViewport->WorldToDisplay();
+
+ float aSelectionPoint[3];
+ theViewport->GetDisplayPoint(aSelectionPoint);
+ float u = aSelectionPoint[0];
+ float v = aSelectionPoint[1] - myDistance;
+ theViewport->ViewportToNormalizedViewport(u, v);
PositionCoordinate->SetValue(u, v);
//
- myTextProperty->SetJustificationToCentered ();
+ myTextProperty->SetJustificationToCentered();
myTextProperty->SetVerticalJustificationToTop();
//
- x[0]=-barWidth/2. ; x[1]=0. ; pts->SetPoint(0,x);
- x[0]=-barWidth/2. ; x[1]=-barHeight ; pts->SetPoint(1,x);
- x[0]= barWidth/2 ; x[1]=0. ; pts->SetPoint(2,x);
- x[0]= barWidth/2 ; x[1]=-barHeight ; pts->SetPoint(3,x);
+ aBarWidth /= 2;
+ aPoints->SetPoint(0, -aBarWidth, 0.0, 0.0);
+ aPoints->SetPoint(1, -aBarWidth, -aBarHeight, 0.0);
+ aPoints->SetPoint(2, aBarWidth, 0.0, 0.0);
+ aPoints->SetPoint(3, aBarWidth, -aBarHeight, 0.0);
}
else {//if (myModePosition==1) {
- PositionCoordinate->SetValue(0., 1.);
+ PositionCoordinate->SetValue(0.0, 1.0);
myTextProperty->SetJustificationToLeft();
myTextProperty->SetVerticalJustificationToTop();
//
- x[0]=0. ; x[1]=0. ; pts->SetPoint(0,x);
- x[0]=0. ; x[1]=-barHeight ; pts->SetPoint(1,x);
- x[0]= barWidth ; x[1]=0. ; pts->SetPoint(2,x);
- x[0]= barWidth ; x[1]=-barHeight ; pts->SetPoint(3,x);
+ aPoints->SetPoint(0, 0.0, 0.0, 0.0);
+ aPoints->SetPoint(1, 0.0, -aBarHeight, 0.0);
+ aPoints->SetPoint(2, aBarWidth, 0.0, 0.0);
+ aPoints->SetPoint(3, aBarWidth, -aBarHeight, 0.0);
}
//
myTextMapper->GetTextProperty()->ShallowCopy(myTextProperty);
myBarActor ->GetPositionCoordinate()->SetReferenceCoordinate(PositionCoordinate);
myTextActor->GetPositionCoordinate()->SetReferenceCoordinate(PositionCoordinate);
//
- vtkIdType ptIds[4]={0,1,3,2};
- polys->InsertNextCell(4,ptIds);
- //
myBuildTime.Modified();
//
- return renderedSomething;
+ return anIsRenderedSomething;
}