@COMMENCE@
# header files
-EXPORT_HEADERS= VTKViewer_RenderWindow.h \
+EXPORT_HEADERS= VTKViewer_Definitions.h \
+ VTKViewer_RenderWindow.h \
VTKViewer_ViewFrame.h \
VTKViewer_RenderWindowInteractor.h \
VTKViewer_InteractorStyleSALOME.h \
}
-void VTKViewer_Actor::SetShrinkFactor(float theValue){
+void VTKViewer_Actor::SetShrinkFactor(_VTK_FLOAT_ theValue){
myShrinkFilter->SetShrinkFactor(theValue);
Modified();
}
aPoints->SetNumberOfPoints(aNbOfParts);
for(int i = 0; i < aNbOfParts; i++){
int aPartId = theMapIndex( i+1 );
- float* aCoord = theMapActor->GetNodeCoord(aPartId);
+ _VTK_FLOAT_* aCoord = theMapActor->GetNodeCoord(aPartId);
aPoints->SetPoint(i,aCoord);
myUnstructuredGrid->InsertNextCell(VTK_VERTEX,1,&i);
}
class vtkDataSetMapper;
class vtkUnstructuredGrid;
+#include "VTKViewer_Definitions.h"
#include "SALOME_Actor.h"
class VTKViewer_Actor : public SALOME_Actor {
static VTKViewer_Actor* New();
virtual ~VTKViewer_Actor();
- void SetShrinkFactor(float value);
+ void SetShrinkFactor(_VTK_FLOAT_ value);
virtual void SetShrink();
virtual void UnShrink();
#define VTKViewer_Algorithm_H
class vtkActor;
-class vtkActorCollection;
+#include <vtkActorCollection.h>
namespace SALOME{
namespace VTK{
}
//----------------------------------------------------------------------------
-float VTKViewer_CellRectPicker::IntersectWithHex(float p1[4][4], float p2[4][4], float tol,
+_VTK_FLOAT_ VTKViewer_CellRectPicker::IntersectWithHex(_VTK_FLOAT_ p1[4][4], _VTK_FLOAT_ p2[4][4], _VTK_FLOAT_ tol,
vtkAssemblyPath *path, vtkProp3D *prop3D,
vtkAbstractMapper3D *m)
{
}
int i, k, subId;
- float bounds[6], center[3], cp1[3], cp2[3];
- float pcoord[3], weight[4], dist;
- float t1[2], t2[2], x[3], t;
+ _VTK_FLOAT_ bounds[6], center[3], cp1[3], cp2[3];
+ _VTK_FLOAT_ pcoord[3], weight[4], dist;
+ _VTK_FLOAT_ t1[2], t2[2], x[3], t;
for (k = 0; k < 4; k++) {
this->Quad1->PointIds->SetId(k, k);
VTKViewer_CellData cellData;
VTKViewer_CellDataSet dataList;
- char inside; int n; float *point;
- float tMin = VTK_LARGE_FLOAT, xMin[3];
+ char inside; int n; _VTK_FLOAT_ *point;
+ _VTK_FLOAT_ tMin = VTK_LARGE_FLOAT, xMin[3];
for (cellId = 0; cellId < numCells; cellId++) {
input->GetCell(cellId, this->Cell);
sub1 = cell1->GetFace(cellData.subId);
int i, result;
- float p1[3], p2[3], dir[3];
+ _VTK_FLOAT_ p1[3], p2[3], dir[3];
char add = 1;
VTKViewer_CellData curData;
vtkGenericCell* cell2 = vtkGenericCell::New();
int i, result;
- float p1[3], p2[3], dir[3];
+ _VTK_FLOAT_ p1[3], p2[3], dir[3];
char removed;
VTKViewer_CellDataSet actorData;
cell2->Delete();
}
-int VTKViewer_CellRectPicker::IntersectCells(vtkCell* c1, float d1, vtkCell* c2, float d2, float dir[3])
+int VTKViewer_CellRectPicker::IntersectCells(vtkCell* c1, _VTK_FLOAT_ d1, vtkCell* c2, _VTK_FLOAT_ d2, _VTK_FLOAT_ dir[3])
{
int i, k;
- float *orig, cp[3], bounds[6];
+ _VTK_FLOAT_ *orig, cp[3], bounds[6];
vtkCell* cell = 0;
vtkCell* tcell = 0;
cp[i] = (bounds[2*i] + bounds[2*i+1])/2;
}
- float proj[3];
+ _VTK_FLOAT_ proj[3];
vtkPlane::GeneralizedProjectPoint(cp, orig, dir, proj);
- float *p, pp[3];
+ _VTK_FLOAT_ *p, pp[3];
vtkPoints* aPoints = vtkPoints::New();
for (k = 0; k < cell->Points->GetNumberOfPoints(); k++) {
p = cell->Points->GetPoint(k);
return result;
}
-char VTKViewer_CellRectPicker::PointInside(float point[3], vtkPoints* list)
+char VTKViewer_CellRectPicker::PointInside(_VTK_FLOAT_ point[3], vtkPoints* list)
{
int i, k, l, n;
- float x[3], *a1, *a2, v[3], p[3], q[3];
+ _VTK_FLOAT_ x[3], *a1, *a2, v[3], p[3], q[3];
n = list->GetNumberOfPoints();
if (n < 3) return 0;
#ifndef __VTKViewer_CellRectPicker_h
#define __VTKViewer_CellRectPicker_h
+#include "VTKViewer_Definitions.h"
#include "VTKViewer_RectPicker.h"
#include <map>
#include <vector>
typedef struct {
vtkIdType cellId;
int subId;
- float depth;
- float p1[3];
- float p2[3];
+ _VTK_FLOAT_ depth;
+ _VTK_FLOAT_ p1[3];
+ _VTK_FLOAT_ p2[3];
} VTKViewer_CellData;
typedef std::vector<VTKViewer_CellData> VTKViewer_CellDataSet;
// The method returns a non-zero value if the cells intersect each other
// in the direction dir[3]. Returned value is 1 if the first cell is top of
// the second one according to direction and 2 if the second cell is top.
- static int IntersectCells(vtkCell* c1, float d1, vtkCell* c2, float d2, float dir[3]);
+ static int IntersectCells(vtkCell* c1, _VTK_FLOAT_ d1, vtkCell* c2, _VTK_FLOAT_ d2, _VTK_FLOAT_ dir[3]);
// Description:
// The method returns a non-zero value if the point is inlide point data set
- static char PointInside(float point[3], vtkPoints* list);
+ static char PointInside(_VTK_FLOAT_ point[3], vtkPoints* list);
protected:
VTKViewer_CellRectPicker();
VTKViewer_ActorDataMap ActorData;
- virtual float IntersectWithHex(float p1[4][4], float p2[4][4], float tol,
+ virtual _VTK_FLOAT_ IntersectWithHex(_VTK_FLOAT_ p1[4][4], _VTK_FLOAT_ p2[4][4], _VTK_FLOAT_ tol,
vtkAssemblyPath *path, vtkProp3D *p,
vtkAbstractMapper3D *m);
void Initialize();
--- /dev/null
+
+#ifndef __VTKViewer_Definitions_h
+#define __VTKViewer_Definitions_h
+
+#if ((VTK_MAJOR_VERSION == 4)&&(VTK_MINOR_VERSION <= 2))
+#define _VTK_FLOAT_ float
+#else
+#define _VTK_FLOAT_ double
+#endif
+
+#endif
static int GetEdgeId(vtkPicker *thePicker, SALOME_Actor *theActor, int theObjId){
int anEdgeId = -1;
if (vtkCell* aPickedCell = theActor->GetElemCell(theObjId)) {
- float aPickPosition[3];
+ _VTK_FLOAT_ aPickPosition[3];
thePicker->GetPickPosition(aPickPosition);
- float aMinDist = 1000000.0, aDist = 0;
+ _VTK_FLOAT_ aMinDist = 1000000.0, aDist = 0;
for (int i = 0, iEnd = aPickedCell->GetNumberOfEdges(); i < iEnd; i++){
if(vtkLine* aLine = vtkLine::SafeDownCast(aPickedCell->GetEdge(i))){
- int subId; float pcoords[3], closestPoint[3], weights[3];
+ int subId; _VTK_FLOAT_ pcoords[3], closestPoint[3], weights[3];
aLine->EvaluatePosition(aPickPosition,closestPoint,subId,pcoords,aDist,weights);
if (aDist < aMinDist) {
aMinDist = aDist;
if (vtkDataSet* aDataSet = SActor->GetInput()) {
SALOME_Selection::TContainerOfId anIndices;
for(int i = 0; i < aDataSet->GetNumberOfPoints(); i++) {
- float aPoint[3];
+ _VTK_FLOAT_ aPoint[3];
aDataSet->GetPoint(i,aPoint);
if (IsInRect(aPoint,x1,y1,x2,y2)){
- float aDisp[3];
+ _VTK_FLOAT_ aDisp[3];
ComputeWorldToDisplay(aPoint[0],aPoint[1],aPoint[2],aDisp);
if(aPointPicker->Pick(aDisp[0],aDisp[1],0.0,CurrentRenderer)){
if(vtkActorCollection *anActorCollection = aPointPicker->GetActors()){
if(anActorCollection->IsItemPresent(SActor)){
- float aPickedPoint[3];
+ _VTK_FLOAT_ aPickedPoint[3];
aPointPicker->GetMapperPosition(aPickedPoint);
vtkIdType aVtkId = aDataSet->FindPoint(aPickedPoint);
if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ){
{
vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
double viewFocus[4], focalDepth, viewPoint[3];
- float newPickPoint[4], oldPickPoint[4], motionVector[3];
+ _VTK_FLOAT_ newPickPoint[4], oldPickPoint[4], motionVector[3];
cam->GetFocalPoint(viewFocus);
this->ComputeWorldToDisplay(viewFocus[0], viewFocus[1],
const int left, const int top,
const int right, const int bottom)
{
- float* aBounds = theActor->GetBounds();
- float aMin[3], aMax[3];
+ _VTK_FLOAT_* aBounds = theActor->GetBounds();
+ _VTK_FLOAT_ aMin[3], aMax[3];
ComputeWorldToDisplay(aBounds[0], aBounds[2], aBounds[4], aMin);
ComputeWorldToDisplay(aBounds[1], aBounds[3], aBounds[5], aMax);
if (aMin[0] > aMax[0]) {
- float aBuf = aMin[0];
+ _VTK_FLOAT_ aBuf = aMin[0];
aMin[0] = aMax[0];
aMax[0] = aBuf;
}
if (aMin[1] > aMax[1]) {
- float aBuf = aMin[1];
+ _VTK_FLOAT_ aBuf = aMin[1];
aMin[1] = aMax[1];
aMax[1] = aBuf;
}
const int left, const int top,
const int right, const int bottom)
{
- float* aBounds = theCell->GetBounds();
- float aMin[3], aMax[3];
+ _VTK_FLOAT_* aBounds = theCell->GetBounds();
+ _VTK_FLOAT_ aMin[3], aMax[3];
ComputeWorldToDisplay(aBounds[0], aBounds[2], aBounds[4], aMin);
ComputeWorldToDisplay(aBounds[1], aBounds[3], aBounds[5], aMax);
if (aMin[0] > aMax[0]) {
- float aBuf = aMin[0];
+ _VTK_FLOAT_ aBuf = aMin[0];
aMin[0] = aMax[0];
aMax[0] = aBuf;
}
if (aMin[1] > aMax[1]) {
- float aBuf = aMin[1];
+ _VTK_FLOAT_ aBuf = aMin[1];
aMin[1] = aMax[1];
aMax[1] = aBuf;
}
}
-bool VTKViewer_InteractorStyleSALOME::IsInRect(float* thePoint,
+bool VTKViewer_InteractorStyleSALOME::IsInRect(_VTK_FLOAT_* thePoint,
const int left, const int top,
const int right, const int bottom)
{
- float aPnt[3];
+ _VTK_FLOAT_ aPnt[3];
ComputeWorldToDisplay(thePoint[0], thePoint[1], thePoint[2], aPnt);
return ((aPnt[0]>left) && (aPnt[0]<right) && (aPnt[1]>bottom) && (aPnt[1]<top));
#ifndef __VTKViewer_InteractorStyleSALOME_h
#define __VTKViewer_InteractorStyleSALOME_h
+#include "VTKViewer_Definitions.h"
#include <vtkInteractorStyle.h>
class vtkCell;
bool IsInRect(vtkCell* theCell,
const int left, const int top,
const int right, const int bottom);
- bool IsInRect(float* thePoint,
+ bool IsInRect(_VTK_FLOAT_* thePoint,
const int left, const int top,
const int right, const int bottom);
int State;
- float MotionFactor;
- float RadianToDegree; // constant: for conv from deg to rad
+ _VTK_FLOAT_ MotionFactor;
+ _VTK_FLOAT_ RadianToDegree; // constant: for conv from deg to rad
double myScale;
SALOME_Actor* myPreViewActor;
}
//----------------------------------------------------------------------------
-int VTKViewer_RectPicker::Pick(float selectionX1, float selectionY1, float selectionZ1,
- float selectionX2, float selectionY2, float selectionZ2,
+int VTKViewer_RectPicker::Pick(_VTK_FLOAT_ selectionX1, _VTK_FLOAT_ selectionY1, _VTK_FLOAT_ selectionZ1,
+ _VTK_FLOAT_ selectionX2, _VTK_FLOAT_ selectionY2, _VTK_FLOAT_ selectionZ2,
vtkRenderer *renderer)
{
int k, i;
vtkProp *prop;
vtkCamera *camera;
vtkAbstractMapper3D *mapper = NULL;
- float p1World[4][4], p2World[4][4], p1Mapper[4][4], p2Mapper[4][4];
- float c1[3], c2[3];
+ _VTK_FLOAT_ p1World[4][4], p2World[4][4], p1Mapper[4][4], p2Mapper[4][4];
+ _VTK_FLOAT_ c1[3], c2[3];
int picked=0;
int *winSize;
- float x, y, t, p;
- float *viewport;
- float cameraPos[4], cameraFP[4];
- float *displayCoords, *worldCoords;
- float pickPosition[4][3];
+ _VTK_FLOAT_ x, y, t, p;
+ _VTK_FLOAT_ *viewport;
+ _VTK_FLOAT_ cameraPos[4], cameraFP[4];
+ _VTK_FLOAT_ *displayCoords, *worldCoords;
+ _VTK_FLOAT_ pickPosition[4][3];
double *clipRange;
- float ray[4][3], rayLength[4];
+ _VTK_FLOAT_ ray[4][3], rayLength[4];
int pickable;
int LODId;
- float windowLowerLeft[4], windowUpperRight[4];
- float bounds[6], tol;
- float tF, tB;
- float hitPosition[3];
- float cameraDOP[3];
+ _VTK_FLOAT_ windowLowerLeft[4], windowUpperRight[4];
+ _VTK_FLOAT_ bounds[6], tol;
+ _VTK_FLOAT_ tF, tB;
+ _VTK_FLOAT_ hitPosition[3];
+ _VTK_FLOAT_ cameraDOP[3];
// Initialize picking process
this->Initialize();
// coordinates. We need a depth value for z-buffer.
//
camera = renderer->GetActiveCamera();
- camera->GetPosition((float *)cameraPos); cameraPos[3] = 1.0;
- camera->GetFocalPoint((float *)cameraFP); cameraFP[3] = 1.0;
+ camera->GetPosition((_VTK_FLOAT_ *)cameraPos); cameraPos[3] = 1.0;
+ camera->GetFocalPoint((_VTK_FLOAT_ *)cameraFP); cameraFP[3] = 1.0;
renderer->SetWorldPoint(cameraFP);
renderer->WorldToDisplay();
#define SIDE_RIGHT 1
#define SIDE_MIDDLE 2
-float GetParameterValue(float start, float end, float point)
+_VTK_FLOAT_ GetParameterValue(_VTK_FLOAT_ start, _VTK_FLOAT_ end, _VTK_FLOAT_ point)
{
if (start == end) return -VTK_LARGE_FLOAT;
return (point-start)/(end-start);
}
-void GetPointCoord(const float start[3], const float end[3], float t, float point[3])
+void GetPointCoord(const _VTK_FLOAT_ start[3], const _VTK_FLOAT_ end[3], _VTK_FLOAT_ t, _VTK_FLOAT_ point[3])
{
int i;
for (i = 0; i < 3; i++) {
}
}
-char GetIntersectionPoint(const float start[3], const float end[3],
- const int& index, const float p, float point[3])
+char GetIntersectionPoint(const _VTK_FLOAT_ start[3], const _VTK_FLOAT_ end[3],
+ const int& index, const _VTK_FLOAT_ p, _VTK_FLOAT_ point[3])
{
- float t = GetParameterValue(start[index], end[index], p);
+ _VTK_FLOAT_ t = GetParameterValue(start[index], end[index], p);
char result = 0;
if (t >= 0.0 && t <= 1.0) {
result = 1;
}
//----------------------------------------------------------------------------
-char VTKViewer_RectPicker::HitBBox (float bounds[6], float origin[4][4], float dir[4][3])
+char VTKViewer_RectPicker::HitBBox (_VTK_FLOAT_ bounds[6], _VTK_FLOAT_ origin[4][4], _VTK_FLOAT_ dir[4][3])
{
int i, j, k, n;
- float endray[4][3];
+ _VTK_FLOAT_ endray[4][3];
for (k = 0; k < 4; k++) {
for (i = 0; i < 3; i++) {
}
// Compute hex bounding box, center point and center direction
- float hbounds[6], center[3], ray[3];
+ _VTK_FLOAT_ hbounds[6], center[3], ray[3];
for (i = 0; i < 3; i++) {
hbounds[2*i] = hbounds[2*i+1] = origin[0][i];
center[i] = ray[i] = 0;
// Find the closest coord plane for the center point
char side[3];
- float coordPlane[3];
+ _VTK_FLOAT_ coordPlane[3];
inside = 1;
for (i = 0; i < 3; i++) {
if (center[i] < bounds[2*i]) {
if (inside) return 1;
// Calculate parametric distances to the planes and find the max
- float maxT[3];
+ _VTK_FLOAT_ maxT[3];
int whichPlane = 0;
char defined = 0;
for (i = 0; i < 3; i++) {
}
// Check for intersection along the center ray
- float coord;
+ _VTK_FLOAT_ coord;
if (maxT[whichPlane] <= 1.0 && maxT[whichPlane] >= 0.0) {
inside = 1;
for (i = 0; i < 3; i++) {
}
// Compute the intersection between hex and coord plane
- float t[4];
+ _VTK_FLOAT_ t[4];
for (k = 0; k < 4; k++) {
if (dir[k][whichPlane] != 0.0) {
t[k] = (coordPlane[whichPlane]-origin[k][whichPlane])/dir[k][whichPlane];
}
vtkPoints* aPoints = vtkPoints::New();
- float p[3], q[3], t1;
+ _VTK_FLOAT_ p[3], q[3], t1;
for (k = 0; k < 4; k++) {
n = (k+1)%4; // next point
if (t[k] > 1.0) {
// Analize intersection
int nearPlane, boundPlane = -1;
- float boundCoord, boundMin, boundMax;
+ _VTK_FLOAT_ boundCoord, boundMin, boundMax;
char intersect = 0;
for (k = 0; k < n; k++) {
aPoints->GetPoint(k, p);
}
//----------------------------------------------------------------------------
-char VTKViewer_RectPicker::PointInside (float p[3], float p1[4][4], float p2[4][4], float tol)
+char VTKViewer_RectPicker::PointInside (_VTK_FLOAT_ p[3], _VTK_FLOAT_ p1[4][4], _VTK_FLOAT_ p2[4][4], _VTK_FLOAT_ tol)
{
int i, j, k;
- float t, coord[3];
+ _VTK_FLOAT_ t, coord[3];
// Fix one coordinate (x, for example) and
// compute intersection with coordinate plane
}
// Fix the second coord and define bounds
- float zMin = VTK_LARGE_FLOAT, zMax = -VTK_LARGE_FLOAT, z, ncoord[3];
+ _VTK_FLOAT_ zMin = VTK_LARGE_FLOAT, zMax = -VTK_LARGE_FLOAT, z, ncoord[3];
char inside = 0;
for (k = 0; k < n; k++) {
aPoints->GetPoint(k, coord);
}
//----------------------------------------------------------------------------
-float VTKViewer_RectPicker::IntersectWithHex(float p1[4][4], float p2[4][4], float tol,
+_VTK_FLOAT_ VTKViewer_RectPicker::IntersectWithHex(_VTK_FLOAT_ p1[4][4], _VTK_FLOAT_ p2[4][4], _VTK_FLOAT_ tol,
vtkAssemblyPath *path, vtkProp3D *prop3D,
vtkAbstractMapper3D *mapper)
{
int i, k;
- float *center, p0[3], ray[3], rayFactor, t;
+ _VTK_FLOAT_ *center, p0[3], ray[3], rayFactor, t;
// Get the data from the modeler
//
#ifndef __VTKViewer_RectPicker_h
#define __VTKViewer_RectPicker_h
+#include "VTKViewer_Definitions.h"
#include <vtkPicker.h>
class VTK_EXPORT VTKViewer_RectPicker : public vtkPicker
// first two values for the selection top-left and right-bottom points are
// x-y pixel coordinate, and the third value is =0.
// Return non-zero if something was successfully picked.
- virtual int Pick(float selectionX1, float selectionY1, float selectionZ1,
- float selectionX2, float selectionY2, float selectionZ2,
+ virtual int Pick(_VTK_FLOAT_ selectionX1, _VTK_FLOAT_ selectionY1, _VTK_FLOAT_ selectionZ1,
+ _VTK_FLOAT_ selectionX2, _VTK_FLOAT_ selectionY2, _VTK_FLOAT_ selectionZ2,
vtkRenderer *renderer);
// Description:
// two values for the selection top-left and right-bottom points are x-y pixel
// coordinate, and the third value is =0.
// Return non-zero if something was successfully picked.
- int Pick(float selectionPt1[3], float selectionPt2[3], vtkRenderer *ren)
+ int Pick(_VTK_FLOAT_ selectionPt1[3], _VTK_FLOAT_ selectionPt2[3], vtkRenderer *ren)
{return this->Pick(selectionPt1[0], selectionPt1[1], selectionPt1[2],
selectionPt2[0], selectionPt2[1], selectionPt2[2],
ren);};
// if the bounding box is hit. Origin[4][4] starts the ray from corner points,
// dir[4][3] is the vector components of the ray in the x-y-z directions.
// (Notes: the intersection ray dir[4][3] is NOT normalized.)
- static char HitBBox(float bounds[6], float origin[4][4], float dir[4][3]);
+ static char HitBBox(_VTK_FLOAT_ bounds[6], _VTK_FLOAT_ origin[4][4], _VTK_FLOAT_ dir[4][3]);
// Description:
// Position of point relative to hexahedron. The method returns a non-zero value
// if the point is inside. p1[4][4] is the corner points of top face,
// p2[4][4] is the corner points of bottom face.
- static char PointInside(float point[3], float p1[4][4], float p2[4][4], float tol=0);
+ static char PointInside(_VTK_FLOAT_ point[3], _VTK_FLOAT_ p1[4][4], _VTK_FLOAT_ p2[4][4], _VTK_FLOAT_ tol=0);
protected:
VTKViewer_RectPicker();
~VTKViewer_RectPicker() {};
- virtual float IntersectWithHex(float p1[4][4], float p2[4][4], float tol,
+ virtual _VTK_FLOAT_ IntersectWithHex(_VTK_FLOAT_ p1[4][4], _VTK_FLOAT_ p2[4][4], _VTK_FLOAT_ tol,
vtkAssemblyPath *path, vtkProp3D *p,
vtkAbstractMapper3D *m);
// $Header$
#include "VTKViewer_RenderWindow.h"
+#include "VTKViewer_Definitions.h"
#include "utilities.h"
#include "QAD_Settings.h"
#include "QAD_Config.h"
void VTKViewer_RenderWindow::onChangeBackgroundColor()
{
- float red, green, blue;
- float backint[3];
+ _VTK_FLOAT_ red, green, blue;
+ _VTK_FLOAT_ backint[3];
vtkRendererCollection * theRenderers = myRW->GetRenderers();
theRenderers->InitTraversal();
void VTKViewer_UnScaledActor::Render(vtkRenderer *theRenderer){
if(theRenderer){
- float P[2][3] = {{-1.0, -1.0, 0.0},{+1.0, +1.0, 0.0}};
+ _VTK_FLOAT_ P[2][3] = {{-1.0, -1.0, 0.0},{+1.0, +1.0, 0.0}};
theRenderer->ViewToWorld(P[0][0],P[0][1],P[0][2]);
theRenderer->ViewToWorld(P[1][0],P[1][1],P[1][2]);
- float aWorldDiag = sqrt((P[1][0]-P[0][0])*(P[1][0]-P[0][0])+
+ _VTK_FLOAT_ aWorldDiag = sqrt((P[1][0]-P[0][0])*(P[1][0]-P[0][0])+
(P[1][1]-P[0][1])*(P[1][1]-P[0][1])+
(P[1][2]-P[0][2])*(P[1][2]-P[0][2]));
int* aSize = theRenderer->GetRenderWindow()->GetSize();
- float aWinDiag = sqrt(float(aSize[0]*aSize[0]+aSize[1]*aSize[1]));
+ _VTK_FLOAT_ aWinDiag = sqrt(_VTK_FLOAT_(aSize[0]*aSize[0]+aSize[1]*aSize[1]));
vtkDataSet* aDataSet = GetMapper()->GetInput();
- float aLength = aDataSet->GetLength();
- float aPrecision = 1.0E-3;
- float anOldScale = GetScale()[0];
- float aScale = mySize*aWorldDiag/aWinDiag/aLength*sqrt(float(aSize[0])/float(aSize[1]));
+ _VTK_FLOAT_ aLength = aDataSet->GetLength();
+ _VTK_FLOAT_ aPrecision = 1.0E-3;
+ _VTK_FLOAT_ anOldScale = GetScale()[0];
+ _VTK_FLOAT_ aScale = mySize*aWorldDiag/aWinDiag/aLength*sqrt(_VTK_FLOAT_(aSize[0])/_VTK_FLOAT_(aSize[1]));
if(fabs(aScale - anOldScale)/aScale > aPrecision){
SetScale(aScale);
}
myVisibility = theVis;
}
-void VTKViewer_Axis::SetSize(float theSize){
- float aPosition[3] = {myDir[0]*theSize, myDir[1]*theSize, myDir[2]*theSize};
+void VTKViewer_Axis::SetSize(_VTK_FLOAT_ theSize){
+ _VTK_FLOAT_ aPosition[3] = {myDir[0]*theSize, myDir[1]*theSize, myDir[2]*theSize};
myLineSource->SetPoint2(aPosition);
myArrowActor->SetPosition(0.0,0.0,0.0);
myAxis[0] = VTKViewer_XAxis::New();
myAxis[1] = VTKViewer_YAxis::New();
myAxis[2] = VTKViewer_ZAxis::New();
- static float aSize = 100;
+ static _VTK_FLOAT_ aSize = 100;
SetSize(aSize);
}
myAxis[i]->Delete();
}
-void VTKViewer_Trihedron::SetSize(float theSize){
+void VTKViewer_Trihedron::SetSize(_VTK_FLOAT_ theSize){
mySize = theSize;
for(int i = 0; i < 3; i++)
myAxis[i]->SetSize(theSize);
#ifndef VTKViewer_Trihedron_H
#define VTKViewer_Trihedron_H
+#include "VTKViewer_Definitions.h"
#include <vtkObject.h>
#include <vtkFollower.h>
vtkTypeMacro(VTKViewer_Trihedron,vtkObject);
static VTKViewer_Trihedron *New();
- virtual void SetSize(float theSize);
- virtual float GetSize() { return mySize;}
+ virtual void SetSize(_VTK_FLOAT_ theSize);
+ virtual _VTK_FLOAT_ GetSize() { return mySize;}
enum TVisibility{eOff, eOn, eOnlyLineOn};
virtual void SetVisibility(TVisibility theVis);
protected:
vtkActorCollection* myPresent;
VTKViewer_Axis* myAxis[3];
- float mySize;
+ _VTK_FLOAT_ mySize;
};
//==============================================================================
virtual void SetCamera(vtkCamera* theCamera);
virtual void SetProperty(vtkProperty* theProperty);
- virtual void SetSize(float theSize);
+ virtual void SetSize(_VTK_FLOAT_ theSize);
virtual VTKViewer_UnScaledActor* GetLabel(){ return myLabelActor; }
virtual VTKViewer_UnScaledActor* GetArrow(){ return myArrowActor; }
protected:
VTKViewer_Trihedron::TVisibility myVisibility;
- float myDir[3], myRot[3];
+ _VTK_FLOAT_ myDir[3], myRot[3];
VTKViewer_LineActor *myLineActor;
//vtkActor *myLineActor;
using namespace std;
-//see vtkRenderer::ResetCamera(float bounds[6]) method
+//see vtkRenderer::ResetCamera(_VTK_FLOAT_ bounds[6]) method
void ResetCamera(vtkRenderer* theRenderer, int theUsingZeroFocalPoint){
if(!theRenderer) return;
- float bounds[6];
+ _VTK_FLOAT_ bounds[6];
int aCount = ComputeVisiblePropBounds(theRenderer,bounds);
if(theUsingZeroFocalPoint || aCount){
- float aLength = bounds[1]-bounds[0];
+ _VTK_FLOAT_ aLength = bounds[1]-bounds[0];
aLength = max((bounds[3]-bounds[2]),aLength);
aLength = max((bounds[5]-bounds[4]),aLength);
return;
}
- float center[3] = {0.0, 0.0, 0.0};
+ _VTK_FLOAT_ center[3] = {0.0, 0.0, 0.0};
if(!theUsingZeroFocalPoint){
center[0] = (bounds[0] + bounds[1])/2.0;
center[1] = (bounds[2] + bounds[3])/2.0;
}
theRenderer->GetActiveCamera()->SetFocalPoint(center[0],center[1],center[2]);
- float width = sqrt((bounds[1]-bounds[0])*(bounds[1]-bounds[0]) +
+ _VTK_FLOAT_ width = sqrt((bounds[1]-bounds[0])*(bounds[1]-bounds[0]) +
(bounds[3]-bounds[2])*(bounds[3]-bounds[2]) +
(bounds[5]-bounds[4])*(bounds[5]-bounds[4]));
double ang = theRenderer->GetActiveCamera()->GetViewAngle();
- float distance = 2.0*width/tan(ang*vtkMath::Pi()/360.0);
+ _VTK_FLOAT_ distance = 2.0*width/tan(ang*vtkMath::Pi()/360.0);
// check view-up vector against view plane normal
double *vup = theRenderer->GetActiveCamera()->GetViewUp();
center[2]+distance*vn[2]);
// find size of the window
int* winsize = theRenderer->GetSize();
- if(winsize[0] < winsize[1]) width *= float(winsize[1])/float(winsize[0]);
+ if(winsize[0] < winsize[1]) width *= _VTK_FLOAT_(winsize[1])/_VTK_FLOAT_(winsize[0]);
if(theUsingZeroFocalPoint) width *= sqrt(2.0);
// Compute the bounds of the visible props
-int ComputeVisiblePropBounds(vtkRenderer* theRenderer, float theBounds[6]){
+int ComputeVisiblePropBounds(vtkRenderer* theRenderer, _VTK_FLOAT_ theBounds[6]){
vtkProp *prop;
- float *bounds;
+ _VTK_FLOAT_ *bounds;
int aCount=0;
theBounds[0] = theBounds[2] = theBounds[4] = VTK_LARGE_FLOAT;
}
-//see vtkRenderer::ResetCameraClippingRange(float bounds[6]) method
+//see vtkRenderer::ResetCameraClippingRange(_VTK_FLOAT_ bounds[6]) method
void ResetCameraClippingRange(vtkRenderer* theRenderer){
if(!theRenderer || !theRenderer->VisibleActorCount()) return;
double position[3];
anActiveCamera->GetPosition(position);
- float bounds[6];
+ _VTK_FLOAT_ bounds[6];
theRenderer->ComputeVisiblePropBounds(bounds);
double center[3];
(position[1]-center[1])*(position[1]-center[1]) +
(position[2]-center[2])*(position[2]-center[2]));
- float range[2] = {distance - width/2.0, distance + width/2.0};
+ _VTK_FLOAT_ range[2] = {distance - width/2.0, distance + width/2.0};
// Do not let the range behind the camera throw off the calculation.
if (range[0] < 0.0) range[0] = 0.0;
#ifndef VTKViewer_Utilities_H
#define VTKViewer_Utilities_H
+#include "VTKViewer_Definitions.h"
+
class vtkRenderer;
extern void ResetCamera(vtkRenderer* theRenderer, int theUsingZeroFocalPoint = false);
-extern int ComputeVisiblePropBounds(vtkRenderer* theRenderer, float theBounds[6]);
+extern int ComputeVisiblePropBounds(vtkRenderer* theRenderer, _VTK_FLOAT_ theBounds[6]);
extern void ResetCameraClippingRange(vtkRenderer* theRenderer);
-extern float EPS_BNDBOX;
+extern _VTK_FLOAT_ EPS_BNDBOX;
#endif
// $Header$
#include "VTKViewer_ViewFrame.h"
+#include "VTKViewer_Definitions.h"
#include "VTKViewer_Utilities.h"
#include "VTKViewer_Trihedron.h"
#include "VTKViewer_RenderWindow.h"
bool VTKViewer_ViewFrame::ComputeTrihedronSize( double& theNewSize, double& theSize )
{
// calculating diagonal of visible props of the renderer
- float bnd[ 6 ];
+ _VTK_FLOAT_ bnd[ 6 ];
m_Triedron->VisibilityOff();
if ( ::ComputeVisiblePropBounds( m_Renderer, bnd ) == 0 )
{
bnd[ 0 ] = bnd[ 2 ] = bnd[ 100 ] = 0;
}
m_Triedron->VisibilityOn();
- float aLength = 0;
+ _VTK_FLOAT_ aLength = 0;
static bool CalcByDiag = false;
if ( CalcByDiag )
{
aLength = max( ( bnd[ 5 ] - bnd[ 4 ] ),aLength );
}
- static float aSizeInPercents = 105;
+ static _VTK_FLOAT_ aSizeInPercents = 105;
QString aSetting = QAD_CONFIG->getSetting( "Viewer:TrihedronSize" );
if ( !aSetting.isEmpty() )
aSizeInPercents = aSetting.toFloat();
- static float EPS_SIZE = 5.0E-3;
+ static _VTK_FLOAT_ EPS_SIZE = 5.0E-3;
theSize = m_Triedron->GetSize();
theNewSize = aLength * aSizeInPercents / 100.0;
::ResetCamera(m_Renderer,true);
if(aTriedronIsVisible) m_Triedron->VisibilityOn();
else m_Triedron->VisibilityOff();
- static float aCoeff = 3.0;
+ static _VTK_FLOAT_ aCoeff = 3.0;
aCamera->SetParallelScale(aCoeff*aCamera->GetParallelScale());
Repaint();
}
*/
QColor VTKViewer_ViewFrame::backgroundColor() const
{
- float backint[3];
+ _VTK_FLOAT_ backint[3];
if ( m_Renderer ) {
m_Renderer->GetBackground(backint);
return QColorDialog::getColor ( QColor(int(backint[0]*255), int(backint[1]*255), int(backint[2]*255)), NULL );