mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-16 10:08:36 +03:00
0025785: Visualization - introduce AIS_ColorScale presentation for Color Scale
Color scale is implemented on AIS. Draw command vcolorscale now works with AIS_ColorScale. In a qt sample VoxelDemo there was added a field AIS_ColorScale myColorsScale to control a color scale. Method displayColorScale and other methods were changed in order to work with this field.
This commit is contained in:
parent
61b0191c54
commit
7a324550c8
@ -2,6 +2,7 @@
|
|||||||
#define APPLICATION_H
|
#define APPLICATION_H
|
||||||
|
|
||||||
#include <qmainwindow.h>
|
#include <qmainwindow.h>
|
||||||
|
#include <AIS_ColorScale.hxx>
|
||||||
#include <AIS_Shape.hxx>
|
#include <AIS_Shape.hxx>
|
||||||
#include <Voxel_Prs.hxx>
|
#include <Voxel_Prs.hxx>
|
||||||
#include <Voxel_BoolDS.hxx>
|
#include <Voxel_BoolDS.hxx>
|
||||||
@ -93,6 +94,7 @@ private:
|
|||||||
Handle(Voxel_Prs) myVoxels;
|
Handle(Voxel_Prs) myVoxels;
|
||||||
Voxel_BoolDS* myBoolVoxels;
|
Voxel_BoolDS* myBoolVoxels;
|
||||||
Voxel_ColorDS* myColorVoxels;
|
Voxel_ColorDS* myColorVoxels;
|
||||||
|
Handle(AIS_ColorScale) myColorScale;
|
||||||
int myNbX;
|
int myNbX;
|
||||||
int myNbY;
|
int myNbY;
|
||||||
int myNbZ;
|
int myNbZ;
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
#include <BRepPrimAPI_MakeTorus.hxx>
|
#include <BRepPrimAPI_MakeTorus.hxx>
|
||||||
#include <BRepPrimAPI_MakeSphere.hxx>
|
#include <BRepPrimAPI_MakeSphere.hxx>
|
||||||
#include <BRepPrimAPI_MakeCylinder.hxx>
|
#include <BRepPrimAPI_MakeCylinder.hxx>
|
||||||
#include <Aspect_ColorScale.hxx>
|
|
||||||
|
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
@ -311,6 +310,10 @@ Application::Application()
|
|||||||
|
|
||||||
myBoolVoxels = 0;
|
myBoolVoxels = 0;
|
||||||
myColorVoxels = 0;
|
myColorVoxels = 0;
|
||||||
|
myColorScale = new AIS_ColorScale;
|
||||||
|
myColorScale->SetZLayer (Graphic3d_ZLayerId_TopOSD);
|
||||||
|
myColorScale->SetTransformPersistence (Graphic3d_TMF_2d, gp_Pnt (-1,-1,0));
|
||||||
|
|
||||||
|
|
||||||
myDisplayedXMin = -DBL_MAX;
|
myDisplayedXMin = -DBL_MAX;
|
||||||
myDisplayedXMax = DBL_MAX;
|
myDisplayedXMax = DBL_MAX;
|
||||||
@ -437,7 +440,7 @@ void Application::open()
|
|||||||
if (myColorVoxels)
|
if (myColorVoxels)
|
||||||
displayColorScale();
|
displayColorScale();
|
||||||
else
|
else
|
||||||
myViewer->getView()->ColorScaleErase();
|
myViewer->getIC()->Erase(myColorScale);
|
||||||
|
|
||||||
myViewer->getView()->FitAll();
|
myViewer->getView()->FitAll();
|
||||||
|
|
||||||
@ -858,7 +861,7 @@ void Application::testROctBoolDS()
|
|||||||
myVoxels->SetTriangulation(empty);
|
myVoxels->SetTriangulation(empty);
|
||||||
myVoxels->SetROctBoolVoxels(ds2);
|
myVoxels->SetROctBoolVoxels(ds2);
|
||||||
myViewer->getIC()->Display(myVoxels, false);
|
myViewer->getIC()->Display(myVoxels, false);
|
||||||
myViewer->getView()->ColorScaleErase();
|
myViewer->getIC()->Erase(myColorScale);
|
||||||
myViewer->getView()->FitAll();
|
myViewer->getView()->FitAll();
|
||||||
myViewer->getSelector().SetVoxels(*ds2);
|
myViewer->getSelector().SetVoxels(*ds2);
|
||||||
}
|
}
|
||||||
@ -1540,7 +1543,7 @@ void Application::convert(const int ivoxel)
|
|||||||
if (myColorVoxels)
|
if (myColorVoxels)
|
||||||
displayColorScale();
|
displayColorScale();
|
||||||
else
|
else
|
||||||
myViewer->getView()->ColorScaleErase();
|
myViewer->getIC()->Erase(myColorScale);
|
||||||
|
|
||||||
myViewer->getView()->FitAll();
|
myViewer->getView()->FitAll();
|
||||||
}
|
}
|
||||||
@ -1718,7 +1721,7 @@ void Application::display(Voxel_VoxelDisplayMode mode)
|
|||||||
if (myColorVoxels)
|
if (myColorVoxels)
|
||||||
displayColorScale();
|
displayColorScale();
|
||||||
else
|
else
|
||||||
myViewer->getView()->ColorScaleErase();
|
myViewer->getIC()->Erase(myColorScale);
|
||||||
|
|
||||||
myViewer->getIC()->Redisplay(myVoxels, true);
|
myViewer->getIC()->Redisplay(myVoxels, true);
|
||||||
}
|
}
|
||||||
@ -1745,16 +1748,19 @@ void Application::displayNearestBoxes()
|
|||||||
|
|
||||||
void Application::displayColorScale()
|
void Application::displayColorScale()
|
||||||
{
|
{
|
||||||
Handle(Aspect_ColorScale) color_scale = myViewer->getView()->ColorScale();
|
if (myColorScale.IsNull())
|
||||||
if (!color_scale.IsNull())
|
{
|
||||||
|
myColorScale = new AIS_ColorScale;
|
||||||
|
}
|
||||||
|
if (!myColorScale.IsNull())
|
||||||
{
|
{
|
||||||
int nb_colors = 1<<4 /* 4 bits */;
|
int nb_colors = 1<<4 /* 4 bits */;
|
||||||
color_scale->SetRange(0, nb_colors - 1);
|
myColorScale->SetRange(0, nb_colors - 1);
|
||||||
color_scale->SetNumberOfIntervals(nb_colors);
|
myColorScale->SetNumberOfIntervals(nb_colors);
|
||||||
color_scale->SetPosition(0.01, 0.5 - 0.01);
|
myColorScale->SetPosition(0.01, 0.5 - 0.01);
|
||||||
color_scale->SetSize(0.5 - 0.01, 0.5 - 0.01);
|
myColorScale->SetSize(0.5 - 0.01, 0.5 - 0.01);
|
||||||
}
|
}
|
||||||
myViewer->getView()->ColorScaleDisplay();
|
myViewer->getIC()->Display(myColorScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::displayWaves()
|
void Application::displayWaves()
|
||||||
@ -1865,7 +1871,7 @@ void Application::initPrs()
|
|||||||
for (int icolor = 0; icolor < nb_colors; icolor++)
|
for (int icolor = 0; icolor < nb_colors; icolor++)
|
||||||
{
|
{
|
||||||
Quantity_Color color;
|
Quantity_Color color;
|
||||||
Aspect_ColorScale::FindColor(icolor, 0, nb_colors - 1, nb_colors, color);
|
AIS_ColorScale::FindColor(icolor, 0, nb_colors - 1, nb_colors, color);
|
||||||
colors->SetValue(icolor, color);
|
colors->SetValue(icolor, color);
|
||||||
}
|
}
|
||||||
myVoxels->SetColors(colors);
|
myVoxels->SetColors(colors);
|
||||||
|
785
src/AIS/AIS_ColorScale.cxx
Normal file
785
src/AIS/AIS_ColorScale.cxx
Normal file
@ -0,0 +1,785 @@
|
|||||||
|
// Created on: 2015-02-03
|
||||||
|
// Copyright (c) 2015 OPEN CASCADE SAS
|
||||||
|
//
|
||||||
|
// This file is part of Open CASCADE Technology software library.
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or modify it under
|
||||||
|
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||||
|
// by the Free Software Foundation, with special exception defined in the file
|
||||||
|
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||||
|
// distribution for complete text of the license and disclaimer of any warranty.
|
||||||
|
//
|
||||||
|
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||||
|
// commercial license or contractual agreement.
|
||||||
|
|
||||||
|
#include <AIS_ColorScale.hxx>
|
||||||
|
#include <AIS_InteractiveContext.hxx>
|
||||||
|
#include <Aspect_TypeOfColorScaleData.hxx>
|
||||||
|
#include <Aspect_TypeOfColorScalePosition.hxx>
|
||||||
|
#include <Aspect_Window.hxx>
|
||||||
|
#include <Geom_Line.hxx>
|
||||||
|
#include <GeomAdaptor_Curve.hxx>
|
||||||
|
#include <Graphic3d_ArrayOfPolygons.hxx>
|
||||||
|
#include <Graphic3d_ArrayOfPolylines.hxx>
|
||||||
|
#include <Graphic3d_AspectFillArea3d.hxx>
|
||||||
|
#include <Graphic3d_AspectText3d.hxx>
|
||||||
|
#include <Graphic3d_GraphicDriver.hxx>
|
||||||
|
#include <Graphic3d_ArrayOfTriangles.hxx>
|
||||||
|
#include <Prs3d_LineAspect.hxx>
|
||||||
|
#include <Prs3d_Root.hxx>
|
||||||
|
#include <Prs3d_ShadingAspect.hxx>
|
||||||
|
#include <Prs3d_Text.hxx>
|
||||||
|
#include <Prs3d_TextAspect.hxx>
|
||||||
|
#include <SelectMgr_EntityOwner.hxx>
|
||||||
|
#include <SelectMgr_Selection.hxx>
|
||||||
|
#include <Select3D_SensitiveBox.hxx>
|
||||||
|
#include <Select3D_SensitiveSegment.hxx>
|
||||||
|
#include <StdPrs_Curve.hxx>
|
||||||
|
#include <V3d_Viewer.hxx>
|
||||||
|
#include <V3d_View.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : AIS_ColorScale
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
AIS_ColorScale::AIS_ColorScale() :
|
||||||
|
myMin (0.0),
|
||||||
|
myMax (1.0),
|
||||||
|
myTitle (""),
|
||||||
|
myFormat ("%.4g"),
|
||||||
|
myInterval (10),
|
||||||
|
myColorType (Aspect_TOCSD_AUTO),
|
||||||
|
myLabelType (Aspect_TOCSD_AUTO),
|
||||||
|
myAtBorder (Standard_True),
|
||||||
|
myReversed (Standard_False),
|
||||||
|
myLabelPos (Aspect_TOCSP_RIGHT),
|
||||||
|
myTitlePos (Aspect_TOCSP_CENTER),
|
||||||
|
myXPos (0),
|
||||||
|
myYPos (0),
|
||||||
|
myWidth (0.2),
|
||||||
|
myHeight (1),
|
||||||
|
myTextHeight(20)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetRange
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_ColorScale::GetRange (Standard_Real& theMin, Standard_Real& theMax) const
|
||||||
|
{
|
||||||
|
theMin = myMin;
|
||||||
|
theMax = myMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetLabel
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
TCollection_ExtendedString AIS_ColorScale::GetLabel (const Standard_Integer theIndex) const
|
||||||
|
{
|
||||||
|
if (GetLabelType() == Aspect_TOCSD_USER)
|
||||||
|
{
|
||||||
|
if (theIndex < 0
|
||||||
|
|| theIndex >= myLabels.Length())
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return myLabels.Value (theIndex + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const Standard_Real aVal = GetNumber (theIndex);
|
||||||
|
const TCollection_AsciiString aFormat = Format();
|
||||||
|
Standard_Character aBuf[1024];
|
||||||
|
sprintf (aBuf, aFormat.ToCString(), aVal);
|
||||||
|
return TCollection_ExtendedString (aBuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetColor
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Quantity_Color AIS_ColorScale::GetColor (const Standard_Integer theIndex) const
|
||||||
|
{
|
||||||
|
if (GetColorType() == Aspect_TOCSD_USER)
|
||||||
|
{
|
||||||
|
if (theIndex < 0
|
||||||
|
|| theIndex >= myColors.Length())
|
||||||
|
{
|
||||||
|
return Quantity_Color();
|
||||||
|
}
|
||||||
|
|
||||||
|
return myColors.Value (theIndex + 1);
|
||||||
|
}
|
||||||
|
return Quantity_Color (HueFromValue (theIndex, 0, GetNumberOfIntervals() - 1), 1.0, 1.0, Quantity_TOC_HLS);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetLabels
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_ColorScale::GetLabels (TColStd_SequenceOfExtendedString& theLabels) const
|
||||||
|
{
|
||||||
|
theLabels.Clear();
|
||||||
|
for (Standard_Integer i = 1; i <= myLabels.Length(); i++)
|
||||||
|
theLabels.Append (myLabels.Value (i));
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetColors
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_ColorScale::GetColors (Aspect_SequenceOfColor& theColors) const
|
||||||
|
{
|
||||||
|
theColors.Clear();
|
||||||
|
for (Standard_Integer i = 1; i <= myColors.Length(); i++)
|
||||||
|
theColors.Append (myColors.Value (i));
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetMin
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_ColorScale::SetMin (const Standard_Real theMin)
|
||||||
|
{
|
||||||
|
SetRange (theMin, GetMax());
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetMax
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_ColorScale::SetMax (const Standard_Real theMax)
|
||||||
|
{
|
||||||
|
SetRange (GetMin(), theMax);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetRange
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_ColorScale::SetRange (const Standard_Real theMin, const Standard_Real theMax)
|
||||||
|
{
|
||||||
|
if (myMin == theMin && myMax == theMax)
|
||||||
|
return;
|
||||||
|
|
||||||
|
myMin = Min (theMin, theMax);
|
||||||
|
myMax = Max (theMin, theMax);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetLabelType
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_ColorScale::SetLabelType (const Aspect_TypeOfColorScaleData theType)
|
||||||
|
{
|
||||||
|
if (myLabelType == theType)
|
||||||
|
return;
|
||||||
|
|
||||||
|
myLabelType = theType;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetColorType
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_ColorScale::SetColorType (const Aspect_TypeOfColorScaleData theType)
|
||||||
|
{
|
||||||
|
if (myColorType == theType)
|
||||||
|
return;
|
||||||
|
|
||||||
|
myColorType = theType;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetNumberOfIntervals
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_ColorScale::SetNumberOfIntervals (const Standard_Integer theNum)
|
||||||
|
{
|
||||||
|
if (myInterval == theNum || theNum < 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
myInterval = theNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetTitle
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_ColorScale::SetTitle (const TCollection_ExtendedString& theTitle)
|
||||||
|
{
|
||||||
|
if (myTitle == theTitle)
|
||||||
|
return;
|
||||||
|
|
||||||
|
myTitle = theTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetFormat
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_ColorScale::SetFormat (const TCollection_AsciiString& theFormat)
|
||||||
|
{
|
||||||
|
if (myFormat == theFormat)
|
||||||
|
return;
|
||||||
|
|
||||||
|
myFormat = theFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetLabel
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_ColorScale::SetLabel (const TCollection_ExtendedString& theLabel, const Standard_Integer theIndex)
|
||||||
|
{
|
||||||
|
Standard_Integer i = theIndex < 0 ? myLabels.Length() + 1 : theIndex + 1;
|
||||||
|
if (i <= myLabels.Length())
|
||||||
|
{
|
||||||
|
myLabels.SetValue (i, theLabel);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while (i > myLabels.Length())
|
||||||
|
myLabels.Append (TCollection_ExtendedString());
|
||||||
|
myLabels.SetValue (i, theLabel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetColor
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_ColorScale::SetColor (const Quantity_Color& theColor, const Standard_Integer theIndex)
|
||||||
|
{
|
||||||
|
Standard_Integer i = theIndex < 0 ? myColors.Length() + 1 : theIndex + 1;
|
||||||
|
if (i <= myColors.Length())
|
||||||
|
{
|
||||||
|
myColors.SetValue (i, theColor);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while (i > myColors.Length())
|
||||||
|
myColors.Append (Quantity_Color());
|
||||||
|
myColors.SetValue (i, theColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetLabels
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_ColorScale::SetLabels (const TColStd_SequenceOfExtendedString& theSeq)
|
||||||
|
{
|
||||||
|
myLabels.Clear();
|
||||||
|
for (Standard_Integer i = 1; i <= theSeq.Length(); i++)
|
||||||
|
myLabels.Append (theSeq.Value (i));
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetColors
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_ColorScale::SetColors (const Aspect_SequenceOfColor& theSeq)
|
||||||
|
{
|
||||||
|
myColors.Clear();
|
||||||
|
for (Standard_Integer i = 1; i <= theSeq.Length(); i++)
|
||||||
|
myColors.Append (theSeq.Value (i));
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetLabelPosition
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_ColorScale::SetLabelPosition (const Aspect_TypeOfColorScalePosition thePos)
|
||||||
|
{
|
||||||
|
if (myLabelPos == thePos)
|
||||||
|
return;
|
||||||
|
|
||||||
|
myLabelPos = thePos;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetTitlePosition
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_ColorScale::SetTitlePosition (const Aspect_TypeOfColorScalePosition thePos)
|
||||||
|
{
|
||||||
|
if (myTitlePos == thePos)
|
||||||
|
return;
|
||||||
|
|
||||||
|
myTitlePos = thePos;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetReversed
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_ColorScale::SetReversed (const Standard_Boolean theReverse)
|
||||||
|
{
|
||||||
|
if (myReversed == theReverse)
|
||||||
|
return;
|
||||||
|
|
||||||
|
myReversed = theReverse;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetLabelAtBorder
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_ColorScale::SetLabelAtBorder (const Standard_Boolean theOn)
|
||||||
|
{
|
||||||
|
if (myAtBorder == theOn)
|
||||||
|
return;
|
||||||
|
|
||||||
|
myAtBorder = theOn;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetPosition
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_ColorScale::GetPosition (Standard_Real& theX, Standard_Real& theY) const
|
||||||
|
{
|
||||||
|
theX = myXPos;
|
||||||
|
theY = myYPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetPosition
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_ColorScale::SetPosition (const Standard_Real theX, const Standard_Real theY)
|
||||||
|
{
|
||||||
|
if (myXPos == theX && myYPos == theY)
|
||||||
|
return;
|
||||||
|
|
||||||
|
myXPos = theX;
|
||||||
|
myYPos = theY;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetXPosition
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_ColorScale::SetXPosition (const Standard_Real theX)
|
||||||
|
{
|
||||||
|
SetPosition (theX, GetYPosition());
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetYPosition
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_ColorScale::SetYPosition (const Standard_Real theY)
|
||||||
|
{
|
||||||
|
SetPosition (GetXPosition(), theY);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetSize
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_ColorScale::GetSize (Standard_Real& theWidth, Standard_Real& theHeight) const
|
||||||
|
{
|
||||||
|
theWidth = myWidth;
|
||||||
|
theHeight = myHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetSize
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_ColorScale::SetSize (const Standard_Real theWidth, const Standard_Real theHeight)
|
||||||
|
{
|
||||||
|
if (myWidth == theWidth && myHeight == theHeight)
|
||||||
|
return;
|
||||||
|
|
||||||
|
myWidth = theWidth;
|
||||||
|
myHeight = theHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetWidth
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_ColorScale::SetWidth (const Standard_Real theWidth)
|
||||||
|
{
|
||||||
|
SetSize (theWidth, GetHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetHeight
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_ColorScale::SetHeight (const Standard_Real theHeight)
|
||||||
|
{
|
||||||
|
SetSize (GetWidth(), theHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SizeHint
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_ColorScale::SizeHint (Standard_Integer& theWidth, Standard_Integer& theHeight) const
|
||||||
|
{
|
||||||
|
Standard_Integer aNum = GetNumberOfIntervals();
|
||||||
|
|
||||||
|
Standard_Integer aSpacer = 5;
|
||||||
|
Standard_Integer aTextWidth = 0;
|
||||||
|
Standard_Integer aTextHeight = TextHeight ("");
|
||||||
|
Standard_Integer aColorWidth = 20;
|
||||||
|
|
||||||
|
if (GetLabelPosition() != Aspect_TOCSP_NONE)
|
||||||
|
for (Standard_Integer idx = 0; idx < aNum; idx++)
|
||||||
|
aTextWidth = Max (aTextWidth, TextWidth (GetLabel (idx + 1)));
|
||||||
|
|
||||||
|
Standard_Integer aScaleWidth = 0;
|
||||||
|
Standard_Integer aScaleHeight = 0;
|
||||||
|
|
||||||
|
Standard_Integer aTitleWidth = 0;
|
||||||
|
Standard_Integer aTitleHeight = 0;
|
||||||
|
|
||||||
|
if (IsLabelAtBorder())
|
||||||
|
{
|
||||||
|
aNum++;
|
||||||
|
if (GetTitle().Length())
|
||||||
|
aTitleHeight += 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
aScaleWidth = aColorWidth + aTextWidth + ( aTextWidth ? 3 : 2 ) * aSpacer;
|
||||||
|
aScaleHeight = (Standard_Integer)( 1.5 * ( aNum + 1 ) * aTextHeight );
|
||||||
|
|
||||||
|
if (GetTitle().Length())
|
||||||
|
{
|
||||||
|
aTitleHeight = TextHeight (GetTitle()) + aSpacer;
|
||||||
|
aTitleWidth = TextWidth (GetTitle()) + 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
theWidth = Max (aTitleWidth, aScaleWidth);
|
||||||
|
theHeight = aScaleHeight + aTitleHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : Format
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
TCollection_AsciiString AIS_ColorScale::Format() const
|
||||||
|
{
|
||||||
|
return GetFormat();
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetNumber
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Real AIS_ColorScale::GetNumber (const Standard_Integer theIndex) const
|
||||||
|
{
|
||||||
|
Standard_Real aNum = 0;
|
||||||
|
if (GetNumberOfIntervals() > 0)
|
||||||
|
aNum = GetMin() + theIndex * ( Abs (GetMax() - GetMin()) / GetNumberOfIntervals() );
|
||||||
|
return aNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : HueFromValue
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Integer AIS_ColorScale::HueFromValue (const Standard_Integer theValue,
|
||||||
|
const Standard_Integer theMin, const Standard_Integer theMax)
|
||||||
|
{
|
||||||
|
Standard_Integer aMinLimit (0), aMaxLimit (230);
|
||||||
|
|
||||||
|
Standard_Integer aHue = aMaxLimit;
|
||||||
|
if (theMin != theMax)
|
||||||
|
aHue = (Standard_Integer)( aMaxLimit - ( aMaxLimit - aMinLimit ) * ( theValue - theMin ) / ( theMax - theMin ) );
|
||||||
|
|
||||||
|
aHue = Min (Max (aMinLimit, aHue), aMaxLimit);
|
||||||
|
|
||||||
|
return aHue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : FindColor
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean AIS_ColorScale::FindColor (const Standard_Real theValue,
|
||||||
|
Quantity_Color& theColor) const
|
||||||
|
{
|
||||||
|
return FindColor (theValue, myMin, myMax, myInterval, theColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : FindColor
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean AIS_ColorScale::FindColor (const Standard_Real theValue,
|
||||||
|
const Standard_Real theMin,
|
||||||
|
const Standard_Real theMax,
|
||||||
|
const Standard_Integer theColorsCount,
|
||||||
|
Quantity_Color& theColor)
|
||||||
|
{
|
||||||
|
if (theValue < theMin || theValue > theMax || theMax < theMin)
|
||||||
|
return Standard_False;
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Standard_Real anIntervNumber = 0;
|
||||||
|
if(Abs (theMax-theMin) > Precision::Approximation())
|
||||||
|
anIntervNumber = Floor (Standard_Real (theColorsCount) * ( theValue - theMin ) / ( theMax - theMin ));
|
||||||
|
|
||||||
|
Standard_Integer anInterv = Standard_Integer (anIntervNumber);
|
||||||
|
|
||||||
|
theColor = Quantity_Color (HueFromValue (anInterv, 0, theColorsCount - 1), 1.0, 1.0, Quantity_TOC_HLS);
|
||||||
|
|
||||||
|
return Standard_True;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : Compute
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_ColorScale::Compute(const Handle(PrsMgr_PresentationManager3d)& /*thePresentationManager*/,
|
||||||
|
const Handle(Prs3d_Presentation)& thePresentation,
|
||||||
|
const Standard_Integer /*theMode*/)
|
||||||
|
{
|
||||||
|
Standard_Integer aWinWidth(0), aWinHeight(0);
|
||||||
|
Handle(V3d_Viewer) aViewer= GetContext()->CurrentViewer();
|
||||||
|
aViewer->InitActiveViews();
|
||||||
|
aViewer->ActiveView()->Window()->Size (aWinWidth, aWinHeight);
|
||||||
|
Quantity_Color aBgColor = aViewer->ActiveView()->BackgroundColor();
|
||||||
|
Standard_Integer aNum = GetNumberOfIntervals();
|
||||||
|
Aspect_TypeOfColorScalePosition aLabPos = GetLabelPosition();
|
||||||
|
|
||||||
|
Standard_Integer aSpacer = 5;
|
||||||
|
Standard_Integer aTextWidth = 0;
|
||||||
|
Standard_Integer aTextHeight = myTextHeight;
|
||||||
|
Standard_Boolean toDrawLabel = GetLabelPosition() != Aspect_TOCSP_NONE;
|
||||||
|
TCollection_ExtendedString aTitle = GetTitle();
|
||||||
|
Standard_Integer aTitleHeight = aSpacer;
|
||||||
|
Standard_Integer aGray = (Standard_Integer)(255 * ( aBgColor.Red() * 11 + aBgColor.Green() * 16 + aBgColor.Blue() * 5 ) / 32);
|
||||||
|
Quantity_Color aFgColor (aGray < 128 ? Quantity_NOC_WHITE : Quantity_NOC_BLACK);
|
||||||
|
|
||||||
|
// Draw title
|
||||||
|
if (aTitle.Length())
|
||||||
|
{
|
||||||
|
aTitleHeight += myTextHeight + aSpacer;
|
||||||
|
DrawText (thePresentation, aTitle, (Standard_Integer)myXPos + aSpacer, aWinHeight - ((Standard_Integer)myYPos - 2 * aSpacer + aTitleHeight), aFgColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
Standard_Boolean toReverse = IsReversed();
|
||||||
|
|
||||||
|
Aspect_SequenceOfColor aColors;
|
||||||
|
TColStd_SequenceOfExtendedString aLabels;
|
||||||
|
for (Standard_Integer i = 0; i < aNum; i++)
|
||||||
|
{
|
||||||
|
if (toReverse)
|
||||||
|
{
|
||||||
|
aColors.Prepend (GetColor (i));
|
||||||
|
aLabels.Prepend (GetLabel (i));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
aColors.Append (GetColor (i));
|
||||||
|
aLabels.Append (GetLabel (i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsLabelAtBorder())
|
||||||
|
{
|
||||||
|
if (toReverse)
|
||||||
|
aLabels.Prepend (GetLabel (aNum));
|
||||||
|
else
|
||||||
|
aLabels.Append (GetLabel (aNum));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (toDrawLabel)
|
||||||
|
for (Standard_Integer i = 1; i <= aLabels.Length(); i++)
|
||||||
|
aTextWidth = Max (aTextWidth, TextWidth (aLabels.Value (i)));
|
||||||
|
|
||||||
|
Standard_Integer aLabCount = aLabels.Length();
|
||||||
|
|
||||||
|
Standard_Real aSpc = ( aWinHeight - ( ( Min (aLabCount, 2) + Abs (aLabCount - aNum - 1) ) * aTextHeight ) - aTitleHeight );
|
||||||
|
Standard_Real aVal = aSpc != 0 ? 1.0 * ( aLabCount - Min (aLabCount, 0) ) * aTextHeight / aSpc : 0;
|
||||||
|
Standard_Real anIPart;
|
||||||
|
Standard_Real anFPart = modf (aVal, &anIPart);
|
||||||
|
Standard_Integer aFilter = (Standard_Integer)anIPart + ( anFPart != 0 ? 1 : 0 );
|
||||||
|
|
||||||
|
Standard_Real aStep = 1.0 * ( aWinHeight - (aLabCount - aNum + Abs (aLabCount - aNum - 1)) * aTextHeight - aTitleHeight ) / aNum;
|
||||||
|
|
||||||
|
Standard_Integer anAscent = 0;
|
||||||
|
Standard_Integer aColorWidth = Max (5, Min (20, aWinWidth - aTextWidth - 3 * aSpacer));
|
||||||
|
if (aLabPos == Aspect_TOCSP_CENTER || !toDrawLabel)
|
||||||
|
aColorWidth = aWinWidth - 2 * aSpacer;
|
||||||
|
|
||||||
|
// Draw colors
|
||||||
|
Standard_Integer aX = (Standard_Integer)myXPos + aSpacer;
|
||||||
|
if (aLabPos == Aspect_TOCSP_LEFT)
|
||||||
|
aX += aTextWidth + ( aTextWidth ? 1 : 0 ) * aSpacer;
|
||||||
|
|
||||||
|
Standard_Real anOffset = 1.0 * aTextHeight / 2 * ( aLabCount - aNum + Abs (aLabCount - aNum - 1) );
|
||||||
|
anOffset += 2*aSpacer;
|
||||||
|
Handle (Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePresentation);
|
||||||
|
Handle (Graphic3d_ArrayOfTriangles) aPrim;
|
||||||
|
Standard_Integer anEdgesPerColor = 6;
|
||||||
|
Standard_Integer aVerticiesPerColor = 4;
|
||||||
|
aPrim = new Graphic3d_ArrayOfTriangles (aColors.Length()*aVerticiesPerColor, aColors.Length()*anEdgesPerColor, 0, 1);
|
||||||
|
Standard_Integer aVertIndex = 1;
|
||||||
|
for (Standard_Integer i = 1; i <= aColors.Length() && aStep > 0; i++)
|
||||||
|
{
|
||||||
|
Standard_Integer aY = (Standard_Integer)( myYPos + ( i - 1 )* aStep + anOffset );
|
||||||
|
Standard_Integer aColorHeight = (Standard_Integer)( myYPos + ( i ) * aStep + anOffset ) - aY;
|
||||||
|
aPrim->AddVertex (gp_Pnt (aX, aY, 0.0), aColors.Value( i ));
|
||||||
|
aPrim->AddVertex (gp_Pnt (aX+aColorWidth, aY, 0.0), aColors.Value( i ));
|
||||||
|
aPrim->AddVertex (gp_Pnt (aX, aY+aColorHeight, 0.0), aColors.Value( i ));
|
||||||
|
aPrim->AddVertex (gp_Pnt (aX+aColorWidth, aY+aColorHeight, 0.0), aColors.Value( i ));
|
||||||
|
aPrim->AddEdge(aVertIndex);
|
||||||
|
aPrim->AddEdge(aVertIndex+1);
|
||||||
|
aPrim->AddEdge(aVertIndex+2);
|
||||||
|
aPrim->AddEdge(aVertIndex+1);
|
||||||
|
aPrim->AddEdge(aVertIndex+2);
|
||||||
|
aPrim->AddEdge(aVertIndex+3);
|
||||||
|
aVertIndex += 4;
|
||||||
|
}
|
||||||
|
aGroup->AddPrimitiveArray (aPrim);
|
||||||
|
|
||||||
|
if (aStep > 0)
|
||||||
|
DrawFrame (thePresentation, aX - 1, (Standard_Integer)(myYPos + anOffset - 1), aColorWidth + 2, (Standard_Integer)(aColors.Length() * aStep + 2), aFgColor);
|
||||||
|
|
||||||
|
// Draw Labels
|
||||||
|
anOffset = 1.0 * Abs (aLabCount - aNum - 1) * ( aStep - aTextHeight ) / 2 + 1.0 * Abs (aLabCount - aNum - 1) * aTextHeight / 2;
|
||||||
|
anOffset += 2*aSpacer;
|
||||||
|
if (toDrawLabel && aLabels.Length() && aFilter > 0)
|
||||||
|
{
|
||||||
|
Standard_Integer i1 = 0;
|
||||||
|
Standard_Integer i2 = aLabCount - 1;
|
||||||
|
Standard_Integer aLast1( i1 ), aLast2( i2 );
|
||||||
|
aX = (Standard_Integer)myXPos + aSpacer;
|
||||||
|
switch (aLabPos)
|
||||||
|
{
|
||||||
|
case Aspect_TOCSP_NONE:
|
||||||
|
case Aspect_TOCSP_LEFT:
|
||||||
|
break;
|
||||||
|
case Aspect_TOCSP_CENTER:
|
||||||
|
aX += ( aColorWidth - aTextWidth ) / 2;
|
||||||
|
break;
|
||||||
|
case Aspect_TOCSP_RIGHT:
|
||||||
|
aX += aColorWidth + aSpacer;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
while (i2 - i1 >= aFilter || ( i2 == 0 && i1 == 0 ))
|
||||||
|
{
|
||||||
|
Standard_Integer aPos1 = i1;
|
||||||
|
Standard_Integer aPos2 = aLabCount - 1 - i2;
|
||||||
|
if (aFilter && !( aPos1 % aFilter ))
|
||||||
|
{
|
||||||
|
DrawText (thePresentation, aLabels.Value (i1 + 1), aX, (Standard_Integer)( myYPos + i1 * aStep + anAscent + anOffset ), aFgColor);
|
||||||
|
aLast1 = i1;
|
||||||
|
}
|
||||||
|
if (aFilter && !( aPos2 % aFilter ))
|
||||||
|
{
|
||||||
|
DrawText (thePresentation, aLabels.Value (i2 + 1), aX, (Standard_Integer)( myYPos + i2 * aStep + anAscent + anOffset ), aFgColor);
|
||||||
|
aLast2 = i2;
|
||||||
|
}
|
||||||
|
i1++;
|
||||||
|
i2--;
|
||||||
|
}
|
||||||
|
Standard_Integer aPos = i1;
|
||||||
|
Standard_Integer i0 = -1;
|
||||||
|
while (aPos <= i2 && i0 == -1)
|
||||||
|
{
|
||||||
|
if (aFilter && !( aPos % aFilter ) && Abs (aPos - aLast1) >= aFilter && Abs (aPos - aLast2) >= aFilter)
|
||||||
|
i0 = aPos;
|
||||||
|
aPos++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i0 != -1)
|
||||||
|
DrawText (thePresentation, aLabels.Value (i0 + 1), aX, (Standard_Integer)( myYPos + i0 * aStep + anAscent + anOffset ), aFgColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : DrawFrame
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_ColorScale::DrawFrame (const Handle(Prs3d_Presentation)& thePresentation,
|
||||||
|
const Standard_Integer theX, const Standard_Integer theY,
|
||||||
|
const Standard_Integer theWidth, const Standard_Integer theHeight,
|
||||||
|
const Quantity_Color& theColor)
|
||||||
|
{
|
||||||
|
Handle (Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePresentation);
|
||||||
|
Handle(Graphic3d_ArrayOfPolylines) aPrim = new Graphic3d_ArrayOfPolylines(5);
|
||||||
|
aPrim->AddVertex (theX,theY,0.0);
|
||||||
|
aPrim->AddVertex (theX+theWidth,theY,0.0);
|
||||||
|
aPrim->AddVertex (theX+theWidth,theY+theHeight,0.0);
|
||||||
|
aPrim->AddVertex (theX,theY+theHeight,0.0);
|
||||||
|
aPrim->AddVertex (theX,theY,0.0);
|
||||||
|
Handle(Prs3d_LineAspect) anAspect = new Prs3d_LineAspect (theColor, Aspect_TOL_SOLID, 1.0);
|
||||||
|
anAspect->SetColor (theColor);
|
||||||
|
aGroup->SetPrimitivesAspect (anAspect->Aspect());
|
||||||
|
aGroup->AddPrimitiveArray (aPrim);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : DrawText
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_ColorScale::DrawText (const Handle(Prs3d_Presentation)& thePresentation,
|
||||||
|
const TCollection_ExtendedString& theText,
|
||||||
|
const Standard_Integer theX, const Standard_Integer theY,
|
||||||
|
const Quantity_Color& theColor)
|
||||||
|
{
|
||||||
|
if (!myDrawer->HasOwnTextAspect())
|
||||||
|
{
|
||||||
|
myDrawer->SetTextAspect (new Prs3d_TextAspect());
|
||||||
|
*myDrawer->TextAspect()->Aspect() = *myDrawer->Link()->TextAspect()->Aspect();
|
||||||
|
}
|
||||||
|
Handle(Prs3d_TextAspect) anAspect = myDrawer->TextAspect();
|
||||||
|
anAspect->SetColor (theColor);
|
||||||
|
anAspect->SetHeight (myTextHeight);
|
||||||
|
anAspect->SetHorizontalJustification (Graphic3d_HTA_LEFT);
|
||||||
|
anAspect->SetVerticalJustification (Graphic3d_VTA_BOTTOM);
|
||||||
|
anAspect->Aspect()->SetTextZoomable (Standard_True);
|
||||||
|
anAspect->Aspect()->SetTextAngle (0.0);
|
||||||
|
anAspect->Aspect()->SetTextFontAspect (Font_FA_Regular);
|
||||||
|
Prs3d_Text::Draw (thePresentation, anAspect, theText,gp_Pnt (theX,theY,0.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : TextWidth
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Integer AIS_ColorScale::TextWidth (const TCollection_ExtendedString& theText) const
|
||||||
|
{
|
||||||
|
Standard_Integer aWidth, anAscent, aDescent;
|
||||||
|
TextSize (theText, GetTextHeight(), aWidth, anAscent, aDescent);
|
||||||
|
return aWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : TextHeight
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Integer AIS_ColorScale::TextHeight (const TCollection_ExtendedString& theText) const
|
||||||
|
{
|
||||||
|
Standard_Integer aWidth, anAscent, aDescent;
|
||||||
|
TextSize (theText, GetTextHeight(), aWidth, anAscent, aDescent);
|
||||||
|
return anAscent+aDescent;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : TextSize
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_ColorScale::TextSize (const TCollection_ExtendedString& theText, const Standard_Integer theHeight, Standard_Integer& theWidth, Standard_Integer& theAscent, Standard_Integer& theDescent) const
|
||||||
|
{
|
||||||
|
Standard_ShortReal aWidth(10.0), anAscent(1.0), aDescent(1.0);
|
||||||
|
TCollection_AsciiString aText (theText.ToExtString(), '?');
|
||||||
|
GetContext()->CurrentViewer()->Driver()->TextSize (aText.ToCString(),(Standard_ShortReal)theHeight,aWidth,anAscent,aDescent);
|
||||||
|
theWidth = (Standard_Integer)aWidth;
|
||||||
|
theAscent = (Standard_Integer)anAscent;
|
||||||
|
theDescent = (Standard_Integer)aDescent;
|
||||||
|
}
|
@ -1,6 +1,5 @@
|
|||||||
// Created on: 2004-06-22
|
// Created on: 2015-02-03
|
||||||
// Created by: STV
|
// Copyright (c) 2015 OPEN CASCADE SAS
|
||||||
// Copyright (c) 2004-2014 OPEN CASCADE SAS
|
|
||||||
//
|
//
|
||||||
// This file is part of Open CASCADE Technology software library.
|
// This file is part of Open CASCADE Technology software library.
|
||||||
//
|
//
|
||||||
@ -13,36 +12,26 @@
|
|||||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||||
// commercial license or contractual agreement.
|
// commercial license or contractual agreement.
|
||||||
|
|
||||||
#ifndef _Aspect_ColorScale_HeaderFile
|
#ifndef _AIS_ColorScale_HeaderFile
|
||||||
#define _Aspect_ColorScale_HeaderFile
|
#define _AIS_ColorScale_HeaderFile
|
||||||
|
|
||||||
#include <Standard.hxx>
|
#include <AIS_InteractiveObject.hxx>
|
||||||
#include <Standard_Type.hxx>
|
|
||||||
|
|
||||||
#include <Standard_Real.hxx>
|
|
||||||
#include <TCollection_ExtendedString.hxx>
|
|
||||||
#include <TCollection_AsciiString.hxx>
|
|
||||||
#include <Standard_Integer.hxx>
|
|
||||||
#include <Aspect_TypeOfColorScaleData.hxx>
|
#include <Aspect_TypeOfColorScaleData.hxx>
|
||||||
#include <Standard_Boolean.hxx>
|
|
||||||
#include <Aspect_SequenceOfColor.hxx>
|
|
||||||
#include <TColStd_SequenceOfExtendedString.hxx>
|
|
||||||
#include <Aspect_TypeOfColorScalePosition.hxx>
|
#include <Aspect_TypeOfColorScalePosition.hxx>
|
||||||
#include <MMgt_TShared.hxx>
|
#include <Aspect_SequenceOfColor.hxx>
|
||||||
class Quantity_Color;
|
#include <Standard.hxx>
|
||||||
class TCollection_ExtendedString;
|
#include <Standard_DefineHandle.hxx>
|
||||||
class TCollection_AsciiString;
|
#include <TCollection_ExtendedString.hxx>
|
||||||
|
#include <TColStd_SequenceOfExtendedString.hxx>
|
||||||
|
|
||||||
|
|
||||||
class Aspect_ColorScale;
|
//! Class for drawing a custom color scale
|
||||||
DEFINE_STANDARD_HANDLE(Aspect_ColorScale, MMgt_TShared)
|
class AIS_ColorScale : public AIS_InteractiveObject {
|
||||||
|
|
||||||
//! Defines a color scale for viewer.
|
|
||||||
class Aspect_ColorScale : public MMgt_TShared
|
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
//! Default constructor.
|
||||||
|
Standard_EXPORT AIS_ColorScale();
|
||||||
|
|
||||||
//! Calculate color according passed value; returns true if value is in range or false, if isn't
|
//! Calculate color according passed value; returns true if value is in range or false, if isn't
|
||||||
Standard_EXPORT Standard_Boolean FindColor (const Standard_Real theValue, Quantity_Color& theColor) const;
|
Standard_EXPORT Standard_Boolean FindColor (const Standard_Real theValue, Quantity_Color& theColor) const;
|
||||||
@ -50,10 +39,10 @@ public:
|
|||||||
Standard_EXPORT static Standard_Boolean FindColor (const Standard_Real theValue, const Standard_Real theMin, const Standard_Real theMax, const Standard_Integer theColorsCount, Quantity_Color& theColor);
|
Standard_EXPORT static Standard_Boolean FindColor (const Standard_Real theValue, const Standard_Real theMin, const Standard_Real theMax, const Standard_Integer theColorsCount, Quantity_Color& theColor);
|
||||||
|
|
||||||
//! Returns minimal value of color scale;
|
//! Returns minimal value of color scale;
|
||||||
Standard_EXPORT Standard_Real GetMin() const;
|
Standard_EXPORT Standard_Real GetMin() const { return myMin; }
|
||||||
|
|
||||||
//! Returns maximal value of color scale;
|
//! Returns maximal value of color scale;
|
||||||
Standard_EXPORT Standard_Real GetMax() const;
|
Standard_EXPORT Standard_Real GetMax() const { return myMax; }
|
||||||
|
|
||||||
//! Returns minimal and maximal values of color scale;
|
//! Returns minimal and maximal values of color scale;
|
||||||
Standard_EXPORT void GetRange (Standard_Real& theMin, Standard_Real& theMax) const;
|
Standard_EXPORT void GetRange (Standard_Real& theMin, Standard_Real& theMax) const;
|
||||||
@ -61,23 +50,23 @@ public:
|
|||||||
//! Returns the type of labels;
|
//! Returns the type of labels;
|
||||||
//! Aspect_TOCSD_AUTO - labels as boundary values for intervals
|
//! Aspect_TOCSD_AUTO - labels as boundary values for intervals
|
||||||
//! Aspect_TOCSD_USER - user specified label is used
|
//! Aspect_TOCSD_USER - user specified label is used
|
||||||
Standard_EXPORT Aspect_TypeOfColorScaleData GetLabelType() const;
|
Standard_EXPORT Aspect_TypeOfColorScaleData GetLabelType() const { return myLabelType; }
|
||||||
|
|
||||||
//! Returns the type of colors;
|
//! Returns the type of colors;
|
||||||
//! Aspect_TOCSD_AUTO - value between Red and Blue
|
//! Aspect_TOCSD_AUTO - value between Red and Blue
|
||||||
//! Aspect_TOCSD_USER - user specified color from color map
|
//! Aspect_TOCSD_USER - user specified color from color map
|
||||||
Standard_EXPORT Aspect_TypeOfColorScaleData GetColorType() const;
|
Standard_EXPORT Aspect_TypeOfColorScaleData GetColorType() const { return myColorType; }
|
||||||
|
|
||||||
//! Returns the number of color scale intervals;
|
//! Returns the number of color scale intervals;
|
||||||
Standard_EXPORT Standard_Integer GetNumberOfIntervals() const;
|
Standard_EXPORT Standard_Integer GetNumberOfIntervals() const { return myInterval; }
|
||||||
|
|
||||||
//! Returns the color scale title string;
|
//! Returns the color scale title string;
|
||||||
Standard_EXPORT TCollection_ExtendedString GetTitle() const;
|
Standard_EXPORT TCollection_ExtendedString GetTitle() const { return myTitle; }
|
||||||
|
|
||||||
//! Returns the format for numbers.
|
//! Returns the format for numbers.
|
||||||
//! The same like format for function printf().
|
//! The same like format for function printf().
|
||||||
//! Used if GetLabelType() is TOCSD_AUTO;
|
//! Used if GetLabelType() is TOCSD_AUTO;
|
||||||
Standard_EXPORT TCollection_AsciiString GetFormat() const;
|
Standard_EXPORT TCollection_AsciiString GetFormat() const { return myFormat; }
|
||||||
|
|
||||||
//! Returns the user specified label with index <anIndex>.
|
//! Returns the user specified label with index <anIndex>.
|
||||||
//! Returns empty string if label not defined.
|
//! Returns empty string if label not defined.
|
||||||
@ -94,16 +83,16 @@ public:
|
|||||||
Standard_EXPORT void GetColors (Aspect_SequenceOfColor& theColors) const;
|
Standard_EXPORT void GetColors (Aspect_SequenceOfColor& theColors) const;
|
||||||
|
|
||||||
//! Returns the position of labels concerning color filled rectangles.
|
//! Returns the position of labels concerning color filled rectangles.
|
||||||
Standard_EXPORT Aspect_TypeOfColorScalePosition GetLabelPosition() const;
|
Standard_EXPORT Aspect_TypeOfColorScalePosition GetLabelPosition() const { return myLabelPos; }
|
||||||
|
|
||||||
//! Returns the position of color scale title.
|
//! Returns the position of color scale title.
|
||||||
Standard_EXPORT Aspect_TypeOfColorScalePosition GetTitlePosition() const;
|
Standard_EXPORT Aspect_TypeOfColorScalePosition GetTitlePosition() const { return myTitlePos; }
|
||||||
|
|
||||||
//! Returns true if the labels and colors used in reversed order.
|
//! Returns true if the labels and colors used in reversed order.
|
||||||
Standard_EXPORT Standard_Boolean IsReversed() const;
|
Standard_EXPORT Standard_Boolean IsReversed() const { return myReversed; }
|
||||||
|
|
||||||
//! Returns true if the labels placed at border of color filled rectangles.
|
//! Returns true if the labels placed at border of color filled rectangles.
|
||||||
Standard_EXPORT Standard_Boolean IsLabelAtBorder() const;
|
Standard_EXPORT Standard_Boolean IsLabelAtBorder() const { return myAtBorder; }
|
||||||
|
|
||||||
//! Sets the minimal value of color scale.
|
//! Sets the minimal value of color scale.
|
||||||
Standard_EXPORT void SetMin (const Standard_Real theMin);
|
Standard_EXPORT void SetMin (const Standard_Real theMin);
|
||||||
@ -161,10 +150,10 @@ public:
|
|||||||
Standard_EXPORT void GetSize (Standard_Real& theWidth, Standard_Real& theHeight) const;
|
Standard_EXPORT void GetSize (Standard_Real& theWidth, Standard_Real& theHeight) const;
|
||||||
|
|
||||||
//! Returns the width of color scale.
|
//! Returns the width of color scale.
|
||||||
Standard_EXPORT Standard_Real GetWidth() const;
|
Standard_EXPORT Standard_Real GetWidth() const { return myWidth; }
|
||||||
|
|
||||||
//! Returns the height of color scale.
|
//! Returns the height of color scale.
|
||||||
Standard_EXPORT Standard_Real GetHeight() const;
|
Standard_EXPORT Standard_Real GetHeight() const { return myHeight; }
|
||||||
|
|
||||||
//! Sets the size of color scale.
|
//! Sets the size of color scale.
|
||||||
Standard_EXPORT void SetSize (const Standard_Real theWidth, const Standard_Real theHeight);
|
Standard_EXPORT void SetSize (const Standard_Real theWidth, const Standard_Real theHeight);
|
||||||
@ -179,10 +168,10 @@ public:
|
|||||||
Standard_EXPORT void GetPosition (Standard_Real& theX, Standard_Real& theY) const;
|
Standard_EXPORT void GetPosition (Standard_Real& theX, Standard_Real& theY) const;
|
||||||
|
|
||||||
//! Returns the X position of color scale.
|
//! Returns the X position of color scale.
|
||||||
Standard_EXPORT Standard_Real GetXPosition() const;
|
Standard_EXPORT Standard_Real GetXPosition() const { return myXPos; }
|
||||||
|
|
||||||
//! Returns the height of color scale.
|
//! Returns the height of color scale.
|
||||||
Standard_EXPORT Standard_Real GetYPosition() const;
|
Standard_EXPORT Standard_Real GetYPosition() const { return myYPos; }
|
||||||
|
|
||||||
//! Sets the position of color scale.
|
//! Sets the position of color scale.
|
||||||
Standard_EXPORT void SetPosition (const Standard_Real theX, const Standard_Real theY);
|
Standard_EXPORT void SetPosition (const Standard_Real theX, const Standard_Real theY);
|
||||||
@ -194,82 +183,74 @@ public:
|
|||||||
Standard_EXPORT void SetYPosition (const Standard_Real theY);
|
Standard_EXPORT void SetYPosition (const Standard_Real theY);
|
||||||
|
|
||||||
//! Returns the height of text of color scale.
|
//! Returns the height of text of color scale.
|
||||||
Standard_EXPORT Standard_Integer GetTextHeight() const;
|
Standard_EXPORT Standard_Integer GetTextHeight() const { return myTextHeight; }
|
||||||
|
|
||||||
//! Sets the height of text of color scale.
|
//! Sets the height of text of color scale.
|
||||||
Standard_EXPORT void SetTextHeight (const Standard_Integer theHeight);
|
Standard_EXPORT void SetTextHeight (const Standard_Integer theHeight) { myTextHeight = theHeight; }
|
||||||
|
|
||||||
//! Draws a rectangle.
|
//! Returns the width of text.
|
||||||
//! @param theX [in] the X coordinate of rectangle position.
|
//! @param theText [in] the text of which to calculate width.
|
||||||
//! @param theY [in] the Y coordinate of rectangle position.
|
Standard_EXPORT Standard_Integer TextWidth (const TCollection_ExtendedString& theText) const;
|
||||||
//! @param theWidth [in] the width of rectangle.
|
|
||||||
//! @param theHeight [in] the height of rectangle.
|
//! Returns the height of text.
|
||||||
//! @param theColor [in] the color of rectangle.
|
//! @param theText [in] the text of which to calculate height.
|
||||||
//! @param theFilled [in] defines if rectangle must be filled.
|
Standard_EXPORT Standard_Integer TextHeight (const TCollection_ExtendedString& theText) const;
|
||||||
Standard_EXPORT virtual void PaintRect (const Standard_Integer theX, const Standard_Integer theY, const Standard_Integer theWidth, const Standard_Integer theHeight, const Quantity_Color& theColor, const Standard_Boolean theFilled = Standard_False) = 0;
|
|
||||||
|
Standard_EXPORT void TextSize (const TCollection_ExtendedString& theText, const Standard_Integer theHeight, Standard_Integer& theWidth, Standard_Integer& theAscent, Standard_Integer& theDescent) const;
|
||||||
|
|
||||||
|
|
||||||
|
DEFINE_STANDARD_RTTI(AIS_ColorScale,AIS_InteractiveObject)
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
//! Draws a frame.
|
||||||
|
//! @param theX [in] the X coordinate of frame position.
|
||||||
|
//! @param theY [in] the Y coordinate of frame position.
|
||||||
|
//! @param theWidth [in] the width of frame.
|
||||||
|
//! @param theHeight [in] the height of frame.
|
||||||
|
//! @param theColor [in] the color of frame.
|
||||||
|
Standard_EXPORT void DrawFrame (const Handle(Prs3d_Presentation)& thePresentation,
|
||||||
|
const Standard_Integer theX, const Standard_Integer theY,
|
||||||
|
const Standard_Integer theWidth, const Standard_Integer theHeight,
|
||||||
|
const Quantity_Color& theColor);
|
||||||
|
|
||||||
//! Draws a text.
|
//! Draws a text.
|
||||||
//! @param theText [in] the text to draw.
|
//! @param theText [in] the text to draw.
|
||||||
//! @param theX [in] the X coordinate of text position.
|
//! @param theX [in] the X coordinate of text position.
|
||||||
//! @param theY [in] the Y coordinate of text position.
|
//! @param theY [in] the Y coordinate of text position.
|
||||||
//! @param theColor [in] the color of text.
|
//! @param theColor [in] the color of text.
|
||||||
Standard_EXPORT virtual void PaintText (const TCollection_ExtendedString& theText, const Standard_Integer theX, const Standard_Integer theY, const Quantity_Color& theColor) = 0;
|
Standard_EXPORT void DrawText (const Handle(Prs3d_Presentation)& thePresentation,
|
||||||
|
const TCollection_ExtendedString& theText,
|
||||||
|
const Standard_Integer theX, const Standard_Integer theY,
|
||||||
|
const Quantity_Color& theColor);
|
||||||
|
|
||||||
//! Returns the width of text.
|
private:
|
||||||
//! @param theText [in] the text of which to calculate width.
|
|
||||||
Standard_EXPORT virtual Standard_Integer TextWidth (const TCollection_ExtendedString& theText) const = 0;
|
|
||||||
|
|
||||||
//! Returns the height of text.
|
|
||||||
//! @param theText [in] the text of which to calculate height.
|
|
||||||
Standard_EXPORT virtual Standard_Integer TextHeight (const TCollection_ExtendedString& theText) const = 0;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DEFINE_STANDARD_RTTI(Aspect_ColorScale,MMgt_TShared)
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
|
|
||||||
//! Default constructor.
|
|
||||||
Standard_EXPORT Aspect_ColorScale();
|
|
||||||
|
|
||||||
//! Returns the size of color scale.
|
//! Returns the size of color scale.
|
||||||
//! @param theWidth [out] the width of color scale.
|
//! @param theWidth [out] the width of color scale.
|
||||||
//! @param theHeight [out] the height of color scale.
|
//! @param theHeight [out] the height of color scale.
|
||||||
Standard_EXPORT void SizeHint (Standard_Integer& theWidth, Standard_Integer& theHeight) const;
|
void SizeHint (Standard_Integer& theWidth, Standard_Integer& theHeight) const;
|
||||||
|
|
||||||
//! updates color scale parameters.
|
void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
|
||||||
Standard_EXPORT virtual void UpdateColorScale();
|
const Handle(Prs3d_Presentation)& thePresentation,
|
||||||
|
const Standard_Integer theMode);
|
||||||
//! Draws color scale.
|
|
||||||
//! @param theBgColor [in] background color
|
|
||||||
//! @param theX [in] the X coordinate of color scale position.
|
|
||||||
//! @param theY [in] the Y coordinate of color scale position.
|
|
||||||
//! @param theWidth [in] the width of color scale.
|
|
||||||
//! @param theHeight [in] the height of color scale.
|
|
||||||
Standard_EXPORT void DrawScale (const Quantity_Color& theBgColor, const Standard_Integer theX, const Standard_Integer theY, const Standard_Integer theWidth, const Standard_Integer theHeight);
|
|
||||||
|
|
||||||
Standard_EXPORT virtual Standard_Boolean BeginPaint();
|
|
||||||
|
|
||||||
Standard_EXPORT virtual Standard_Boolean EndPaint();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
|
void ComputeSelection (const Handle(SelectMgr_Selection)& /*aSelection*/,
|
||||||
|
const Standard_Integer /*aMode*/){};
|
||||||
|
|
||||||
//! Returns the format of text.
|
//! Returns the format of text.
|
||||||
Standard_EXPORT TCollection_AsciiString Format() const;
|
TCollection_AsciiString Format() const;
|
||||||
|
|
||||||
//! Returns the value of given interval.
|
//! Returns the value of given interval.
|
||||||
Standard_EXPORT Standard_Real GetNumber (const Standard_Integer theIndex) const;
|
Standard_Real GetNumber (const Standard_Integer anIndex) const;
|
||||||
|
|
||||||
//! Returns the color's hue for the given value in the given interval.
|
//! Returns the color's hue for the given value in the given interval.
|
||||||
//! @param theValue [in] the current value of interval.
|
//! @param theValue [in] the current value of interval.
|
||||||
//! @param theMin [in] the min value of interval.
|
//! @param theMin [in] the min value of interval.
|
||||||
//! @param theMax [in] the max value of interval.
|
//! @param theMax [in] the max value of interval.
|
||||||
Standard_EXPORT static Standard_Integer HueFromValue (const Standard_Integer theValue, const Standard_Integer theMin, const Standard_Integer theMax);
|
static Standard_Integer HueFromValue (const Standard_Integer aValue, const Standard_Integer aMin, const Standard_Integer aMax);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
Standard_Real myMin;
|
Standard_Real myMin;
|
||||||
Standard_Real myMax;
|
Standard_Real myMax;
|
||||||
@ -289,14 +270,5 @@ private:
|
|||||||
Standard_Real myWidth;
|
Standard_Real myWidth;
|
||||||
Standard_Real myHeight;
|
Standard_Real myHeight;
|
||||||
Standard_Integer myTextHeight;
|
Standard_Integer myTextHeight;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // _Aspect_ColorScale_HeaderFile
|
|
2
src/AIS/FILES
Executable file → Normal file
2
src/AIS/FILES
Executable file → Normal file
@ -24,6 +24,8 @@ AIS_Circle.lxx
|
|||||||
AIS_ClearMode.hxx
|
AIS_ClearMode.hxx
|
||||||
AIS_ColoredShape.cxx
|
AIS_ColoredShape.cxx
|
||||||
AIS_ColoredShape.hxx
|
AIS_ColoredShape.hxx
|
||||||
|
AIS_ColorScale.cxx
|
||||||
|
AIS_ColorScale.hxx
|
||||||
AIS_ConcentricRelation.cxx
|
AIS_ConcentricRelation.cxx
|
||||||
AIS_ConcentricRelation.hxx
|
AIS_ConcentricRelation.hxx
|
||||||
AIS_ConnectedInteractive.cxx
|
AIS_ConnectedInteractive.cxx
|
||||||
|
@ -1,637 +0,0 @@
|
|||||||
// Created on: 2004-06-22
|
|
||||||
// Created by: STV
|
|
||||||
// Copyright (c) 2004-2014 OPEN CASCADE SAS
|
|
||||||
//
|
|
||||||
// This file is part of Open CASCADE Technology software library.
|
|
||||||
//
|
|
||||||
// This library is free software; you can redistribute it and/or modify it under
|
|
||||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
|
||||||
// by the Free Software Foundation, with special exception defined in the file
|
|
||||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
|
||||||
// distribution for complete text of the license and disclaimer of any warranty.
|
|
||||||
//
|
|
||||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
|
||||||
// commercial license or contractual agreement.
|
|
||||||
|
|
||||||
|
|
||||||
#include <Aspect_ColorScale.hxx>
|
|
||||||
#include <Aspect_SequenceOfColor.hxx>
|
|
||||||
#include <Aspect_TypeOfColorScaleData.hxx>
|
|
||||||
#include <Aspect_TypeOfColorScalePosition.hxx>
|
|
||||||
#include <Precision.hxx>
|
|
||||||
#include <Quantity_Color.hxx>
|
|
||||||
#include <Standard_Type.hxx>
|
|
||||||
#include <TCollection_AsciiString.hxx>
|
|
||||||
#include <TCollection_ExtendedString.hxx>
|
|
||||||
#include <TColStd_SequenceOfExtendedString.hxx>
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
Aspect_ColorScale::Aspect_ColorScale()
|
|
||||||
: MMgt_TShared(),
|
|
||||||
myMin( 0.0 ),
|
|
||||||
myMax( 1.0 ),
|
|
||||||
myTitle( "" ),
|
|
||||||
myFormat( "%.4g" ),
|
|
||||||
myInterval( 10 ),
|
|
||||||
myColorType( Aspect_TOCSD_AUTO ),
|
|
||||||
myLabelType( Aspect_TOCSD_AUTO ),
|
|
||||||
myAtBorder( Standard_True ),
|
|
||||||
myReversed( Standard_False ),
|
|
||||||
myLabelPos( Aspect_TOCSP_RIGHT ),
|
|
||||||
myTitlePos( Aspect_TOCSP_CENTER ),
|
|
||||||
myXPos( 0 ),
|
|
||||||
myYPos( 0 ),
|
|
||||||
myWidth( 0.2 ),
|
|
||||||
myHeight( 1 ),
|
|
||||||
myTextHeight(20)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Real Aspect_ColorScale::GetMin() const
|
|
||||||
{
|
|
||||||
return myMin;
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Real Aspect_ColorScale::GetMax() const
|
|
||||||
{
|
|
||||||
return myMax;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Aspect_ColorScale::GetRange (Standard_Real& theMin, Standard_Real& theMax) const
|
|
||||||
{
|
|
||||||
theMin = myMin;
|
|
||||||
theMax = myMax;
|
|
||||||
}
|
|
||||||
|
|
||||||
Aspect_TypeOfColorScaleData Aspect_ColorScale::GetLabelType() const
|
|
||||||
{
|
|
||||||
return myLabelType;
|
|
||||||
}
|
|
||||||
|
|
||||||
Aspect_TypeOfColorScaleData Aspect_ColorScale::GetColorType() const
|
|
||||||
{
|
|
||||||
return myColorType;
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Integer Aspect_ColorScale::GetNumberOfIntervals() const
|
|
||||||
{
|
|
||||||
return myInterval;
|
|
||||||
}
|
|
||||||
|
|
||||||
TCollection_ExtendedString Aspect_ColorScale::GetTitle() const
|
|
||||||
{
|
|
||||||
return myTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
TCollection_AsciiString Aspect_ColorScale::GetFormat() const
|
|
||||||
{
|
|
||||||
return myFormat;
|
|
||||||
}
|
|
||||||
|
|
||||||
TCollection_ExtendedString Aspect_ColorScale::GetLabel (const Standard_Integer theIndex) const
|
|
||||||
{
|
|
||||||
if (GetLabelType() == Aspect_TOCSD_USER)
|
|
||||||
{
|
|
||||||
if (theIndex < 0
|
|
||||||
|| theIndex >= myLabels.Length())
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
return myLabels.Value (theIndex + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
const Standard_Real aVal = GetNumber (theIndex);
|
|
||||||
const TCollection_AsciiString aFormat = Format();
|
|
||||||
Standard_Character aBuf[1024];
|
|
||||||
sprintf (aBuf, aFormat.ToCString(), aVal);
|
|
||||||
return TCollection_ExtendedString (aBuf);
|
|
||||||
}
|
|
||||||
|
|
||||||
Quantity_Color Aspect_ColorScale::GetColor (const Standard_Integer theIndex) const
|
|
||||||
{
|
|
||||||
if (GetColorType() == Aspect_TOCSD_USER)
|
|
||||||
{
|
|
||||||
if (theIndex < 0
|
|
||||||
|| theIndex >= myColors.Length())
|
|
||||||
{
|
|
||||||
return Quantity_Color();
|
|
||||||
}
|
|
||||||
|
|
||||||
return myColors.Value (theIndex + 1);
|
|
||||||
}
|
|
||||||
return Quantity_Color (HueFromValue (theIndex, 0, GetNumberOfIntervals() - 1), 1.0, 1.0, Quantity_TOC_HLS);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Aspect_ColorScale::GetLabels (TColStd_SequenceOfExtendedString& theLabels) const
|
|
||||||
{
|
|
||||||
theLabels.Clear();
|
|
||||||
for (Standard_Integer i = 1; i <= myLabels.Length(); i++)
|
|
||||||
theLabels.Append (myLabels.Value (i));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Aspect_ColorScale::GetColors (Aspect_SequenceOfColor& theColors) const
|
|
||||||
{
|
|
||||||
theColors.Clear();
|
|
||||||
for (Standard_Integer i = 1; i <= myColors.Length(); i++)
|
|
||||||
theColors.Append (myColors.Value (i));
|
|
||||||
}
|
|
||||||
|
|
||||||
Aspect_TypeOfColorScalePosition Aspect_ColorScale::GetLabelPosition() const
|
|
||||||
{
|
|
||||||
return myLabelPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
Aspect_TypeOfColorScalePosition Aspect_ColorScale::GetTitlePosition() const
|
|
||||||
{
|
|
||||||
return myTitlePos;
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Boolean Aspect_ColorScale::IsReversed() const
|
|
||||||
{
|
|
||||||
return myReversed;
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Boolean Aspect_ColorScale::IsLabelAtBorder() const
|
|
||||||
{
|
|
||||||
return myAtBorder;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Aspect_ColorScale::SetMin (const Standard_Real theMin)
|
|
||||||
{
|
|
||||||
SetRange (theMin, GetMax());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Aspect_ColorScale::SetMax (const Standard_Real theMax)
|
|
||||||
{
|
|
||||||
SetRange (GetMin(), theMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Aspect_ColorScale::SetRange (const Standard_Real theMin, const Standard_Real theMax)
|
|
||||||
{
|
|
||||||
if (myMin == theMin && myMax == theMax)
|
|
||||||
return;
|
|
||||||
|
|
||||||
myMin = Min( theMin, theMax );
|
|
||||||
myMax = Max( theMin, theMax );
|
|
||||||
|
|
||||||
if (GetColorType() == Aspect_TOCSD_AUTO)
|
|
||||||
UpdateColorScale();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Aspect_ColorScale::SetLabelType (const Aspect_TypeOfColorScaleData theType)
|
|
||||||
{
|
|
||||||
if (myLabelType == theType)
|
|
||||||
return;
|
|
||||||
|
|
||||||
myLabelType = theType;
|
|
||||||
UpdateColorScale();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Aspect_ColorScale::SetColorType (const Aspect_TypeOfColorScaleData theType)
|
|
||||||
{
|
|
||||||
if (myColorType == theType)
|
|
||||||
return;
|
|
||||||
|
|
||||||
myColorType = theType;
|
|
||||||
UpdateColorScale();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Aspect_ColorScale::SetNumberOfIntervals (const Standard_Integer theNum)
|
|
||||||
{
|
|
||||||
if (myInterval == theNum || theNum < 1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
myInterval = theNum;
|
|
||||||
UpdateColorScale();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Aspect_ColorScale::SetTitle (const TCollection_ExtendedString& theTitle)
|
|
||||||
{
|
|
||||||
if (myTitle == theTitle)
|
|
||||||
return;
|
|
||||||
|
|
||||||
myTitle = theTitle;
|
|
||||||
UpdateColorScale();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Aspect_ColorScale::SetFormat (const TCollection_AsciiString& theFormat)
|
|
||||||
{
|
|
||||||
if (myFormat == theFormat)
|
|
||||||
return;
|
|
||||||
|
|
||||||
myFormat = theFormat;
|
|
||||||
if (GetLabelType() == Aspect_TOCSD_AUTO)
|
|
||||||
UpdateColorScale();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Aspect_ColorScale::SetLabel (const TCollection_ExtendedString& theLabel, const Standard_Integer theIndex)
|
|
||||||
{
|
|
||||||
Standard_Boolean changed = Standard_False;
|
|
||||||
Standard_Integer i = theIndex < 0 ? myLabels.Length() + 1 : theIndex + 1;
|
|
||||||
if (i <= myLabels.Length()) {
|
|
||||||
changed = myLabels.Value (i) != theLabel;
|
|
||||||
myLabels.SetValue (i, theLabel);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
changed = Standard_True;
|
|
||||||
while (i > myLabels.Length())
|
|
||||||
myLabels.Append (TCollection_ExtendedString());
|
|
||||||
myLabels.SetValue (i, theLabel);
|
|
||||||
}
|
|
||||||
if (changed)
|
|
||||||
UpdateColorScale();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Aspect_ColorScale::SetColor (const Quantity_Color& theColor, const Standard_Integer theIndex)
|
|
||||||
{
|
|
||||||
Standard_Boolean changed = Standard_False;
|
|
||||||
Standard_Integer i = theIndex < 0 ? myColors.Length() + 1 : theIndex + 1;
|
|
||||||
if (i <= myColors.Length()) {
|
|
||||||
changed = myColors.Value (i) != theColor;
|
|
||||||
myColors.SetValue (i, theColor);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
changed = Standard_True;
|
|
||||||
while ( i > myColors.Length() )
|
|
||||||
myColors.Append (Quantity_Color());
|
|
||||||
myColors.SetValue (i, theColor);
|
|
||||||
}
|
|
||||||
if (changed)
|
|
||||||
UpdateColorScale();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Aspect_ColorScale::SetLabels (const TColStd_SequenceOfExtendedString& theSeq)
|
|
||||||
{
|
|
||||||
myLabels.Clear();
|
|
||||||
for (Standard_Integer i = 1; i <= theSeq.Length(); i++)
|
|
||||||
myLabels.Append (theSeq.Value (i));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Aspect_ColorScale::SetColors (const Aspect_SequenceOfColor& theSeq)
|
|
||||||
{
|
|
||||||
myColors.Clear();
|
|
||||||
for (Standard_Integer i = 1; i <= theSeq.Length(); i++)
|
|
||||||
myColors.Append (theSeq.Value (i));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Aspect_ColorScale::SetLabelPosition (const Aspect_TypeOfColorScalePosition thePos)
|
|
||||||
{
|
|
||||||
if (myLabelPos == thePos)
|
|
||||||
return;
|
|
||||||
|
|
||||||
myLabelPos = thePos;
|
|
||||||
UpdateColorScale();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Aspect_ColorScale::SetTitlePosition (const Aspect_TypeOfColorScalePosition thePos)
|
|
||||||
{
|
|
||||||
if (myTitlePos == thePos)
|
|
||||||
return;
|
|
||||||
|
|
||||||
myTitlePos = thePos;
|
|
||||||
UpdateColorScale();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Aspect_ColorScale::SetReversed (const Standard_Boolean theReverse)
|
|
||||||
{
|
|
||||||
if (myReversed == theReverse)
|
|
||||||
return;
|
|
||||||
|
|
||||||
myReversed = theReverse;
|
|
||||||
UpdateColorScale();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Aspect_ColorScale::SetLabelAtBorder (const Standard_Boolean theOn)
|
|
||||||
{
|
|
||||||
if (myAtBorder == theOn)
|
|
||||||
return;
|
|
||||||
|
|
||||||
myAtBorder = theOn;
|
|
||||||
UpdateColorScale();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Aspect_ColorScale::GetPosition (Standard_Real& theX, Standard_Real& theY) const
|
|
||||||
{
|
|
||||||
theX = myXPos;
|
|
||||||
theY = myYPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Real Aspect_ColorScale::GetXPosition() const
|
|
||||||
{
|
|
||||||
return myXPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Real Aspect_ColorScale::GetYPosition() const
|
|
||||||
{
|
|
||||||
return myYPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Aspect_ColorScale::SetPosition (const Standard_Real theX, const Standard_Real theY)
|
|
||||||
{
|
|
||||||
if (myXPos == theX && myYPos == theY)
|
|
||||||
return;
|
|
||||||
|
|
||||||
myXPos = theX;
|
|
||||||
myYPos = theY;
|
|
||||||
|
|
||||||
UpdateColorScale();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Aspect_ColorScale::SetXPosition (const Standard_Real theX)
|
|
||||||
{
|
|
||||||
SetPosition (theX, GetYPosition());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Aspect_ColorScale::SetYPosition (const Standard_Real theY)
|
|
||||||
{
|
|
||||||
SetPosition (GetXPosition(), theY);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Aspect_ColorScale::GetSize (Standard_Real& theWidth, Standard_Real& theHeight) const
|
|
||||||
{
|
|
||||||
theWidth = myWidth;
|
|
||||||
theHeight = myHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Real Aspect_ColorScale::GetWidth() const
|
|
||||||
{
|
|
||||||
return myWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Real Aspect_ColorScale::GetHeight() const
|
|
||||||
{
|
|
||||||
return myHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Aspect_ColorScale::SetSize (const Standard_Real theWidth, const Standard_Real theHeight)
|
|
||||||
{
|
|
||||||
if (myWidth == theWidth && myHeight == theHeight)
|
|
||||||
return;
|
|
||||||
|
|
||||||
myWidth = theWidth;
|
|
||||||
myHeight = theHeight;
|
|
||||||
|
|
||||||
UpdateColorScale();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Aspect_ColorScale::SetWidth (const Standard_Real theWidth)
|
|
||||||
{
|
|
||||||
SetSize (theWidth, GetHeight());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Aspect_ColorScale::SetHeight (const Standard_Real theHeight)
|
|
||||||
{
|
|
||||||
SetSize (GetWidth(), theHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Aspect_ColorScale::SizeHint (Standard_Integer& theWidth, Standard_Integer& theHeight) const
|
|
||||||
{
|
|
||||||
Standard_Integer num = GetNumberOfIntervals();
|
|
||||||
|
|
||||||
Standard_Integer spacer = 5;
|
|
||||||
Standard_Integer textWidth = 0;
|
|
||||||
Standard_Integer textHeight = TextHeight ("");
|
|
||||||
Standard_Integer colorWidth = 20;
|
|
||||||
|
|
||||||
if (GetLabelPosition() != Aspect_TOCSP_NONE)
|
|
||||||
for (Standard_Integer idx = 0; idx < num; idx++)
|
|
||||||
textWidth = Max (textWidth, TextWidth (GetLabel (idx + 1)));
|
|
||||||
|
|
||||||
Standard_Integer scaleWidth = 0;
|
|
||||||
Standard_Integer scaleHeight = 0;
|
|
||||||
|
|
||||||
Standard_Integer titleWidth = 0;
|
|
||||||
Standard_Integer titleHeight = 0;
|
|
||||||
|
|
||||||
if (IsLabelAtBorder()) {
|
|
||||||
num++;
|
|
||||||
if (GetTitle().Length())
|
|
||||||
titleHeight += 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
scaleWidth = colorWidth + textWidth + ( textWidth ? 3 : 2 ) * spacer;
|
|
||||||
scaleHeight = (Standard_Integer)( 1.5 * ( num + 1 ) * textHeight );
|
|
||||||
|
|
||||||
if (GetTitle().Length()) {
|
|
||||||
titleHeight = TextHeight (GetTitle()) + spacer;
|
|
||||||
titleWidth = TextWidth (GetTitle()) + 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
theWidth = Max (titleWidth, scaleWidth);
|
|
||||||
theHeight = scaleHeight + titleHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Aspect_ColorScale::DrawScale ( const Quantity_Color& theBgColor,
|
|
||||||
const Standard_Integer theX, const Standard_Integer theY,
|
|
||||||
const Standard_Integer theWidth, const Standard_Integer theHeight)
|
|
||||||
{
|
|
||||||
if (!BeginPaint())
|
|
||||||
return;
|
|
||||||
|
|
||||||
Standard_Integer num = GetNumberOfIntervals();
|
|
||||||
Aspect_TypeOfColorScalePosition labPos = GetLabelPosition();
|
|
||||||
|
|
||||||
Standard_Integer spacer = 5;
|
|
||||||
Standard_Integer textWidth = 0;
|
|
||||||
Standard_Integer textHeight = TextHeight ("");
|
|
||||||
|
|
||||||
Standard_Boolean drawLabel = GetLabelPosition() != Aspect_TOCSP_NONE;
|
|
||||||
|
|
||||||
TCollection_ExtendedString aTitle = GetTitle();
|
|
||||||
|
|
||||||
Standard_Integer titleHeight = 0;
|
|
||||||
|
|
||||||
Standard_Integer aGray = (Standard_Integer)(255 * ( theBgColor.Red() * 11 + theBgColor.Green() * 16 + theBgColor.Blue() * 5 ) / 32);
|
|
||||||
Quantity_Color aFgColor (aGray < 128 ? Quantity_NOC_WHITE : Quantity_NOC_BLACK);
|
|
||||||
|
|
||||||
// Draw title
|
|
||||||
if (aTitle.Length()) {
|
|
||||||
titleHeight = TextHeight (aTitle) + 2 * spacer;
|
|
||||||
PaintText (aTitle, theX + spacer, theY + spacer, aFgColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Boolean reverse = IsReversed();
|
|
||||||
|
|
||||||
Aspect_SequenceOfColor colors;
|
|
||||||
TColStd_SequenceOfExtendedString labels;
|
|
||||||
for (int idx = 0; idx < num; idx++) {
|
|
||||||
if (reverse) {
|
|
||||||
colors.Append (GetColor (idx));
|
|
||||||
labels.Append (GetLabel (idx));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
colors.Prepend (GetColor (idx));
|
|
||||||
labels.Prepend (GetLabel (idx));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsLabelAtBorder()) {
|
|
||||||
if (reverse)
|
|
||||||
labels.Append (GetLabel (num));
|
|
||||||
else
|
|
||||||
labels.Prepend (GetLabel (num));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (drawLabel)
|
|
||||||
for (Standard_Integer i = 1; i <= labels.Length(); i++)
|
|
||||||
textWidth = Max (textWidth, TextWidth (labels.Value (i)));
|
|
||||||
|
|
||||||
Standard_Integer lab = labels.Length();
|
|
||||||
|
|
||||||
Standard_Real spc = ( theHeight - ( ( Min (lab, 2) + Abs (lab - num - 1) ) * textHeight ) - titleHeight );
|
|
||||||
Standard_Real val = spc != 0 ? 1.0 * ( lab - Min (lab, 1) ) * textHeight / spc : 0;
|
|
||||||
Standard_Real iPart;
|
|
||||||
Standard_Real fPart = modf (val, &iPart);
|
|
||||||
Standard_Integer filter = (Standard_Integer)iPart + ( fPart != 0 ? 1 : 0 );
|
|
||||||
|
|
||||||
Standard_Real step = 1.0 * ( theHeight - ( lab - num + Abs (lab - num - 1) ) * textHeight - titleHeight ) / num;
|
|
||||||
|
|
||||||
Standard_Integer ascent = 0;
|
|
||||||
Standard_Integer colorWidth = Max (5, Min (20, theWidth - textWidth - 3 * spacer));
|
|
||||||
if (labPos == Aspect_TOCSP_CENTER || !drawLabel)
|
|
||||||
colorWidth = theWidth - 2 * spacer;
|
|
||||||
|
|
||||||
// Draw colors
|
|
||||||
Standard_Integer x = theX + spacer;
|
|
||||||
if (labPos == Aspect_TOCSP_LEFT)
|
|
||||||
x += textWidth + ( textWidth ? 1 : 0 ) * spacer;
|
|
||||||
|
|
||||||
Standard_Real offset = 1.0 * textHeight / 2 * ( lab - num + Abs (lab - num - 1) ) + titleHeight;
|
|
||||||
for (Standard_Integer ci = 1; ci <= colors.Length() && step > 0; ci++ ) {
|
|
||||||
Standard_Integer y = (Standard_Integer)( theY + ( ci - 1 )* step + offset);
|
|
||||||
Standard_Integer h = (Standard_Integer)( theY + ( ci ) * step + offset ) - y;
|
|
||||||
PaintRect (x, y, colorWidth, h, colors.Value (ci), Standard_True);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (step > 0)
|
|
||||||
PaintRect (x - 1, (Standard_Integer)(theY + offset - 1), colorWidth + 2, (Standard_Integer)(colors.Length() * step + 2), aFgColor);
|
|
||||||
|
|
||||||
// Draw labels
|
|
||||||
offset = 1.0 * Abs (lab - num - 1) * ( step - textHeight ) / 2 + 1.0 * Abs (lab - num - 1) * textHeight / 2;
|
|
||||||
offset += titleHeight;
|
|
||||||
if (drawLabel && labels.Length() && filter > 0) {
|
|
||||||
Standard_Integer i1 = 0;
|
|
||||||
Standard_Integer i2 = lab - 1;
|
|
||||||
Standard_Integer last1 (i1), last2 (i2);
|
|
||||||
x = theX + spacer;
|
|
||||||
switch ( labPos ) {
|
|
||||||
case Aspect_TOCSP_NONE:
|
|
||||||
case Aspect_TOCSP_LEFT:
|
|
||||||
break;
|
|
||||||
case Aspect_TOCSP_CENTER:
|
|
||||||
x += ( colorWidth - textWidth ) / 2;
|
|
||||||
break;
|
|
||||||
case Aspect_TOCSP_RIGHT:
|
|
||||||
x += colorWidth + spacer;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
while (i2 - i1 >= filter || ( i2 == 0 && i1 == 0 )) {
|
|
||||||
Standard_Integer pos1 = i1;
|
|
||||||
Standard_Integer pos2 = lab - 1 - i2;
|
|
||||||
if (filter && !( pos1 % filter )) {
|
|
||||||
PaintText (labels.Value (i1 + 1), x, (Standard_Integer)( theY + i1 * step + ascent + offset ), aFgColor);
|
|
||||||
last1 = i1;
|
|
||||||
}
|
|
||||||
if (filter && !( pos2 % filter )) {
|
|
||||||
PaintText (labels.Value (i2 + 1), x, (Standard_Integer)( theY + i2 * step + ascent + offset ), aFgColor);
|
|
||||||
last2 = i2;
|
|
||||||
}
|
|
||||||
i1++;
|
|
||||||
i2--;
|
|
||||||
}
|
|
||||||
Standard_Integer pos = i1;
|
|
||||||
Standard_Integer i0 = -1;
|
|
||||||
while (pos <= i2 && i0 == -1) {
|
|
||||||
if (filter && !( pos % filter ) && Abs (pos - last1) >= filter && Abs (pos - last2) >= filter)
|
|
||||||
i0 = pos;
|
|
||||||
pos++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i0 != -1)
|
|
||||||
PaintText (labels.Value (i0 + 1), x, (Standard_Integer)( theY + i0 * step + ascent + offset ), aFgColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
EndPaint();
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Boolean Aspect_ColorScale::BeginPaint()
|
|
||||||
{
|
|
||||||
return Standard_True;
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Boolean Aspect_ColorScale::EndPaint()
|
|
||||||
{
|
|
||||||
return Standard_True;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Aspect_ColorScale::UpdateColorScale()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
TCollection_AsciiString Aspect_ColorScale::Format() const
|
|
||||||
{
|
|
||||||
return GetFormat();
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Real Aspect_ColorScale::GetNumber (const Standard_Integer theIndex) const
|
|
||||||
{
|
|
||||||
Standard_Real aNum = 0;
|
|
||||||
if (GetNumberOfIntervals() > 0)
|
|
||||||
aNum = GetMin() + theIndex * ( Abs (GetMax() - GetMin()) / GetNumberOfIntervals() );
|
|
||||||
return aNum;
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Integer Aspect_ColorScale::HueFromValue (const Standard_Integer theValue,
|
|
||||||
const Standard_Integer theMin, const Standard_Integer theMax)
|
|
||||||
{
|
|
||||||
Standard_Integer minLimit (0), maxLimit (230);
|
|
||||||
|
|
||||||
Standard_Integer aHue = maxLimit;
|
|
||||||
if (theMin != theMax)
|
|
||||||
aHue = (Standard_Integer)( maxLimit - ( maxLimit - minLimit ) * ( theValue - theMin ) / ( theMax - theMin ) );
|
|
||||||
|
|
||||||
aHue = Min (Max (minLimit, aHue), maxLimit);
|
|
||||||
|
|
||||||
return aHue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Integer Aspect_ColorScale::GetTextHeight() const {
|
|
||||||
return myTextHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Aspect_ColorScale::SetTextHeight (const Standard_Integer theHeight) {
|
|
||||||
myTextHeight = theHeight;
|
|
||||||
UpdateColorScale ();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Standard_Boolean Aspect_ColorScale::FindColor (const Standard_Real theValue,
|
|
||||||
Quantity_Color& theColor) const
|
|
||||||
{
|
|
||||||
return FindColor (theValue, myMin, myMax, myInterval, theColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Standard_Boolean Aspect_ColorScale::FindColor (const Standard_Real theValue,
|
|
||||||
const Standard_Real theMin,
|
|
||||||
const Standard_Real theMax,
|
|
||||||
const Standard_Integer theColorsCount,
|
|
||||||
Quantity_Color& theColor)
|
|
||||||
{
|
|
||||||
if(theValue<theMin || theValue>theMax || theMax<theMin)
|
|
||||||
return Standard_False;
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Standard_Real IntervNumber = 0;
|
|
||||||
if(Abs (theMax-theMin) > Precision::Approximation())
|
|
||||||
IntervNumber = Floor (Standard_Real( theColorsCount ) * ( theValue - theMin ) / ( theMax - theMin ));
|
|
||||||
|
|
||||||
Standard_Integer Interv = Standard_Integer (IntervNumber);
|
|
||||||
|
|
||||||
theColor = Quantity_Color (HueFromValue (Interv, 0, theColorsCount - 1), 1.0, 1.0, Quantity_TOC_HLS);
|
|
||||||
|
|
||||||
return Standard_True;
|
|
||||||
}
|
|
||||||
}
|
|
@ -13,8 +13,6 @@ Aspect_BadAccess.hxx
|
|||||||
Aspect_CircularGrid.cxx
|
Aspect_CircularGrid.cxx
|
||||||
Aspect_CircularGrid.hxx
|
Aspect_CircularGrid.hxx
|
||||||
Aspect_CLayer2d.hxx
|
Aspect_CLayer2d.hxx
|
||||||
Aspect_ColorScale.cxx
|
|
||||||
Aspect_ColorScale.hxx
|
|
||||||
Aspect_Convert.hxx
|
Aspect_Convert.hxx
|
||||||
Aspect_Display.hxx
|
Aspect_Display.hxx
|
||||||
Aspect_DisplayConnection.cxx
|
Aspect_DisplayConnection.cxx
|
||||||
|
@ -75,6 +75,7 @@
|
|||||||
#include <TColStd_Array1OfInteger.hxx>
|
#include <TColStd_Array1OfInteger.hxx>
|
||||||
#include <Geom_BSplineCurve.hxx>
|
#include <Geom_BSplineCurve.hxx>
|
||||||
#include <TColgp_Array1OfPnt.hxx>
|
#include <TColgp_Array1OfPnt.hxx>
|
||||||
|
#include <AIS_ColorScale.hxx>
|
||||||
#include <AIS_ListOfInteractive.hxx>
|
#include <AIS_ListOfInteractive.hxx>
|
||||||
#include <AIS_ListIteratorOfListOfInteractive.hxx>
|
#include <AIS_ListIteratorOfListOfInteractive.hxx>
|
||||||
#include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
|
#include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
|
||||||
@ -4536,17 +4537,30 @@ static Standard_Integer OCC12584 (Draw_Interpretor& di, Standard_Integer argc, c
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
Handle(V3d_View) V = ViewerTest::CurrentView();
|
Handle(V3d_View) V = ViewerTest::CurrentView();
|
||||||
|
static Handle(AIS_ColorScale) aCS;
|
||||||
|
if (aCS.IsNull())
|
||||||
|
{
|
||||||
|
aCS = new AIS_ColorScale();
|
||||||
|
}
|
||||||
|
if (aCS->ZLayer() != Graphic3d_ZLayerId_TopOSD)
|
||||||
|
{
|
||||||
|
aCS->SetZLayer (Graphic3d_ZLayerId_TopOSD);
|
||||||
|
}
|
||||||
|
if (aCS->GetTransformPersistenceMode() != Graphic3d_TMF_2d)
|
||||||
|
{
|
||||||
|
aCS->SetTransformPersistence (Graphic3d_TMF_2d, gp_Pnt (-1,-1,0));
|
||||||
|
}
|
||||||
if ( !V.IsNull() ) {
|
if ( !V.IsNull() ) {
|
||||||
if (mode == 0) {
|
if (mode == 0) {
|
||||||
V->ColorScaleDisplay();
|
aContext->Display (aCS);
|
||||||
}
|
}
|
||||||
if (mode == 1) {
|
if (mode == 1) {
|
||||||
V->ColorScaleErase();
|
aContext->Erase (aCS);
|
||||||
V->UpdateLights();
|
V->UpdateLights();
|
||||||
V->Update();
|
V->Update();
|
||||||
}
|
}
|
||||||
if (mode == 2) {
|
if (mode == 2) {
|
||||||
Standard_Boolean IsDisplayed = V->ColorScaleIsDisplayed();
|
Standard_Boolean IsDisplayed = aContext->IsDisplayed (aCS);
|
||||||
if (IsDisplayed)
|
if (IsDisplayed)
|
||||||
di <<"ColorScaleIsDisplayed = " << "1" << "\n";
|
di <<"ColorScaleIsDisplayed = " << "1" << "\n";
|
||||||
else
|
else
|
||||||
|
@ -5,10 +5,6 @@ V3d_AmbientLight.hxx
|
|||||||
V3d_BadValue.hxx
|
V3d_BadValue.hxx
|
||||||
V3d_CircularGrid.cxx
|
V3d_CircularGrid.cxx
|
||||||
V3d_CircularGrid.hxx
|
V3d_CircularGrid.hxx
|
||||||
V3d_ColorScale.cxx
|
|
||||||
V3d_ColorScale.hxx
|
|
||||||
V3d_ColorScaleLayerItem.cxx
|
|
||||||
V3d_ColorScaleLayerItem.hxx
|
|
||||||
V3d_Coordinate.hxx
|
V3d_Coordinate.hxx
|
||||||
V3d_DirectionalLight.cxx
|
V3d_DirectionalLight.cxx
|
||||||
V3d_DirectionalLight.hxx
|
V3d_DirectionalLight.hxx
|
||||||
|
@ -1,153 +0,0 @@
|
|||||||
// Created on: 2004-06-22
|
|
||||||
// Created by: STV
|
|
||||||
// Copyright (c) 2004-2014 OPEN CASCADE SAS
|
|
||||||
//
|
|
||||||
// This file is part of Open CASCADE Technology software library.
|
|
||||||
//
|
|
||||||
// This library is free software; you can redistribute it and/or modify it under
|
|
||||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
|
||||||
// by the Free Software Foundation, with special exception defined in the file
|
|
||||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
|
||||||
// distribution for complete text of the license and disclaimer of any warranty.
|
|
||||||
//
|
|
||||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
|
||||||
// commercial license or contractual agreement.
|
|
||||||
|
|
||||||
|
|
||||||
#include <Aspect_SequenceOfColor.hxx>
|
|
||||||
#include <Aspect_TypeOfColorScaleData.hxx>
|
|
||||||
#include <Aspect_TypeOfColorScalePosition.hxx>
|
|
||||||
#include <Aspect_Window.hxx>
|
|
||||||
#include <Font_NameOfFont.hxx>
|
|
||||||
#include <Quantity_Color.hxx>
|
|
||||||
#include <Standard_Type.hxx>
|
|
||||||
#include <TCollection_AsciiString.hxx>
|
|
||||||
#include <TCollection_ExtendedString.hxx>
|
|
||||||
#include <TColStd_SequenceOfExtendedString.hxx>
|
|
||||||
#include <V3d_ColorScale.hxx>
|
|
||||||
#include <V3d_LayerMgr.hxx>
|
|
||||||
#include <V3d_View.hxx>
|
|
||||||
#include <Visual3d_Layer.hxx>
|
|
||||||
#include <Visual3d_View.hxx>
|
|
||||||
#include <Visual3d_ViewManager.hxx>
|
|
||||||
|
|
||||||
V3d_ColorScale::V3d_ColorScale (const Handle(V3d_LayerMgr)& theMgr)
|
|
||||||
: Aspect_ColorScale(),
|
|
||||||
myLayerMgr( theMgr.operator->() ),
|
|
||||||
myDisplay( Standard_False )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void V3d_ColorScale::Display()
|
|
||||||
{
|
|
||||||
myDisplay = Standard_True;
|
|
||||||
UpdateColorScale();
|
|
||||||
}
|
|
||||||
|
|
||||||
void V3d_ColorScale::Erase()
|
|
||||||
{
|
|
||||||
myDisplay = Standard_False;
|
|
||||||
UpdateColorScale();
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Boolean V3d_ColorScale::IsDisplayed() const
|
|
||||||
{
|
|
||||||
return myDisplay;
|
|
||||||
}
|
|
||||||
|
|
||||||
void V3d_ColorScale::UpdateColorScale()
|
|
||||||
{
|
|
||||||
myLayerMgr->Compute();
|
|
||||||
}
|
|
||||||
|
|
||||||
void V3d_ColorScale::PaintRect (const Standard_Integer theX, const Standard_Integer theY,
|
|
||||||
const Standard_Integer theWidth, const Standard_Integer theHeight,
|
|
||||||
const Quantity_Color& theColor, const Standard_Boolean theFilled)
|
|
||||||
{
|
|
||||||
const Handle(Visual3d_Layer) &theLayer = myLayerMgr->Overlay();
|
|
||||||
if (theLayer.IsNull())
|
|
||||||
return;
|
|
||||||
|
|
||||||
theLayer->SetColor (theColor);
|
|
||||||
if (theFilled)
|
|
||||||
theLayer->DrawRectangle (theX, theY, theWidth, theHeight);
|
|
||||||
else {
|
|
||||||
theLayer->SetLineAttributes( Aspect_TOL_SOLID, 0.5 );
|
|
||||||
theLayer->BeginPolyline();
|
|
||||||
theLayer->AddVertex (theX, theY, Standard_False);
|
|
||||||
theLayer->AddVertex (theX, theY + theHeight, Standard_True);
|
|
||||||
theLayer->AddVertex (theX + theWidth, theY + theHeight, Standard_True);
|
|
||||||
theLayer->AddVertex (theX + theWidth, theY, Standard_True);
|
|
||||||
theLayer->AddVertex (theX, theY, Standard_True);
|
|
||||||
theLayer->ClosePrimitive();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void V3d_ColorScale::PaintText (const TCollection_ExtendedString& theText,
|
|
||||||
const Standard_Integer theX, const Standard_Integer theY,
|
|
||||||
const Quantity_Color& theColor)
|
|
||||||
{
|
|
||||||
const Handle(Visual3d_Layer) &theLayer = myLayerMgr->Overlay();
|
|
||||||
if (theLayer.IsNull())
|
|
||||||
return;
|
|
||||||
|
|
||||||
theLayer->SetColor (theColor);
|
|
||||||
theLayer->SetTextAttributes (Font_NOF_ASCII_MONO, Aspect_TODT_NORMAL, theColor);
|
|
||||||
TCollection_AsciiString aText (theText.ToExtString(), '?');
|
|
||||||
Standard_Integer aTextH = GetTextHeight();
|
|
||||||
Standard_Integer aWidth, anAscent, aDescent;
|
|
||||||
TextSize (theText, aTextH, aWidth, anAscent, aDescent);
|
|
||||||
theLayer->DrawText (aText.ToCString(), theX, theY + anAscent, aTextH);
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Integer V3d_ColorScale::TextWidth (const TCollection_ExtendedString& theText) const
|
|
||||||
{
|
|
||||||
Standard_Integer aWidth, anAscent, aDescent;
|
|
||||||
TextSize (theText, GetTextHeight(), aWidth, anAscent, aDescent);
|
|
||||||
return aWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Integer V3d_ColorScale::TextHeight (const TCollection_ExtendedString& theText) const
|
|
||||||
{
|
|
||||||
Standard_Integer aWidth, anAscent, aDescent;
|
|
||||||
TextSize (theText, GetTextHeight(), aWidth, anAscent, aDescent);
|
|
||||||
return anAscent+aDescent;
|
|
||||||
}
|
|
||||||
|
|
||||||
void V3d_ColorScale::TextSize (const TCollection_ExtendedString& theText, const Standard_Integer theHeight, Standard_Integer& theWidth, Standard_Integer& theAscent, Standard_Integer& theDescent) const
|
|
||||||
{
|
|
||||||
const Handle(Visual3d_Layer) &theLayer = myLayerMgr->Overlay();
|
|
||||||
if (!theLayer.IsNull()) {
|
|
||||||
Standard_Real aWidth, anAscent, aDescent;
|
|
||||||
TCollection_AsciiString aText (theText.ToExtString(), '?');
|
|
||||||
theLayer->TextSize (aText.ToCString(),theHeight,aWidth,anAscent,aDescent);
|
|
||||||
theWidth = (Standard_Integer)aWidth;
|
|
||||||
theAscent = (Standard_Integer)anAscent;
|
|
||||||
theDescent = (Standard_Integer)aDescent;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
theWidth=theAscent=theDescent=0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void V3d_ColorScale::DrawScale ()
|
|
||||||
{
|
|
||||||
const Handle(V3d_View) &theView = myLayerMgr->View();
|
|
||||||
if (theView.IsNull())
|
|
||||||
return;
|
|
||||||
|
|
||||||
const Handle(Aspect_Window) &theWin = theView->Window();
|
|
||||||
if (theWin.IsNull())
|
|
||||||
return;
|
|
||||||
|
|
||||||
Standard_Integer WinWidth( 0 ), WinHeight( 0 );
|
|
||||||
theWin->Size (WinWidth, WinHeight);
|
|
||||||
|
|
||||||
const Standard_Integer X = RealToInt (GetXPosition() * WinWidth);
|
|
||||||
const Standard_Integer Y = RealToInt (GetYPosition() * WinHeight);
|
|
||||||
|
|
||||||
const Standard_Integer W = RealToInt (GetWidth() * WinWidth);
|
|
||||||
const Standard_Integer H = RealToInt (GetHeight() * WinHeight);
|
|
||||||
|
|
||||||
Aspect_ColorScale::DrawScale (theView->BackgroundColor(), X, Y, W, H);
|
|
||||||
}
|
|
@ -1,90 +0,0 @@
|
|||||||
// Created on: 2004-06-24
|
|
||||||
// Created by: STV
|
|
||||||
// Copyright (c) 2004-2014 OPEN CASCADE SAS
|
|
||||||
//
|
|
||||||
// This file is part of Open CASCADE Technology software library.
|
|
||||||
//
|
|
||||||
// This library is free software; you can redistribute it and/or modify it under
|
|
||||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
|
||||||
// by the Free Software Foundation, with special exception defined in the file
|
|
||||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
|
||||||
// distribution for complete text of the license and disclaimer of any warranty.
|
|
||||||
//
|
|
||||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
|
||||||
// commercial license or contractual agreement.
|
|
||||||
|
|
||||||
#ifndef _V3d_ColorScale_HeaderFile
|
|
||||||
#define _V3d_ColorScale_HeaderFile
|
|
||||||
|
|
||||||
#include <Standard.hxx>
|
|
||||||
#include <Standard_Type.hxx>
|
|
||||||
|
|
||||||
#include <V3d_LayerMgrPointer.hxx>
|
|
||||||
#include <Standard_Boolean.hxx>
|
|
||||||
#include <Aspect_ColorScale.hxx>
|
|
||||||
#include <Standard_Integer.hxx>
|
|
||||||
class V3d_LayerMgr;
|
|
||||||
class Quantity_Color;
|
|
||||||
class TCollection_ExtendedString;
|
|
||||||
|
|
||||||
|
|
||||||
class V3d_ColorScale;
|
|
||||||
DEFINE_STANDARD_HANDLE(V3d_ColorScale, Aspect_ColorScale)
|
|
||||||
|
|
||||||
//! A colorscale class
|
|
||||||
class V3d_ColorScale : public Aspect_ColorScale
|
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
|
|
||||||
//! Returns returns ColorScale from V3d.
|
|
||||||
//! Returns View from V3d.
|
|
||||||
Standard_EXPORT V3d_ColorScale(const Handle(V3d_LayerMgr)& theMgr);
|
|
||||||
|
|
||||||
Standard_EXPORT void Display();
|
|
||||||
|
|
||||||
Standard_EXPORT void Erase();
|
|
||||||
|
|
||||||
Standard_EXPORT Standard_Boolean IsDisplayed() const;
|
|
||||||
|
|
||||||
Standard_EXPORT virtual void PaintRect (const Standard_Integer theX, const Standard_Integer theY, const Standard_Integer theWidth, const Standard_Integer theHeight, const Quantity_Color& theColor, const Standard_Boolean theFilled = Standard_False) Standard_OVERRIDE;
|
|
||||||
|
|
||||||
Standard_EXPORT virtual void PaintText (const TCollection_ExtendedString& theText, const Standard_Integer theX, const Standard_Integer theY, const Quantity_Color& theColor) Standard_OVERRIDE;
|
|
||||||
|
|
||||||
Standard_EXPORT virtual Standard_Integer TextWidth (const TCollection_ExtendedString& theText) const Standard_OVERRIDE;
|
|
||||||
|
|
||||||
Standard_EXPORT virtual Standard_Integer TextHeight (const TCollection_ExtendedString& theText) const Standard_OVERRIDE;
|
|
||||||
|
|
||||||
Standard_EXPORT void TextSize (const TCollection_ExtendedString& theText, const Standard_Integer theHeight, Standard_Integer& theWidth, Standard_Integer& theAscent, Standard_Integer& theDescent) const;
|
|
||||||
|
|
||||||
Standard_EXPORT void DrawScale();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DEFINE_STANDARD_RTTI(V3d_ColorScale,Aspect_ColorScale)
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
|
|
||||||
Standard_EXPORT virtual void UpdateColorScale() Standard_OVERRIDE;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
|
|
||||||
V3d_LayerMgrPointer myLayerMgr;
|
|
||||||
Standard_Boolean myDisplay;
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // _V3d_ColorScale_HeaderFile
|
|
@ -1,42 +0,0 @@
|
|||||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
|
||||||
//
|
|
||||||
// This file is part of Open CASCADE Technology software library.
|
|
||||||
//
|
|
||||||
// This library is free software; you can redistribute it and/or modify it under
|
|
||||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
|
||||||
// by the Free Software Foundation, with special exception defined in the file
|
|
||||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
|
||||||
// distribution for complete text of the license and disclaimer of any warranty.
|
|
||||||
//
|
|
||||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
|
||||||
// commercial license or contractual agreement.
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
************************************************************************/
|
|
||||||
// for the class
|
|
||||||
|
|
||||||
#include <Standard_Type.hxx>
|
|
||||||
#include <V3d_ColorScale.hxx>
|
|
||||||
#include <V3d_ColorScaleLayerItem.hxx>
|
|
||||||
|
|
||||||
//
|
|
||||||
//-Constructors
|
|
||||||
//
|
|
||||||
V3d_ColorScaleLayerItem::V3d_ColorScaleLayerItem (
|
|
||||||
const Handle(V3d_ColorScale)& aColorScale ):
|
|
||||||
Visual3d_LayerItem(),
|
|
||||||
MyColorScale(aColorScale)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void V3d_ColorScaleLayerItem::ComputeLayerPrs()
|
|
||||||
{
|
|
||||||
Visual3d_LayerItem::ComputeLayerPrs();
|
|
||||||
}
|
|
||||||
|
|
||||||
void V3d_ColorScaleLayerItem::RedrawLayerPrs()
|
|
||||||
{
|
|
||||||
Visual3d_LayerItem::RedrawLayerPrs();
|
|
||||||
if ( !MyColorScale.IsNull() )
|
|
||||||
MyColorScale->DrawScale();
|
|
||||||
}
|
|
@ -1,71 +0,0 @@
|
|||||||
// Created on: 2009-03-20
|
|
||||||
// Created by: ABD
|
|
||||||
// Copyright (c) 2009-2014 OPEN CASCADE SAS
|
|
||||||
//
|
|
||||||
// This file is part of Open CASCADE Technology software library.
|
|
||||||
//
|
|
||||||
// This library is free software; you can redistribute it and/or modify it under
|
|
||||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
|
||||||
// by the Free Software Foundation, with special exception defined in the file
|
|
||||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
|
||||||
// distribution for complete text of the license and disclaimer of any warranty.
|
|
||||||
//
|
|
||||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
|
||||||
// commercial license or contractual agreement.
|
|
||||||
|
|
||||||
#ifndef _V3d_ColorScaleLayerItem_HeaderFile
|
|
||||||
#define _V3d_ColorScaleLayerItem_HeaderFile
|
|
||||||
|
|
||||||
#include <Standard.hxx>
|
|
||||||
#include <Standard_Type.hxx>
|
|
||||||
|
|
||||||
#include <Visual3d_LayerItem.hxx>
|
|
||||||
class V3d_ColorScale;
|
|
||||||
|
|
||||||
|
|
||||||
class V3d_ColorScaleLayerItem;
|
|
||||||
DEFINE_STANDARD_HANDLE(V3d_ColorScaleLayerItem, Visual3d_LayerItem)
|
|
||||||
|
|
||||||
//! This class is drawable unit of ColorScale of 2d scene
|
|
||||||
class V3d_ColorScaleLayerItem : public Visual3d_LayerItem
|
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
|
|
||||||
//! Creates a layer item
|
|
||||||
Standard_EXPORT V3d_ColorScaleLayerItem(const Handle(V3d_ColorScale)& aColorScale);
|
|
||||||
|
|
||||||
//! virtual function for recompute 2D
|
|
||||||
//! presentation (empty by default)
|
|
||||||
Standard_EXPORT virtual void ComputeLayerPrs() Standard_OVERRIDE;
|
|
||||||
|
|
||||||
//! virtual function for recompute 2D
|
|
||||||
//! presentation (empty by default)
|
|
||||||
Standard_EXPORT virtual void RedrawLayerPrs() Standard_OVERRIDE;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DEFINE_STANDARD_RTTI(V3d_ColorScaleLayerItem,Visual3d_LayerItem)
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
|
|
||||||
Handle(V3d_ColorScale) MyColorScale;
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // _V3d_ColorScaleLayerItem_HeaderFile
|
|
@ -14,12 +14,9 @@
|
|||||||
// commercial license or contractual agreement.
|
// commercial license or contractual agreement.
|
||||||
|
|
||||||
|
|
||||||
#include <Aspect_ColorScale.hxx>
|
|
||||||
#include <Aspect_Window.hxx>
|
#include <Aspect_Window.hxx>
|
||||||
#include <Font_NameOfFont.hxx>
|
#include <Font_NameOfFont.hxx>
|
||||||
#include <Standard_Type.hxx>
|
#include <Standard_Type.hxx>
|
||||||
#include <V3d_ColorScale.hxx>
|
|
||||||
#include <V3d_ColorScaleLayerItem.hxx>
|
|
||||||
#include <V3d_LayerMgr.hxx>
|
#include <V3d_LayerMgr.hxx>
|
||||||
#include <V3d_View.hxx>
|
#include <V3d_View.hxx>
|
||||||
#include <Visual3d_Layer.hxx>
|
#include <Visual3d_Layer.hxx>
|
||||||
@ -52,38 +49,6 @@ void V3d_LayerMgr::Resized()
|
|||||||
Compute();
|
Compute();
|
||||||
}
|
}
|
||||||
|
|
||||||
void V3d_LayerMgr::ColorScaleDisplay()
|
|
||||||
{
|
|
||||||
if (ColorScaleIsDisplayed())
|
|
||||||
return;
|
|
||||||
ColorScale();
|
|
||||||
myColorScale->Display();
|
|
||||||
myOverlay->AddLayerItem( myColorScaleLayerItem );
|
|
||||||
}
|
|
||||||
|
|
||||||
void V3d_LayerMgr::ColorScaleErase()
|
|
||||||
{
|
|
||||||
if ( !myColorScale.IsNull() )
|
|
||||||
myColorScale->Erase();
|
|
||||||
myOverlay->RemoveLayerItem( myColorScaleLayerItem );
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Boolean V3d_LayerMgr::ColorScaleIsDisplayed() const
|
|
||||||
{
|
|
||||||
return ( myColorScale.IsNull() ? Standard_False : myColorScale->IsDisplayed() );
|
|
||||||
}
|
|
||||||
|
|
||||||
Handle(Aspect_ColorScale) V3d_LayerMgr::ColorScale() const
|
|
||||||
{
|
|
||||||
if ( myColorScale.IsNull() ) {
|
|
||||||
Handle(V3d_LayerMgr) that = this;
|
|
||||||
that->myColorScale = new V3d_ColorScale( this );
|
|
||||||
that->myColorScaleLayerItem = new V3d_ColorScaleLayerItem( that->myColorScale );
|
|
||||||
}
|
|
||||||
|
|
||||||
return Handle(Aspect_ColorScale) (myColorScale);
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Boolean V3d_LayerMgr::Begin()
|
Standard_Boolean V3d_LayerMgr::Begin()
|
||||||
{
|
{
|
||||||
if ( myOverlay.IsNull() )
|
if ( myOverlay.IsNull() )
|
||||||
|
@ -45,14 +45,6 @@ public:
|
|||||||
|
|
||||||
Handle(V3d_View) View() const;
|
Handle(V3d_View) View() const;
|
||||||
|
|
||||||
Standard_EXPORT void ColorScaleDisplay();
|
|
||||||
|
|
||||||
Standard_EXPORT void ColorScaleErase();
|
|
||||||
|
|
||||||
Standard_EXPORT Standard_Boolean ColorScaleIsDisplayed() const;
|
|
||||||
|
|
||||||
Standard_EXPORT Handle(Aspect_ColorScale) ColorScale() const;
|
|
||||||
|
|
||||||
//! Recompute layer with objects
|
//! Recompute layer with objects
|
||||||
Standard_EXPORT void Compute();
|
Standard_EXPORT void Compute();
|
||||||
|
|
||||||
@ -77,8 +69,6 @@ protected:
|
|||||||
|
|
||||||
V3d_ViewPointer myView;
|
V3d_ViewPointer myView;
|
||||||
Handle(Visual3d_Layer) myOverlay;
|
Handle(Visual3d_Layer) myOverlay;
|
||||||
Handle(V3d_ColorScale) myColorScale;
|
|
||||||
Handle(V3d_ColorScaleLayerItem) myColorScaleLayerItem;
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -66,7 +66,6 @@ To solve the problem (for lack of a better solution) I make 2 passes.
|
|||||||
* Includes
|
* Includes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Aspect_ColorScale.hxx>
|
|
||||||
#include <Aspect_GradientBackground.hxx>
|
#include <Aspect_GradientBackground.hxx>
|
||||||
#include <Aspect_Grid.hxx>
|
#include <Aspect_Grid.hxx>
|
||||||
#include <Aspect_Window.hxx>
|
#include <Aspect_Window.hxx>
|
||||||
|
@ -86,7 +86,6 @@ class V3d_Viewer;
|
|||||||
class Quantity_Color;
|
class Quantity_Color;
|
||||||
class Graphic3d_TextureEnv;
|
class Graphic3d_TextureEnv;
|
||||||
class V3d_Light;
|
class V3d_Light;
|
||||||
class Aspect_ColorScale;
|
|
||||||
class Bnd_Box;
|
class Bnd_Box;
|
||||||
class Aspect_GradientBackground;
|
class Aspect_GradientBackground;
|
||||||
class gp_Dir;
|
class gp_Dir;
|
||||||
@ -340,14 +339,6 @@ public:
|
|||||||
|
|
||||||
Standard_EXPORT void SetLayerMgr (const Handle(V3d_LayerMgr)& aMgr);
|
Standard_EXPORT void SetLayerMgr (const Handle(V3d_LayerMgr)& aMgr);
|
||||||
|
|
||||||
Standard_EXPORT void ColorScaleDisplay();
|
|
||||||
|
|
||||||
Standard_EXPORT void ColorScaleErase();
|
|
||||||
|
|
||||||
Standard_EXPORT Standard_Boolean ColorScaleIsDisplayed() const;
|
|
||||||
|
|
||||||
Standard_EXPORT Handle(Aspect_ColorScale) ColorScale() const;
|
|
||||||
|
|
||||||
//! modify the Projection of the view perpendicularly to
|
//! modify the Projection of the view perpendicularly to
|
||||||
//! the privileged plane of the viewer.
|
//! the privileged plane of the viewer.
|
||||||
Standard_EXPORT void SetFront();
|
Standard_EXPORT void SetFront();
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
* Includes
|
* Includes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Aspect_ColorScale.hxx>
|
|
||||||
#include <Aspect_GradientBackground.hxx>
|
#include <Aspect_GradientBackground.hxx>
|
||||||
#include <Aspect_Grid.hxx>
|
#include <Aspect_Grid.hxx>
|
||||||
#include <Aspect_Window.hxx>
|
#include <Aspect_Window.hxx>
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
* Includes
|
* Includes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Aspect_ColorScale.hxx>
|
|
||||||
#include <Aspect_GradientBackground.hxx>
|
#include <Aspect_GradientBackground.hxx>
|
||||||
#include <Aspect_Grid.hxx>
|
#include <Aspect_Grid.hxx>
|
||||||
#include <Aspect_Window.hxx>
|
#include <Aspect_Window.hxx>
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
// commercial license or contractual agreement.
|
// commercial license or contractual agreement.
|
||||||
|
|
||||||
|
|
||||||
#include <Aspect_ColorScale.hxx>
|
|
||||||
#include <Aspect_GradientBackground.hxx>
|
#include <Aspect_GradientBackground.hxx>
|
||||||
#include <Aspect_Grid.hxx>
|
#include <Aspect_Grid.hxx>
|
||||||
#include <Aspect_Window.hxx>
|
#include <Aspect_Window.hxx>
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
// commercial license or contractual agreement.
|
// commercial license or contractual agreement.
|
||||||
|
|
||||||
|
|
||||||
#include <Aspect_ColorScale.hxx>
|
|
||||||
#include <Aspect_GradientBackground.hxx>
|
#include <Aspect_GradientBackground.hxx>
|
||||||
#include <Aspect_Grid.hxx>
|
#include <Aspect_Grid.hxx>
|
||||||
#include <Aspect_RectangularGrid.hxx>
|
#include <Aspect_RectangularGrid.hxx>
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
* Includes
|
* Includes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Aspect_ColorScale.hxx>
|
|
||||||
#include <Aspect_GradientBackground.hxx>
|
#include <Aspect_GradientBackground.hxx>
|
||||||
#include <Aspect_Grid.hxx>
|
#include <Aspect_Grid.hxx>
|
||||||
#include <Aspect_Window.hxx>
|
#include <Aspect_Window.hxx>
|
||||||
@ -72,42 +71,3 @@ void V3d_View::SetLayerMgr(const Handle(V3d_LayerMgr)& aMgr)
|
|||||||
{
|
{
|
||||||
MyLayerMgr = aMgr;
|
MyLayerMgr = aMgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void V3d_View::ColorScaleDisplay()
|
|
||||||
{
|
|
||||||
if ( MyLayerMgr.IsNull() )
|
|
||||||
MyLayerMgr = new V3d_LayerMgr( this );
|
|
||||||
|
|
||||||
MyLayerMgr->ColorScaleDisplay();
|
|
||||||
MustBeResized();
|
|
||||||
if ( !Window().IsNull() ) {
|
|
||||||
Standard_Integer aW( 0 ), aH( 0 );
|
|
||||||
Window()->Size( aW, aH );
|
|
||||||
Redraw( 0, 0, aW, aH );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void V3d_View::ColorScaleErase()
|
|
||||||
{
|
|
||||||
if ( !MyLayerMgr.IsNull() )
|
|
||||||
MyLayerMgr->ColorScaleErase();
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Boolean V3d_View::ColorScaleIsDisplayed() const
|
|
||||||
{
|
|
||||||
Standard_Boolean aStatus = Standard_False;
|
|
||||||
if ( !MyLayerMgr.IsNull() )
|
|
||||||
aStatus = MyLayerMgr->ColorScaleIsDisplayed();
|
|
||||||
|
|
||||||
return aStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
Handle(Aspect_ColorScale) V3d_View::ColorScale() const
|
|
||||||
{
|
|
||||||
if ( MyLayerMgr.IsNull() ) {
|
|
||||||
Handle(V3d_View) that = this;
|
|
||||||
that->MyLayerMgr = new V3d_LayerMgr( this );
|
|
||||||
}
|
|
||||||
|
|
||||||
return MyLayerMgr->ColorScale();
|
|
||||||
}
|
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include <Aspect_ColorScale.hxx>
|
|
||||||
#include <Aspect_GradientBackground.hxx>
|
#include <Aspect_GradientBackground.hxx>
|
||||||
#include <Aspect_Grid.hxx>
|
#include <Aspect_Grid.hxx>
|
||||||
#include <Aspect_Window.hxx>
|
#include <Aspect_Window.hxx>
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
// commercial license or contractual agreement.
|
// commercial license or contractual agreement.
|
||||||
|
|
||||||
#include <OpenGl_GlCore20.hxx>
|
#include <OpenGl_GlCore20.hxx>
|
||||||
|
#include <AIS_ColorScale.hxx>
|
||||||
#include <AIS_Shape.hxx>
|
#include <AIS_Shape.hxx>
|
||||||
#include <AIS_InteractiveObject.hxx>
|
#include <AIS_InteractiveObject.hxx>
|
||||||
#include <AIS_ListOfInteractive.hxx>
|
#include <AIS_ListOfInteractive.hxx>
|
||||||
@ -37,7 +38,6 @@
|
|||||||
#include <Visual3d_View.hxx>
|
#include <Visual3d_View.hxx>
|
||||||
#include <Visual3d_ViewManager.hxx>
|
#include <Visual3d_ViewManager.hxx>
|
||||||
#include <V3d_AmbientLight.hxx>
|
#include <V3d_AmbientLight.hxx>
|
||||||
#include <V3d_ColorScale.hxx>
|
|
||||||
#include <V3d_DirectionalLight.hxx>
|
#include <V3d_DirectionalLight.hxx>
|
||||||
#include <V3d_LayerMgr.hxx>
|
#include <V3d_LayerMgr.hxx>
|
||||||
#include <V3d_LayerMgrPointer.hxx>
|
#include <V3d_LayerMgrPointer.hxx>
|
||||||
@ -3474,12 +3474,32 @@ static int VColorScale (Draw_Interpretor& theDI,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle(V3d_ColorScale) aCS = Handle(V3d_ColorScale)::DownCast (aView->ColorScale());
|
Handle(AIS_ColorScale) aCS;
|
||||||
|
// find object
|
||||||
|
Handle(AIS_InteractiveObject) anIObj;
|
||||||
|
if (GetMapOfAIS().IsBound2 (theArgVec[1]))
|
||||||
|
{
|
||||||
|
aCS = Handle(AIS_ColorScale)::DownCast (GetMapOfAIS().Find2 (theArgVec[1]));
|
||||||
if (aCS.IsNull())
|
if (aCS.IsNull())
|
||||||
{
|
{
|
||||||
std::cout << "Error: color scale is undefined!\n";
|
std::cout << "Error: object '" << theArgVec[1] << "'is already defined and is not a color scale!\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
aCS = new AIS_ColorScale();
|
||||||
|
GetMapOfAIS().Bind (aCS,theArgVec[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aCS->ZLayer() != Graphic3d_ZLayerId_TopOSD)
|
||||||
|
{
|
||||||
|
aCS->SetZLayer (Graphic3d_ZLayerId_TopOSD);
|
||||||
|
}
|
||||||
|
if (aCS->GetTransformPersistenceMode() != Graphic3d_TMF_2d)
|
||||||
|
{
|
||||||
|
aCS->SetTransformPersistence (Graphic3d_TMF_2d, gp_Pnt (-1,-1,0));
|
||||||
|
}
|
||||||
|
|
||||||
Standard_Real aMinRange = aCS->GetMin();
|
Standard_Real aMinRange = aCS->GetMin();
|
||||||
Standard_Real aMaxRange = aCS->GetMax();
|
Standard_Real aMaxRange = aCS->GetMax();
|
||||||
@ -3492,7 +3512,12 @@ static int VColorScale (Draw_Interpretor& theDI,
|
|||||||
|
|
||||||
if (theArgNb <= 1)
|
if (theArgNb <= 1)
|
||||||
{
|
{
|
||||||
theDI << "Current color scale parameters:\n"
|
std::cout << "Error: wrong syntax at command '" << theArgVec[0] << "'!\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (theArgNb <= 2)
|
||||||
|
{
|
||||||
|
theDI << "Color scale parameters for '"<< theArgVec[1] << "':\n"
|
||||||
<< "Min range: " << aMinRange << "\n"
|
<< "Min range: " << aMinRange << "\n"
|
||||||
<< "Max range: " << aMaxRange << "\n"
|
<< "Max range: " << aMaxRange << "\n"
|
||||||
<< "Number of intervals: " << aNbIntervals << "\n"
|
<< "Number of intervals: " << aNbIntervals << "\n"
|
||||||
@ -3517,41 +3542,8 @@ static int VColorScale (Draw_Interpretor& theDI,
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Standard_CString aFirstArg = theArgVec[1];
|
|
||||||
TCollection_AsciiString aFlag (aFirstArg);
|
|
||||||
aFlag.LowerCase();
|
|
||||||
if (aFlag == "-hide" ||
|
|
||||||
aFlag == "-erase")
|
|
||||||
{
|
|
||||||
if (theArgNb > 2)
|
|
||||||
{
|
|
||||||
std::cout << "Error: wrong syntax at argument '" << theArgVec[1] << "'!\n";
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (!aView->ColorScaleIsDisplayed())
|
|
||||||
{
|
|
||||||
std::cout << "Error: color scale is not displayed!\n";
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
aView->ColorScaleErase();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (aFlag == "-show" ||
|
|
||||||
aFlag == "-display")
|
|
||||||
{
|
|
||||||
if (theArgNb > 2)
|
|
||||||
{
|
|
||||||
std::cout << "Error: wrong syntax at argument '" << theArgVec[1] << "'!\n";
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
aView->ColorScaleDisplay();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
|
for (Standard_Integer anArgIter = 2; anArgIter < theArgNb; ++anArgIter)
|
||||||
{
|
{
|
||||||
Standard_CString anArg = theArgVec[anArgIter];
|
Standard_CString anArg = theArgVec[anArgIter];
|
||||||
TCollection_AsciiString aFlag (anArg);
|
TCollection_AsciiString aFlag (anArg);
|
||||||
@ -3699,7 +3691,7 @@ static int VColorScale (Draw_Interpretor& theDI,
|
|||||||
if (Quantity_Color::ColorFromName (theArgVec[anArgIter + 2], aColorName))
|
if (Quantity_Color::ColorFromName (theArgVec[anArgIter + 2], aColorName))
|
||||||
{
|
{
|
||||||
aCS->SetColor (Quantity_Color (aColorName), anIndex);
|
aCS->SetColor (Quantity_Color (aColorName), anIndex);
|
||||||
aCS->SetColorType(Aspect_TOCSD_USER);
|
aCS->SetColorType (Aspect_TOCSD_USER);
|
||||||
anArgIter += 2;
|
anArgIter += 2;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -3867,8 +3859,8 @@ static int VColorScale (Draw_Interpretor& theDI,
|
|||||||
aMaxRange = 100;
|
aMaxRange = 100;
|
||||||
aNbIntervals = 10;
|
aNbIntervals = 10;
|
||||||
aLabPosition = Aspect_TOCSP_RIGHT;
|
aLabPosition = Aspect_TOCSP_RIGHT;
|
||||||
aCS->SetColorType(Aspect_TOCSD_AUTO);
|
aCS->SetColorType (Aspect_TOCSD_AUTO);
|
||||||
aCS->SetLabelType(Aspect_TOCSD_AUTO);
|
aCS->SetLabelType (Aspect_TOCSD_AUTO);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -3883,11 +3875,8 @@ static int VColorScale (Draw_Interpretor& theDI,
|
|||||||
aCS->SetRange (aMinRange, aMaxRange);
|
aCS->SetRange (aMinRange, aMaxRange);
|
||||||
aCS->SetNumberOfIntervals (aNbIntervals);
|
aCS->SetNumberOfIntervals (aNbIntervals);
|
||||||
aCS->SetLabelPosition (aLabPosition);
|
aCS->SetLabelPosition (aLabPosition);
|
||||||
|
aCS->SetToUpdate();
|
||||||
if (!aView->ColorScaleIsDisplayed())
|
aContext->Display (aCS);
|
||||||
{
|
|
||||||
aView->ColorScaleDisplay();
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -8837,7 +8826,7 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
|
|||||||
" : notice that EMF format requires patched gl2ps",
|
" : notice that EMF format requires patched gl2ps",
|
||||||
__FILE__,VExport,group);
|
__FILE__,VExport,group);
|
||||||
theCommands.Add("vcolorscale",
|
theCommands.Add("vcolorscale",
|
||||||
"vcolorscale : vcolorscale [-range RangeMin = 0 RangeMax = 100 Intervals = 10 -font HeightFont = 16 -textpos "
|
"vcolorscale : vcolorscale name [-range RangeMin = 0 RangeMax = 100 Intervals = 10 -font HeightFont = 16 -textpos "
|
||||||
"Position = left -xy X = 0 Y = 0] [-noupdate|-update]: draw color scale\n"
|
"Position = left -xy X = 0 Y = 0] [-noupdate|-update]: draw color scale\n"
|
||||||
"-demo/-demoversion draw a demoversion of color scale.\n"
|
"-demo/-demoversion draw a demoversion of color scale.\n"
|
||||||
"-show/display display color scale.\n"
|
"-show/display display color scale.\n"
|
||||||
|
2
tests/3rdparty/fonts/A1
vendored
2
tests/3rdparty/fonts/A1
vendored
@ -4,5 +4,5 @@ puts "OCC21450"
|
|||||||
puts "============"
|
puts "============"
|
||||||
puts ""
|
puts ""
|
||||||
|
|
||||||
vcolorscale -range 10 20 100 -font 16 -textpos right -xy 0 0
|
vcolorscale cs -range 10 20 100 -font 16 -textpos right -xy 0 0
|
||||||
|
|
||||||
|
@ -5,5 +5,5 @@ puts "============"
|
|||||||
puts ""
|
puts ""
|
||||||
|
|
||||||
vinit View1
|
vinit View1
|
||||||
vcolorscale -range 10 20 100 -font 16 -textpos right -xy 0 0
|
vcolorscale cs -range 10 20 100 -font 16 -textpos right -xy 0 0
|
||||||
set only_screen 0
|
set only_screen 0
|
||||||
|
@ -12,7 +12,7 @@ vinit View1
|
|||||||
vdisplay result
|
vdisplay result
|
||||||
vsetmaterial result SILVER
|
vsetmaterial result SILVER
|
||||||
vsettransparency result 0.6
|
vsettransparency result 0.6
|
||||||
vcolorscale -demo
|
vcolorscale cs -demo
|
||||||
vsetdispmode result 1
|
vsetdispmode result 1
|
||||||
|
|
||||||
set square 11309.6
|
set square 11309.6
|
||||||
|
@ -11,7 +11,7 @@ vinit View1 w=1024 h=512
|
|||||||
vsetdispmode 1
|
vsetdispmode 1
|
||||||
vdisplay b
|
vdisplay b
|
||||||
vfit
|
vfit
|
||||||
vcolorscale -range 10 20 100 -font 16 -textpos right -xy 0 0
|
vcolorscale cs -range 10 20 100 -font 16 -textpos right -xy 0 0
|
||||||
vmoveto 512 250
|
vmoveto 512 250
|
||||||
|
|
||||||
set only_screen 1
|
set only_screen 1
|
||||||
|
@ -9,24 +9,24 @@ vclear
|
|||||||
vaxo
|
vaxo
|
||||||
|
|
||||||
# create default color scale
|
# create default color scale
|
||||||
vcolorscale -demo
|
vcolorscale cs -demo
|
||||||
vdump ${imagedir}/${casename}_1.png
|
vdump ${imagedir}/${casename}_1.png
|
||||||
|
|
||||||
# reduce color scale range and number of intervals
|
# reduce color scale range and number of intervals
|
||||||
vcolorscale -range 0 20 5
|
vcolorscale cs -range 0 20 5
|
||||||
vdump ${imagedir}/${casename}_2.png
|
vdump ${imagedir}/${casename}_2.png
|
||||||
|
|
||||||
# set user-defined colors and labels for color scale
|
# set user-defined colors and labels for color scale
|
||||||
vcolorscale -colors white 0 0 1 green 1 0 0 1 1 1 -labels start 1 2 3 4 end
|
vcolorscale cs -colors white 0 0 1 green 1 0 0 1 1 1 -labels start 1 2 3 4 end
|
||||||
vdump ${imagedir}/${casename}_3.png
|
vdump ${imagedir}/${casename}_3.png
|
||||||
|
|
||||||
# change colors of first and last intervals
|
# change colors of first and last intervals
|
||||||
vcolorscale -color 0 0.42 0.35 0.8
|
vcolorscale cs -color 0 0.42 0.35 0.8
|
||||||
vcolorscale -color 4 pink
|
vcolorscale cs -color 4 pink
|
||||||
|
|
||||||
# change last label
|
# change last label
|
||||||
vcolorscale -label 5 "last"
|
vcolorscale cs -label 5 "last"
|
||||||
|
|
||||||
# set a title for color scale
|
# set a title for color scale
|
||||||
vcolorscale -title "My color scale"
|
vcolorscale cs -title "My color scale"
|
||||||
vdump ${imagedir}/${casename}_4.png
|
vdump ${imagedir}/${casename}_4.png
|
||||||
|
Loading…
x
Reference in New Issue
Block a user