1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // SALOME VTKViewer : build VTK viewer into Salome desktop
23 // File : VVTK_ImplicitFunctionWidget.cxx
24 // Author : Peter KURNEV
28 #include "VISU_ImplicitFunctionWidget.hxx"
30 #include <vtkFollower.h>
31 #include <vtkObjectFactory.h>
32 #include <vtkDataSet.h>
33 #include <vtkRenderWindow.h>
34 #include <vtkRenderer.h>
35 #include <vtkDataSet.h>
36 #include <vtkImplicitFunction.h>
37 #include <vtkMapper.h>
39 vtkStandardNewMacro(VISU_UnScaledActor);
41 //====================================================================
42 // function: VISU_UnScaledActor
44 //====================================================================
45 VISU_UnScaledActor::VISU_UnScaledActor()
47 for (int i=0; i<3; ++i){
52 //====================================================================
53 // function: SetCenter
55 //====================================================================
56 void VISU_UnScaledActor::SetCenter(vtkFloatingPointType *pC)
58 for (int i=0; i<3; ++i){
62 //====================================================================
65 //====================================================================
66 vtkFloatingPointType* VISU_UnScaledActor::GetBounds()
68 Superclass::GetBounds();
70 for (int i=0; i<3; ++i){
71 Bounds[2*i]=myCenter[i];
72 Bounds[2*i+1]=myCenter[i];
76 //====================================================================
79 //====================================================================
80 void VISU_UnScaledActor::Render(vtkRenderer *theRenderer)
83 vtkFloatingPointType P[2][3] = {{-1.0, -1.0, 0.0},{+1.0, +1.0, 0.0}};
84 theRenderer->ViewToWorld(P[0][0],P[0][1],P[0][2]);
85 theRenderer->ViewToWorld(P[1][0],P[1][1],P[1][2]);
86 vtkFloatingPointType aWorldDiag = sqrt((P[1][0]-P[0][0])*(P[1][0]-P[0][0])+
87 (P[1][1]-P[0][1])*(P[1][1]-P[0][1])+
88 (P[1][2]-P[0][2])*(P[1][2]-P[0][2]));
89 int* aSize = theRenderer->GetRenderWindow()->GetSize();
90 vtkFloatingPointType aWinDiag = sqrt(vtkFloatingPointType(aSize[0]*aSize[0]+aSize[1]*aSize[1]));
91 vtkDataSet* aDataSet = GetMapper()->GetInput();
92 vtkFloatingPointType aLength = aDataSet->GetLength();
93 vtkFloatingPointType aPrecision = 1.e-3;
94 vtkFloatingPointType anOldScale = GetScale()[0];
95 vtkFloatingPointType aScale =
96 mySize*aWorldDiag/aWinDiag/aLength*sqrt(vtkFloatingPointType(aSize[0])/vtkFloatingPointType(aSize[1]));
100 if(fabs(aScale - anOldScale)/aScale > aPrecision){
104 vtkFollower::Render(theRenderer);
107 //====================================================================
110 //====================================================================
111 void VISU_UnScaledActor::SetSize(int theSize)
116 //==================================================================
117 // class: VISU_ImplicitFunctionWidget
119 vtkCxxRevisionMacro(VISU_ImplicitFunctionWidget, "$Revision$");
120 //==================================================================
121 // function: VISU_ImplicitFunctionWidget
123 //==================================================================
124 VISU_ImplicitFunctionWidget::VISU_ImplicitFunctionWidget()
129 //==================================================================
132 //==================================================================
133 VISU_ImplicitFunctionWidget::~VISU_ImplicitFunctionWidget()