mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0026490: Visualization - implement draw commands 'voverlaytext' and 'vlayerline' using AIS_InteractiveObject class
Command 'voverlaytext' was removed, its functionality was transfered to command 'vdrawtext'. Corresponding test cases were updated. Command 'vlayerline' was implemented on AIS.
This commit is contained in:
parent
ecac41a957
commit
61b0191c54
src
AIS
ViewerTest
tests
@ -141,6 +141,24 @@ void AIS_TextLabel::SetFont (Standard_CString theFont)
|
||||
myDrawer->TextAspect()->SetFont (myFont.ToCString());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetDisplayType
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_TextLabel::SetDisplayType (const Aspect_TypeOfDisplayText theDisplayType)
|
||||
{
|
||||
myDrawer->TextAspect()->Aspect()->SetDisplayType(theDisplayType);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetColorSubTitle
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_TextLabel::SetColorSubTitle (const Quantity_Color& theColor)
|
||||
{
|
||||
myDrawer->TextAspect()->Aspect()->SetColorSubTitle(theColor);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Compute
|
||||
//purpose :
|
||||
|
@ -43,6 +43,9 @@ public:
|
||||
//! Setup position.
|
||||
Standard_EXPORT void SetPosition (const gp_Pnt& thePosition);
|
||||
|
||||
//! Get position.
|
||||
Standard_EXPORT gp_Pnt GetPosition () {return myPosition;};
|
||||
|
||||
//! Setup horizontal justification.
|
||||
Standard_EXPORT void SetHJustification (const Graphic3d_HorizontalTextAlignment theHJust);
|
||||
|
||||
@ -64,6 +67,19 @@ public:
|
||||
//! Setup font.
|
||||
Standard_EXPORT void SetFont (Standard_CString theFont);
|
||||
|
||||
//! Define the display type of the text.
|
||||
//!
|
||||
//! TODT_NORMAL Default display. Text only.
|
||||
//! TODT_SUBTITLE There is a subtitle under the text.
|
||||
//! TODT_DEKALE The text is displayed with a 3D style.
|
||||
//! TODT_BLEND The text is displayed in XOR.
|
||||
//! TODT_DIMENSION Dimension line under text will be invisible.
|
||||
Standard_EXPORT void SetDisplayType (const Aspect_TypeOfDisplayText theDisplayType);
|
||||
|
||||
//! Modifies the colour of the subtitle for the TODT_SUBTITLE TextDisplayType
|
||||
//! and the colour of backgroubd for the TODT_DEKALE TextDisplayType.
|
||||
Standard_EXPORT void SetColorSubTitle (const Quantity_Color& theColor);
|
||||
|
||||
private:
|
||||
|
||||
//! Compute
|
||||
|
@ -132,6 +132,7 @@
|
||||
#include <Prs3d_VertexDrawMode.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Prs3d_PointAspect.hxx>
|
||||
#include <Prs3d_TextAspect.hxx>
|
||||
|
||||
#include <Image_AlienPixMap.hxx>
|
||||
#include <TColStd_HArray1OfAsciiString.hxx>
|
||||
@ -2426,6 +2427,10 @@ static int VDrawText (Draw_Interpretor& theDI,
|
||||
|
||||
aTextPrs->SetText (aText);
|
||||
|
||||
Graphic3d_TransModeFlags aTrsfPersFlags = Graphic3d_TMF_None;
|
||||
gp_Pnt aTPPosition;
|
||||
Aspect_TypeOfDisplayText aDisplayType = Aspect_TODT_NORMAL;
|
||||
|
||||
for (; anArgIt < theArgsNb; ++anArgIt)
|
||||
{
|
||||
TCollection_AsciiString aParam (theArgVec[anArgIt]);
|
||||
@ -2612,6 +2617,105 @@ static int VDrawText (Draw_Interpretor& theDI,
|
||||
|
||||
aTextPrs->SetFont (theArgVec[anArgIt]);
|
||||
}
|
||||
else if (aParam == "-disptype"
|
||||
|| aParam == "-displaytype")
|
||||
{
|
||||
if (++anArgIt >= theArgsNb)
|
||||
{
|
||||
std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
|
||||
return 1;
|
||||
}
|
||||
TCollection_AsciiString aType (theArgVec[anArgIt]);
|
||||
aType.LowerCase();
|
||||
if (aType == "subtitle")
|
||||
aDisplayType = Aspect_TODT_SUBTITLE;
|
||||
else if (aType == "decal")
|
||||
aDisplayType = Aspect_TODT_DEKALE;
|
||||
else if (aType == "blend")
|
||||
aDisplayType = Aspect_TODT_BLEND;
|
||||
else if (aType == "dimension")
|
||||
aDisplayType = Aspect_TODT_DIMENSION;
|
||||
else if (aType == "normal")
|
||||
aDisplayType = Aspect_TODT_NORMAL;
|
||||
else
|
||||
{
|
||||
std::cout << "Error: wrong display type '" << aType << "'.\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (aParam == "-subcolor"
|
||||
|| aParam == "-subtitlecolor")
|
||||
{
|
||||
if (anArgIt + 1 >= theArgsNb)
|
||||
{
|
||||
std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
TCollection_AsciiString aColor (theArgVec[anArgIt + 1]);
|
||||
Quantity_NameOfColor aNameOfColor = Quantity_NOC_BLACK;
|
||||
if (Quantity_Color::ColorFromName (aColor.ToCString(), aNameOfColor))
|
||||
{
|
||||
anArgIt += 1;
|
||||
aTextPrs->SetColorSubTitle (aNameOfColor);
|
||||
continue;
|
||||
}
|
||||
else if (anArgIt + 3 >= theArgsNb)
|
||||
{
|
||||
std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
TCollection_AsciiString aGreen (theArgVec[anArgIt + 2]);
|
||||
TCollection_AsciiString aBlue (theArgVec[anArgIt + 3]);
|
||||
if (!aColor.IsRealValue()
|
||||
|| !aGreen.IsRealValue()
|
||||
|| !aBlue.IsRealValue())
|
||||
{
|
||||
std::cout << "Error: wrong syntax at '" << aParam.ToCString() << "'.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
const Graphic3d_Vec3d anRGB (aColor.RealValue(),
|
||||
aGreen.RealValue(),
|
||||
aBlue.RealValue());
|
||||
|
||||
aTextPrs->SetColorSubTitle (Quantity_Color (anRGB.r(), anRGB.g(), anRGB.b(), Quantity_TOC_RGB));
|
||||
anArgIt += 3;
|
||||
}
|
||||
else if (aParam == "-2d")
|
||||
{
|
||||
aTrsfPersFlags = Graphic3d_TMF_2d;
|
||||
}
|
||||
else if (aParam == "-trsfperspos"
|
||||
|| aParam == "-perspos")
|
||||
{
|
||||
if (anArgIt + 2 >= theArgsNb)
|
||||
{
|
||||
std::cerr << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
TCollection_AsciiString aX (theArgVec[++anArgIt]);
|
||||
TCollection_AsciiString aY (theArgVec[++anArgIt]);
|
||||
TCollection_AsciiString aZ = "0";
|
||||
if (!aX.IsIntegerValue()
|
||||
|| !aY.IsIntegerValue())
|
||||
{
|
||||
std::cerr << "Error: wrong syntax at '" << aParam << "'.\n";
|
||||
return 1;
|
||||
}
|
||||
if (anArgIt + 1 < theArgsNb)
|
||||
{
|
||||
TCollection_AsciiString aTemp = theArgVec[anArgIt + 1];
|
||||
if (aTemp.IsIntegerValue())
|
||||
{
|
||||
aZ = aTemp;
|
||||
++anArgIt;
|
||||
}
|
||||
}
|
||||
aTPPosition.SetCoord (aX.IntegerValue(), aY.IntegerValue(), aZ.IntegerValue());
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Error: unknown argument '" << aParam << "'\n";
|
||||
@ -2619,6 +2723,21 @@ static int VDrawText (Draw_Interpretor& theDI,
|
||||
}
|
||||
}
|
||||
|
||||
if (aTrsfPersFlags != Graphic3d_TMF_None)
|
||||
{
|
||||
aTextPrs->SetTransformPersistence (aTrsfPersFlags, aTPPosition);
|
||||
aTextPrs->SetDisplayType (aDisplayType);
|
||||
aTextPrs->SetZLayer(Graphic3d_ZLayerId_TopOSD);
|
||||
if (aTextPrs->GetPosition().Z() != 0)
|
||||
{
|
||||
aTextPrs->SetPosition (gp_Pnt(aTextPrs->GetPosition().X(), aTextPrs->GetPosition().Y(), 0));
|
||||
}
|
||||
}
|
||||
else if (aTrsfPersFlags != aTextPrs->TransformPersistence().Flags)
|
||||
{
|
||||
aTextPrs->SetTransformPersistence (aTrsfPersFlags);
|
||||
aTextPrs->SetDisplayType (Aspect_TODT_NORMAL);
|
||||
}
|
||||
ViewerTest::Display (aName, aTextPrs, Standard_False);
|
||||
return 0;
|
||||
}
|
||||
@ -6005,6 +6124,13 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
|
||||
"\n\t\t: [-height height=16]"
|
||||
"\n\t\t: [-aspect {regular|bold|italic|bolditalic}=regular]"
|
||||
"\n\t\t: [-font font=Times]"
|
||||
"\n\t\t: [-2d]"
|
||||
"\n\t\t: [-perspos {X Y Z}=0 0 0], where"
|
||||
"\n\t\t X and Y define the coordinate origin in 2d space relative to the view window"
|
||||
"\n\t\t Example: X=0 Y=0 is center, X=1 Y=1 is upper right corner etc..."
|
||||
"\n\t\t Z coordinate defines the gap from border of view window (except center position)."
|
||||
"\n\t\t: [-disptype {blend|decal|subtitle|dimension|normal}=normal}"
|
||||
"\n\t\t: [-subcolor {R G B|name}=white]"
|
||||
"\n\t\t: [-noupdate]"
|
||||
"\n\t\t: Display text label at specified position.",
|
||||
__FILE__, VDrawText, group);
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <AIS_ListOfInteractive.hxx>
|
||||
#include <AIS_ListIteratorOfListOfInteractive.hxx>
|
||||
#include <DBRep.hxx>
|
||||
#include <Graphic3d_ArrayOfPolylines.hxx>
|
||||
#include <Graphic3d_AspectMarker3d.hxx>
|
||||
#include <Graphic3d_ExportFormat.hxx>
|
||||
#include <Graphic3d_NameOfTextureEnv.hxx>
|
||||
@ -71,6 +72,8 @@
|
||||
#include <Graphic3d_Texture2Dmanual.hxx>
|
||||
#include <Prs3d_ShadingAspect.hxx>
|
||||
#include <Prs3d_Drawer.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Prs3d_Root.hxx>
|
||||
|
||||
#ifdef WNT
|
||||
#undef DrawText
|
||||
@ -4606,139 +4609,66 @@ static int VZLayer (Draw_Interpretor& di, Standard_Integer argc, const char** ar
|
||||
return 0;
|
||||
}
|
||||
|
||||
// this class provides a presentation of text item in v3d view under-/overlayer
|
||||
class V3d_TextItem : public Visual3d_LayerItem
|
||||
{
|
||||
public:
|
||||
|
||||
// CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTI(V3d_TextItem, Visual3d_LayerItem)
|
||||
|
||||
// constructor
|
||||
Standard_EXPORT V3d_TextItem(const TCollection_AsciiString& theText,
|
||||
const Standard_Real theX1,
|
||||
const Standard_Real theY1,
|
||||
const Standard_Real theHeight,
|
||||
const TCollection_AsciiString& theFontName,
|
||||
const Quantity_Color& theColor,
|
||||
const Quantity_Color& theSubtitleColor,
|
||||
const Aspect_TypeOfDisplayText& theTypeOfDisplay,
|
||||
const Handle(Visual3d_Layer)& theLayer);
|
||||
|
||||
// redraw method
|
||||
Standard_EXPORT void RedrawLayerPrs();
|
||||
|
||||
private:
|
||||
|
||||
Standard_Real myX1;
|
||||
Standard_Real myY1;
|
||||
TCollection_AsciiString myText;
|
||||
Standard_Real myHeight;
|
||||
Handle(Visual3d_Layer) myLayer;
|
||||
Quantity_Color myColor;
|
||||
Quantity_Color mySubtitleColor;
|
||||
Aspect_TypeOfDisplayText myType;
|
||||
TCollection_AsciiString myFontName;
|
||||
};
|
||||
|
||||
|
||||
// create and add to display the text item
|
||||
V3d_TextItem::V3d_TextItem (const TCollection_AsciiString& theText,
|
||||
const Standard_Real theX1,
|
||||
const Standard_Real theY1,
|
||||
const Standard_Real theHeight,
|
||||
const TCollection_AsciiString& theFontName,
|
||||
const Quantity_Color& theColor,
|
||||
const Quantity_Color& theSubtitleColor,
|
||||
const Aspect_TypeOfDisplayText& theTypeOfDisplay,
|
||||
const Handle(Visual3d_Layer)& theLayer)
|
||||
: myX1 (theX1), myY1 (theY1),
|
||||
myText (theText),
|
||||
myHeight (theHeight),
|
||||
myLayer (theLayer),
|
||||
myColor (theColor),
|
||||
mySubtitleColor (theSubtitleColor),
|
||||
myType (theTypeOfDisplay),
|
||||
myFontName (theFontName)
|
||||
{
|
||||
if (!myLayer.IsNull ())
|
||||
myLayer->AddLayerItem (this);
|
||||
}
|
||||
|
||||
// render item
|
||||
void V3d_TextItem::RedrawLayerPrs ()
|
||||
{
|
||||
if (myLayer.IsNull ())
|
||||
return;
|
||||
|
||||
myLayer->SetColor (myColor);
|
||||
myLayer->SetTextAttributes (myFontName.ToCString (), myType, mySubtitleColor);
|
||||
myLayer->DrawText (myText.ToCString (), myX1, myY1, myHeight);
|
||||
}
|
||||
|
||||
// The Visual3d_LayerItem line item for "vlayerline" command
|
||||
// it provides a presentation of line with user-defined
|
||||
// linewidth, linetype and transparency.
|
||||
class V3d_LineItem : public Visual3d_LayerItem
|
||||
class V3d_LineItem : public AIS_InteractiveObject
|
||||
{
|
||||
public:
|
||||
// CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTI(V3d_LineItem, Visual3d_LayerItem)
|
||||
DEFINE_STANDARD_RTTI(V3d_LineItem, AIS_InteractiveObject)
|
||||
|
||||
// constructor
|
||||
Standard_EXPORT V3d_LineItem(Standard_Real X1, Standard_Real Y1,
|
||||
Standard_Real X2, Standard_Real Y2,
|
||||
V3d_LayerMgrPointer theLayerMgr,
|
||||
Aspect_TypeOfLine theType = Aspect_TOL_SOLID,
|
||||
Standard_Real theWidth = 0.5,
|
||||
Standard_Real theTransp = 1.0);
|
||||
|
||||
// redraw method
|
||||
Standard_EXPORT void RedrawLayerPrs();
|
||||
private:
|
||||
|
||||
void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
|
||||
const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const Standard_Integer theMode);
|
||||
|
||||
void ComputeSelection (const Handle(SelectMgr_Selection)& /*aSelection*/,
|
||||
const Standard_Integer /*aMode*/){};
|
||||
|
||||
private:
|
||||
|
||||
Standard_Real myX1, myY1, myX2, myY2;
|
||||
V3d_LayerMgrPointer myLayerMgr;
|
||||
Aspect_TypeOfLine myType;
|
||||
Standard_Real myWidth;
|
||||
Standard_Real myTransparency;
|
||||
};
|
||||
|
||||
|
||||
// default constructor for line item
|
||||
V3d_LineItem::V3d_LineItem(Standard_Real X1, Standard_Real Y1,
|
||||
Standard_Real X2, Standard_Real Y2,
|
||||
V3d_LayerMgrPointer theLayerMgr,
|
||||
Aspect_TypeOfLine theType,
|
||||
Standard_Real theWidth,
|
||||
Standard_Real theTransp) :
|
||||
myX1(X1), myY1(Y1), myX2(X2), myY2(Y2), myLayerMgr(theLayerMgr),
|
||||
myType(theType), myWidth(theWidth), myTransparency(theTransp)
|
||||
myX1(X1), myY1(Y1), myX2(X2), myY2(Y2),
|
||||
myType(theType), myWidth(theWidth)
|
||||
{
|
||||
if (myLayerMgr && !myLayerMgr->Overlay().IsNull())
|
||||
myLayerMgr->Overlay()->AddLayerItem (this);
|
||||
SetTransparency (1-theTransp);
|
||||
}
|
||||
|
||||
// render line
|
||||
void V3d_LineItem::RedrawLayerPrs ()
|
||||
void V3d_LineItem::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePresentationManager*/,
|
||||
const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const Standard_Integer /*theMode*/)
|
||||
{
|
||||
Handle (Visual3d_Layer) aOverlay;
|
||||
|
||||
if (myLayerMgr)
|
||||
aOverlay = myLayerMgr->Overlay();
|
||||
|
||||
if (!aOverlay.IsNull())
|
||||
{
|
||||
Quantity_Color aColor(1.0, 0, 0, Quantity_TOC_RGB);
|
||||
aOverlay->SetColor(aColor);
|
||||
aOverlay->SetTransparency((Standard_ShortReal)myTransparency);
|
||||
aOverlay->SetLineAttributes((Aspect_TypeOfLine)myType, myWidth);
|
||||
aOverlay->BeginPolyline();
|
||||
aOverlay->AddVertex(myX1, myY1);
|
||||
aOverlay->AddVertex(myX2, myY2);
|
||||
aOverlay->ClosePrimitive();
|
||||
}
|
||||
thePresentation->Clear();
|
||||
Quantity_Color aColor (1.0, 0, 0, Quantity_TOC_RGB);
|
||||
Standard_Integer aWidth, aHeight;
|
||||
ViewerTest::CurrentView()->Window()->Size (aWidth, aHeight);
|
||||
Handle (Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePresentation);
|
||||
Handle(Graphic3d_ArrayOfPolylines) aPrim = new Graphic3d_ArrayOfPolylines(5);
|
||||
aPrim->AddVertex(myX1, aHeight-myY1, 0.);
|
||||
aPrim->AddVertex(myX2, aHeight-myY2, 0.);
|
||||
Handle(Prs3d_LineAspect) anAspect = new Prs3d_LineAspect (aColor, (Aspect_TypeOfLine)myType, myWidth);
|
||||
aGroup->SetPrimitivesAspect (anAspect->Aspect());
|
||||
aGroup->AddPrimitiveArray (aPrim);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
@ -4770,6 +4700,7 @@ static int VLayerLine(Draw_Interpretor& di, Standard_Integer argc, const char**
|
||||
return 1;
|
||||
}
|
||||
|
||||
Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
|
||||
// get the input params
|
||||
Standard_Real X1 = Draw::Atof(argv[1]);
|
||||
Standard_Real Y1 = Draw::Atof(argv[2]);
|
||||
@ -4816,121 +4747,23 @@ static int VLayerLine(Draw_Interpretor& di, Standard_Integer argc, const char**
|
||||
aLineType = Aspect_TOL_SOLID;
|
||||
}
|
||||
|
||||
// replace layer manager
|
||||
Handle(V3d_LayerMgr) aMgr = new V3d_LayerMgr(aView);
|
||||
aView->SetLayerMgr(aMgr);
|
||||
static Handle (V3d_LineItem) aLine;
|
||||
if (!aLine.IsNull())
|
||||
{
|
||||
aContext->Erase (aLine);
|
||||
}
|
||||
aLine = new V3d_LineItem (X1, Y1, X2, Y2,
|
||||
aLineType, aWidth,
|
||||
aTransparency);
|
||||
|
||||
// add line item
|
||||
Handle (V3d_LineItem) anItem = new V3d_LineItem(X1, Y1, X2, Y2,
|
||||
aMgr.operator->(),
|
||||
aLineType, aWidth,
|
||||
aTransparency);
|
||||
|
||||
// update view
|
||||
aView->MustBeResized();
|
||||
aView->Redraw();
|
||||
aLine->SetTransformPersistence (Graphic3d_TMF_2d,gp_Pnt(-1,-1,0));
|
||||
aLine->SetZLayer (Graphic3d_ZLayerId_TopOSD);
|
||||
aLine->SetToUpdate();
|
||||
aContext->Display (aLine, Standard_True);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VOverlayText
|
||||
//purpose : Test text displaying in view overlay
|
||||
//=======================================================================
|
||||
static int VOverlayText (Draw_Interpretor& di, Standard_Integer argc, const char**argv)
|
||||
{
|
||||
// get the active view
|
||||
Handle(V3d_View) aView = ViewerTest::CurrentView();
|
||||
if (aView.IsNull())
|
||||
{
|
||||
di << "No active view. Please call vinit.\n";
|
||||
return 1;
|
||||
}
|
||||
else if (argc < 4 || argc > 13)
|
||||
{
|
||||
di << "Use: " << argv[0];
|
||||
di << " text x y [height] [font_name] [text_color: R G B] [displayType]\n";
|
||||
di << "[background_color: R G B]\n";
|
||||
di << " height - pixel height of the text (default=10.0)\n";
|
||||
di << " font_name - name of font (default=courier)\n";
|
||||
di << " text_color - R G B values of text color (default=255.0 255.0 255.0)\n";
|
||||
di << " display_type = {normal/subtitle/decal/blend/dimension}, (default=normal)\n";
|
||||
di << " background_color- R G B values used for subtitle and decal text\n";
|
||||
di << "(default=255.0 255.0 255.0)\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
TCollection_AsciiString aText (argv[1]);
|
||||
Standard_Real aPosX = Draw::Atof(argv[2]);
|
||||
Standard_Real aPosY = Draw::Atof(argv[3]);
|
||||
Standard_Real aHeight = (argc >= 5) ? Draw::Atof (argv[4]) : 10.0;
|
||||
|
||||
// font name
|
||||
TCollection_AsciiString aFontName = "Courier";
|
||||
if (argc >= 6)
|
||||
aFontName = TCollection_AsciiString (argv[5]);
|
||||
|
||||
// text colors
|
||||
Quantity_Parameter aColorRed = 1.0;
|
||||
Quantity_Parameter aColorGreen = 1.0;
|
||||
Quantity_Parameter aColorBlue = 1.0;
|
||||
if (argc >= 9)
|
||||
{
|
||||
aColorRed = Draw::Atof (argv[6])/255.;
|
||||
aColorGreen = Draw::Atof (argv[7])/255.;
|
||||
aColorBlue = Draw::Atof (argv[8])/255.;
|
||||
}
|
||||
|
||||
// display type
|
||||
TCollection_AsciiString aDispStr;
|
||||
if (argc >= 10)
|
||||
aDispStr = TCollection_AsciiString (argv[9]);
|
||||
|
||||
Aspect_TypeOfDisplayText aTextType = Aspect_TODT_NORMAL;
|
||||
if (aDispStr.IsEqual ("subtitle"))
|
||||
aTextType = Aspect_TODT_SUBTITLE;
|
||||
else if (aDispStr.IsEqual ("decal"))
|
||||
aTextType = Aspect_TODT_DEKALE;
|
||||
else if (aDispStr.IsEqual ("blend"))
|
||||
aTextType = Aspect_TODT_BLEND;
|
||||
else if (aDispStr.IsEqual ("dimension"))
|
||||
aTextType = Aspect_TODT_DIMENSION;
|
||||
|
||||
// subtitle color
|
||||
Quantity_Parameter aSubRed = 1.0;
|
||||
Quantity_Parameter aSubGreen = 1.0;
|
||||
Quantity_Parameter aSubBlue = 1.0;
|
||||
if (argc == 13)
|
||||
{
|
||||
aSubRed = Draw::Atof (argv[10])/255.;
|
||||
aSubGreen = Draw::Atof (argv[11])/255.;
|
||||
aSubBlue = Draw::Atof (argv[12])/255.;
|
||||
}
|
||||
|
||||
// check fo current overlay
|
||||
Handle(Visual3d_Layer) anOverlay = aView->Viewer()->Viewer()->OverLayer ();
|
||||
if (anOverlay.IsNull ())
|
||||
{
|
||||
Handle(V3d_LayerMgr) aMgr = new V3d_LayerMgr (aView);
|
||||
anOverlay = aMgr->Overlay ();
|
||||
aView->SetLayerMgr (aMgr);
|
||||
}
|
||||
|
||||
Quantity_Color aTextColor (aColorRed, aColorGreen,
|
||||
aColorBlue, Quantity_TOC_RGB);
|
||||
Quantity_Color aSubtColor (aSubRed, aSubGreen,
|
||||
aSubBlue, Quantity_TOC_RGB);
|
||||
|
||||
// add text item
|
||||
Handle(V3d_TextItem) anItem = new V3d_TextItem (aText, aPosX, aPosY,
|
||||
aHeight, aFontName, aTextColor, aSubtColor, aTextType, anOverlay);
|
||||
|
||||
// update view
|
||||
aView->MustBeResized();
|
||||
aView->Redraw();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//function : VGrid
|
||||
@ -9063,14 +8896,6 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
|
||||
" vzlayer disable depthtest 1\n"
|
||||
" vzlayer del 1\n",
|
||||
__FILE__,VZLayer,group);
|
||||
theCommands.Add("voverlaytext",
|
||||
"voverlaytext : text x y [height] [font_name] [text_color: R G B] [display_type] [background_color: R G B]"
|
||||
" : height - pixel height of the text (default=10.0)"
|
||||
" : font_name - name of font (default=courier)"
|
||||
" : text_color - three values: RedColor GreenColor BlueColor (default = 255.0 255.0 255.0) "
|
||||
" : display_type = {normal/subtitle/decal/blend}, (default=normal) "
|
||||
" : background_color - three values: RedColor GreenColor BlueColor (default = 255.0 255.0 255.0), the parameter is defined for subtitle and decal display types ",
|
||||
__FILE__,VOverlayText,group);
|
||||
theCommands.Add("vlayerline",
|
||||
"vlayerline : vlayerline x1 y1 x2 y2 [linewidth=0.5] [linetype=0] [transparency=1.0]",
|
||||
__FILE__,VLayerLine,group);
|
||||
|
16
tests/3rdparty/fonts/A7
vendored
16
tests/3rdparty/fonts/A7
vendored
@ -4,21 +4,21 @@ puts "Test case prints overlay labels with different subtitle styles"
|
||||
puts "============"
|
||||
puts ""
|
||||
|
||||
voverlaytext "Overlay Test Blend" 100 50 16 Times-Roman 255 255 0 blend 0 0 255
|
||||
vdrawtext t1 "Overlay Test Blend" -2d -perspos -1 1 -pos 100 -50 0 -height 16 -font Times-Roman -color 1 1 0 -disptype blend -subcolor 0 0 1
|
||||
|
||||
voverlaytext "Overlay Test Decal" 100 100 16 Times-Roman 255 255 0 decal 0 0 255
|
||||
vdrawtext t2 "Overlay Test Decal" -2d -perspos -1 1 -pos 100 -100 0 -height 16 -font Times-Roman -color 1 1 0 -disptype decal -subcolor 0 0 1
|
||||
|
||||
voverlaytext "Overlay Test Subtitle" 100 150 16 Times-Roman 255 255 0 subtitle 0 0 255
|
||||
vdrawtext t3 "Overlay Test Subtitle" -2d -perspos -1 1 -pos 100 -150 0 -height 16 -font Times-Roman -color 1 1 0 -disptype subtitle -subcolor 0 0 1
|
||||
|
||||
voverlaytext "Overlay Test Normal" 100 200 16 Times-Roman 0 255 255 normal 0 0 255
|
||||
vdrawtext t4 "Overlay Test Normal" -2d -perspos -1 1 -pos 100 -200 0 -height 16 -font Times-Roman -color 0 1 1 -disptype normal -subcolor 0 0 1
|
||||
|
||||
voverlaytext " Overlay Test Normal \n Second line" 100 250 16 Times-Roman 0 255 255 normal 0 0 255
|
||||
vdrawtext t5 " Overlay Test Normal \n Second line" -2d -perspos -1 1 -pos 100 -250 0 -height 16 -font Times-Roman -color 0 1 1 -disptype normal -subcolor 0 0 1
|
||||
|
||||
voverlaytext " Overlay Test Subtitle\n Second line" 100 300 16 Times-Roman 255 255 0 subtitle 0 0 255
|
||||
vdrawtext t6 " Overlay Test Subtitle\n Second line" -2d -perspos -1 1 -pos 100 -300 0 -height 16 -font Times-Roman -color 1 1 0 -disptype subtitle -subcolor 0 0 1
|
||||
|
||||
voverlaytext " Overlay Test Decal \n Second line" 100 350 16 Times-Roman 255 255 0 decal 0 0 255
|
||||
vdrawtext t7 " Overlay Test Decal \n Second line" -2d -perspos -1 1 -pos 100 -350 0 -height 16 -font Times-Roman -color 1 1 0 -disptype decal -subcolor 0 0 1
|
||||
|
||||
voverlaytext " Overlay Test Blend \n Second line" 100 400 16 Times-Roman 255 255 0 blend 0 0 255
|
||||
vdrawtext t8 " Overlay Test Blend \n Second line" -2d -perspos -1 1 -pos 100 -400 0 -height 16 -font Times-Roman -color 1 1 0 -disptype blend -subcolor 0 0 1
|
||||
|
||||
box b 1 2 3
|
||||
vsetdispmode 1
|
||||
|
@ -10,13 +10,13 @@ set BugNumber OCC22879
|
||||
|
||||
vinit
|
||||
|
||||
voverlaytext "Text Height=14" 10.0 10.0 14.0
|
||||
voverlaytext "Text Height=25" 10.0 40.0 25.0
|
||||
voverlaytext "Arial" 10.0 60.0 18.0 "Arial" 255.0 0.0 0.0
|
||||
voverlaytext "Times New Roman" 10.0 80.0 20.0 "Times New Roman" 0.0 0.0 255.0
|
||||
voverlaytext "Subtitle" 10.0 110.0 20.0 "Arial" 0.0 255.0 0.0 subtitle 76.5 76.5 76.5
|
||||
voverlaytext "Decal" 10.0 140.0 20.0 "Arial" 0.0 0.0 255.0 decal 255.0 0.0 0.0
|
||||
voverlaytext "Blend" 10.0 170.0 20.0 "Arial" 255.0 0.0 0.0 blend
|
||||
vdrawtext t1 "Text Height=14" -2d -perspos -1 1 -pos 10 -10 0 -height 14 -color 1 1 1
|
||||
vdrawtext t2 "Text Height=25" -2d -perspos -1 1 -pos 10 -40 0 -height 25 -color 1 1 1
|
||||
vdrawtext t3 "Arial" -2d -perspos -1 1 -pos 10 -60 0 -height 18 -font Arial -color 1 0 0
|
||||
vdrawtext t4 "Times New Roman" -2d -perspos -1 1 -pos 10 -80 0 -height 18 -font Times-Roman -color 0 0 1
|
||||
vdrawtext t5 "Subtitle" -2d -perspos -1 1 -pos 10 -110 0 -height 20 -font Arial -color 0 1 0 -disptype subtitle -subcolor 0.3 0.3 0.3
|
||||
vdrawtext t6 "Decal" -2d -perspos -1 1 -pos 10 -140 0 -height 20 -font Arial -color 0 0 1 -disptype decal -subcolor 1 0 0
|
||||
vdrawtext t7 "Blend" -2d -perspos -1 1 -pos 10 -170 0 -height 20 -font Arial -color 1 0 0 -disptype blend
|
||||
box b 50 -700 450 50 50 50
|
||||
vdisplay b
|
||||
vsetdispmode 1
|
||||
|
@ -17,9 +17,9 @@ vdrawtext 000_3D "000 3D" -pos 0.0 0.0 0.0 -color 1.0 1.0 1.0 -halign center -va
|
||||
vdrawtext 001_3D "001 3D" -pos 0.0 1.0 0.0 -color 1.0 1.0 1.0 -halign center -valign center -angle 000 -zoom 0 -height 16 -aspect regular -font Courier
|
||||
vdrawtext 101_3D "101 3D" -pos 0.0 2.0 0.0 -color 1.0 1.0 1.0 -halign center -valign center -angle 000 -zoom 0 -height 16 -aspect regular -font Courier
|
||||
vdrawtext 110_3D "110 3D" -pos 0.0 3.0 0.0 -color 1.0 1.0 1.0 -halign center -valign center -angle 000 -zoom 0 -height 16 -aspect regular -font Courier
|
||||
voverlaytext "000 2D" 100 200 16 Courier 255 255 255 normal 0 0 255
|
||||
voverlaytext "001 2D" 100 250 16 Courier 255 255 255 normal 0 0 255
|
||||
voverlaytext "101 2D" 100 300 16 Courier 255 255 255 normal 0 0 255
|
||||
voverlaytext "110 2D" 100 350 16 Courier 255 255 255 normal 0 0 255
|
||||
vdrawtext t1 "000 2D" -2d -perspos -1 1 -pos 100 -200 0 -height 16 -font Courier -color 1 1 1 -disptype normal -subcolor 0 0 1
|
||||
vdrawtext t2 "001 2D" -2d -perspos -1 1 -pos 100 -250 0 -height 16 -font Courier -color 1 1 1 -disptype normal -subcolor 0 0 1
|
||||
vdrawtext t3 "101 2D" -2d -perspos -1 1 -pos 100 -300 0 -height 16 -font Courier -color 1 1 1 -disptype normal -subcolor 0 0 1
|
||||
vdrawtext t4 "110 2D" -2d -perspos -1 1 -pos 100 -350 0 -height 16 -font Courier -color 1 1 1 -disptype normal -subcolor 0 0 1
|
||||
|
||||
set only_screen 1
|
||||
|
@ -25,7 +25,7 @@ text2brep t "text" "Arial" 8
|
||||
vdisplay t
|
||||
|
||||
# overlay objects
|
||||
voverlaytext "Overlay text!" 200 440 40
|
||||
vdrawtext t1 "Overlay text!" -2d -perspos -1 1 -pos 200 -440 0 -height 40
|
||||
|
||||
# markers
|
||||
vpoint p 1 1 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user