-// VISU OBJECT : interactive object for VISU entities implementation
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// 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
+// 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.
//
+// 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 <vtkObjectFactory.h>
#include <vtkActor2D.h>
#include <vtkCoordinate.h>
#include <vtkRenderer.h>
#include <vtkScalarsToColors.h>
-#include <vtkLookupTable.h>
#include <vtkTextProperty.h>
-#include <vtkScalarBarActor.h>
-#include <vtkIdType.h>
+#include <vtkType.h>
#include <string.h>
-//----------------------------------------------------------------------------
-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);
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();
void
VISU_ScalarBarCtrl
::SetRangeLocal(vtkFloatingPointType theMin,
- vtkFloatingPointType theMax)
+ vtkFloatingPointType theMax)
{
myLocalLookupTable->SetTableRange(theMin,theMax);
}
void
VISU_ScalarBarCtrl
::SetRangeGlobal(vtkFloatingPointType theMin,
- vtkFloatingPointType theMax)
+ vtkFloatingPointType theMax)
{
myGlobalLookupTable->SetTableRange(theMin,theMax);
}
//----------------------------------------------------------------------------
-vtkScalarBarActor*
+VISU_ScalarBarActor*
VISU_ScalarBarCtrl
::GetLocalBar()
{
return myLocalScalarBar;
}
-vtkScalarBarActor*
+VISU_ScalarBarActor*
VISU_ScalarBarCtrl
::GetGlobalBar()
{
//----------------------------------------------------------------------------
-vtkLookupTable*
+VISU_LookupTable*
VISU_ScalarBarCtrl
::GetLocalTable()
{
return myLocalLookupTable;
}
-vtkLookupTable*
+VISU_LookupTable*
VISU_ScalarBarCtrl
::GetGlobalTable()
{
{
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 );
}
}
//----------------------------------------------------------------------------
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();
::UpdateForColor()
{
if(myMode == eGlobal){
- FillByColor(myLocalLookupTable,myGrey);
+ myLocalLookupTable->FillByColor( myGrey );
}else if(myMode == eLocal){
- FillByColor(myGlobalLookupTable,myGrey);
+ myGlobalLookupTable->FillByColor( myGrey );
}
}
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 );
}
}