X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPIPELINE%2FVISU_ScalarBarCtrl.cxx;h=cb2807a213735c38487499d010617e5e6eec226d;hb=1f9d5836e71aac9c59192e955e63465940ef7a6f;hp=624159f5a83a2e46e70caa1851fb322031f410ab;hpb=e967b0415406f4f86ca2c9489abc8554b4c15dae;p=modules%2Fvisu.git diff --git a/src/PIPELINE/VISU_ScalarBarCtrl.cxx b/src/PIPELINE/VISU_ScalarBarCtrl.cxx index 624159f5..cb2807a2 100644 --- a/src/PIPELINE/VISU_ScalarBarCtrl.cxx +++ b/src/PIPELINE/VISU_ScalarBarCtrl.cxx @@ -1,106 +1,45 @@ -// VISU OBJECT : interactive object for VISU entities implementation +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// VISU OBJECT : interactive object for VISU entities implementation // File: VISU_ScalarBarCtrl.cxx // Author: Peter KURNEV // Module : VISU - +// #include "VISU_ScalarBarCtrl.hxx" +#include "VISU_LookupTable.hxx" +#include "VISU_ScalarBarActor.hxx" #include #include #include #include #include -#include #include -#include -#include +#include #include -//---------------------------------------------------------------------------- -namespace -{ - inline - void - MarkValueByColor(vtkLookupTable* theTable, - vtkFloatingPointType theValue, - unsigned char* theColor) - { - vtkIdType anIndex = theTable->GetIndex(theValue); - unsigned char *aTablePtr = theTable->GetPointer(anIndex); - aTablePtr[0] = theColor[0]; - aTablePtr[1] = theColor[1]; - aTablePtr[2] = theColor[2]; - } - - inline - void - CopyColor(unsigned char* theTaget, const unsigned char* theSource) - { - theTaget[0] = theSource[0]; - theTaget[1] = theSource[1]; - theTaget[2] = theSource[2]; - } - - void - FillByColor(vtkLookupTable* theTable, - unsigned char* theColor) - { - vtkIdType aNbColors = theTable->GetNumberOfColors(); - for(int i = 0; i < aNbColors; i++){ - unsigned char *aTablePtr = theTable->GetPointer(i); - CopyColor(aTablePtr,theColor); - } - } - - void - MakeBiColor(vtkLookupTable* theTable) - { - unsigned char aRedPtr[3] = {255, 0, 0}; - unsigned char aBluePtr[3] = {0, 0, 255}; - - vtkFloatingPointType aRange[2]; - theTable->GetTableRange(aRange); - vtkIdType aNbColors = theTable->GetNumberOfColors(); - - vtkFloatingPointType aDelta = (aRange[1]-aRange[0])/aNbColors; - vtkFloatingPointType aValue = aRange[0]+0.5*aDelta; - for(int i = 0; i < aNbColors; i++){ - vtkIdType anIndex = theTable->GetIndex(aValue); - unsigned char* aTablePtr = theTable->GetPointer(anIndex); - if(aValue > 0.0){ - CopyColor(aTablePtr,aRedPtr); - }else{ - CopyColor(aTablePtr,aBluePtr); - } - aValue += aDelta; - } - } -} - - //---------------------------------------------------------------------------- vtkStandardNewMacro(VISU_ScalarBarCtrl); @@ -119,18 +58,18 @@ VISU_ScalarBarCtrl SetMode(eSimple); // Initilize global scalar bar - myGlobalLookupTable = vtkLookupTable::New(); + myGlobalLookupTable = VISU_LookupTable::New(); myGlobalLookupTable->SetHueRange(0.667,0.0); - myGlobalScalarBar = vtkScalarBarActor::New(); + myGlobalScalarBar = VISU_ScalarBarActor::New(); myGlobalScalarBar->SetLookupTable(myGlobalLookupTable); myGlobalLookupTable->Delete(); // Initilize local scalar bar - myLocalLookupTable = vtkLookupTable::New(); + myLocalLookupTable = VISU_LookupTable::New(); myLocalLookupTable->SetHueRange(0.667,0.0); - myLocalScalarBar = vtkScalarBarActor::New(); + myLocalScalarBar = VISU_ScalarBarActor::New(); myLocalScalarBar->SetLookupTable(myLocalLookupTable); myLocalLookupTable->Delete(); @@ -214,7 +153,7 @@ VISU_ScalarBarCtrl void VISU_ScalarBarCtrl ::SetRangeLocal(vtkFloatingPointType theMin, - vtkFloatingPointType theMax) + vtkFloatingPointType theMax) { myLocalLookupTable->SetTableRange(theMin,theMax); } @@ -231,7 +170,7 @@ VISU_ScalarBarCtrl void VISU_ScalarBarCtrl ::SetRangeGlobal(vtkFloatingPointType theMin, - vtkFloatingPointType theMax) + vtkFloatingPointType theMax) { myGlobalLookupTable->SetTableRange(theMin,theMax); } @@ -245,14 +184,14 @@ VISU_ScalarBarCtrl //---------------------------------------------------------------------------- -vtkScalarBarActor* +VISU_ScalarBarActor* VISU_ScalarBarCtrl ::GetLocalBar() { return myLocalScalarBar; } -vtkScalarBarActor* +VISU_ScalarBarActor* VISU_ScalarBarCtrl ::GetGlobalBar() { @@ -261,14 +200,14 @@ VISU_ScalarBarCtrl //---------------------------------------------------------------------------- -vtkLookupTable* +VISU_LookupTable* VISU_ScalarBarCtrl ::GetLocalTable() { return myLocalLookupTable; } -vtkLookupTable* +VISU_LookupTable* VISU_ScalarBarCtrl ::GetGlobalTable() { @@ -435,16 +374,16 @@ VISU_ScalarBarCtrl { if(myMarked){ if(myMode == eGlobal){ - MarkValueByColor(myGlobalLookupTable, myMarkedValue, myBlack); + myGlobalLookupTable->MarkValueByColor( myMarkedValue, myBlack ); }else{ - MarkValueByColor(myLocalLookupTable, myMarkedValue, myBlack); + myLocalLookupTable->MarkValueByColor( myMarkedValue, myBlack ); } } if(myGlobalRangeIsDefined){ vtkFloatingPointType aLocalRange[2]; myLocalLookupTable->GetTableRange(aLocalRange); - MarkValueByColor(myGlobalLookupTable, aLocalRange[0], myBlack); - MarkValueByColor(myGlobalLookupTable, aLocalRange[1], myBlack); + myGlobalLookupTable->MarkValueByColor( aLocalRange[0], myBlack ); + myGlobalLookupTable->MarkValueByColor( aLocalRange[1], myBlack ); } } @@ -452,9 +391,9 @@ VISU_ScalarBarCtrl //---------------------------------------------------------------------------- void VISU_ScalarBarCtrl -::PrepareTables(vtkScalarBarActor* theScalarBarActor, - vtkLookupTable *theLookupTable, - vtkIdType theId) +::PrepareTables(VISU_ScalarBarActor* theScalarBarActor, + VISU_LookupTable *theLookupTable, + vtkIdType theId) { vtkCoordinate * aCoordinate = theScalarBarActor->GetPositionCoordinate(); aCoordinate->SetCoordinateSystemToNormalizedViewport(); @@ -490,9 +429,9 @@ VISU_ScalarBarCtrl ::UpdateForColor() { if(myMode == eGlobal){ - FillByColor(myLocalLookupTable,myGrey); + myLocalLookupTable->FillByColor( myGrey ); }else if(myMode == eLocal){ - FillByColor(myGlobalLookupTable,myGrey); + myGlobalLookupTable->FillByColor( myGrey ); } } @@ -506,15 +445,15 @@ VISU_ScalarBarCtrl myLocalLookupTable->Build(); if(myMode == eSimple){ - MakeBiColor(myLocalLookupTable); + myLocalLookupTable->MakeBiColor(); return; } if(myMode == eGlobal){ - MakeBiColor(myGlobalLookupTable); - FillByColor(myLocalLookupTable,myGrey); + myGlobalLookupTable->MakeBiColor(); + myLocalLookupTable->FillByColor( myGrey ); }else if(myMode == eLocal){ - MakeBiColor(myLocalLookupTable); - FillByColor(myGlobalLookupTable,myGrey); + myLocalLookupTable->MakeBiColor(); + myGlobalLookupTable->FillByColor( myGrey ); } }