1 // SALOME VTKViewer : build VTK viewer into Salome desktop
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : VVTK_ImplicitFunctionWidget.cxx
25 // Author : Peter KURNEV
29 #include "VISU_ImplicitFunctionWidget.hxx"
31 #include <vtkFollower.h>
32 #include <vtkObjectFactory.h>
33 #include <vtkDataSet.h>
34 #include <vtkRenderWindow.h>
35 #include <vtkRenderer.h>
36 #include <vtkDataSet.h>
37 #include <vtkImplicitFunction.h>
38 #include <vtkMapper.h>
40 vtkStandardNewMacro(VISU_UnScaledActor);
42 //====================================================================
43 // function: VISU_UnScaledActor
45 //====================================================================
46 VISU_UnScaledActor::VISU_UnScaledActor()
48 for (int i=0; i<3; ++i){
53 //====================================================================
54 // function: SetCenter
56 //====================================================================
57 void VISU_UnScaledActor::SetCenter(float *pC)
59 for (int i=0; i<3; ++i){
63 //====================================================================
66 //====================================================================
67 float* VISU_UnScaledActor::GetBounds()
69 Superclass::GetBounds();
71 for (int i=0; i<3; ++i){
72 Bounds[2*i]=myCenter[i];
73 Bounds[2*i+1]=myCenter[i];
77 //====================================================================
80 //====================================================================
81 void VISU_UnScaledActor::Render(vtkRenderer *theRenderer)
84 float P[2][3] = {{-1.0, -1.0, 0.0},{+1.0, +1.0, 0.0}};
85 theRenderer->ViewToWorld(P[0][0],P[0][1],P[0][2]);
86 theRenderer->ViewToWorld(P[1][0],P[1][1],P[1][2]);
87 float aWorldDiag = sqrt((P[1][0]-P[0][0])*(P[1][0]-P[0][0])+
88 (P[1][1]-P[0][1])*(P[1][1]-P[0][1])+
89 (P[1][2]-P[0][2])*(P[1][2]-P[0][2]));
90 int* aSize = theRenderer->GetRenderWindow()->GetSize();
91 float aWinDiag = sqrt(float(aSize[0]*aSize[0]+aSize[1]*aSize[1]));
92 vtkDataSet* aDataSet = GetMapper()->GetInput();
93 float aLength = aDataSet->GetLength();
94 float aPrecision = 1.e-3;
95 float anOldScale = GetScale()[0];
97 mySize*aWorldDiag/aWinDiag/aLength*sqrt(float(aSize[0])/float(aSize[1]));
101 if(fabs(aScale - anOldScale)/aScale > aPrecision){
105 vtkFollower::Render(theRenderer);
108 //====================================================================
111 //====================================================================
112 void VISU_UnScaledActor::SetSize(int theSize)
117 //==================================================================
118 // class: VISU_ImplicitFunctionWidget
120 vtkCxxRevisionMacro(VISU_ImplicitFunctionWidget, "$Revision$");
121 //==================================================================
122 // function: VISU_ImplicitFunctionWidget
124 //==================================================================
125 VISU_ImplicitFunctionWidget::VISU_ImplicitFunctionWidget()
130 //==================================================================
133 //==================================================================
134 VISU_ImplicitFunctionWidget::~VISU_ImplicitFunctionWidget()