-// File: ViewerTest_ObjectsCommands.cxx
-// Created: Thu Nov 12 15:50:42 1998
-// Author: Robert COUBLANC
-// <rob@robox.paris1.matra-dtv.fr>
+// File: ViewerTest_ObjectsCommands.cxx
+// Created: Thu Nov 12 15:50:42 1998
+// Author: Robert COUBLANC
+// Copyright: OPEN CASCADE 1998
//===============================================
DEFINE_STANDARD_HANDLE(MyTextClass, AIS_InteractiveObject)
-class MyTextClass:public AIS_InteractiveObject{
-
+class MyTextClass:public AIS_InteractiveObject
+{
public:
// CASCADE RTTI
DEFINE_STANDARD_RTTI(MyTextClass );
IMPLEMENT_STANDARD_RTTIEXT(MyTextClass, AIS_InteractiveObject)
-
MyTextClass::MyTextClass( const TCollection_ExtendedString& text, const gp_Pnt& position,
Quantity_Color color = Quantity_NOC_YELLOW,
Standard_Integer aHJust = Graphic3d_HTA_LEFT,
static int VDrawText (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
- // Verification des arguments
- if ( argc > 17 ) {di<<argv[0]<<" Syntaxe error"<<"\n"; return 1;}
- Quantity_Parameter R, G, B;
- Quantity_Color aColor;
- Standard_Real angle;
- Standard_Real height;
- Standard_Boolean zoom;
- OSD_FontAspect aspect;
- TCollection_AsciiString font;
- gp_Pnt pnt;
- int hor_align;
- int ver_align;
- TCollection_AsciiString aFont;
- TCollection_AsciiString name = argv[1];
-
- //Declarations et creation des objets par default
- Standard_Real X,Y,Z;
- X = atof(argv[2]);
- Y = atof(argv[3]);
- Z = atof(argv[4]);
- pnt.SetCoord(X,Y,Z);
-
- R = atof(argv[5])/255.;
- G = atof(argv[6])/255.;
- B = atof(argv[7])/255.;
-
- hor_align = atoi(argv[8]);
- ver_align = atoi(argv[9]);
-
- angle = atof(argv[10]);
-
- zoom = atoi(argv[11]);
-
- height = atof(argv[12]);
-
- aspect = OSD_FontAspect(atoi(argv[13]));
-
- if(argc == 14)
- font.AssignCat("Courier");
- if(argc == 15)
- font.AssignCat(argv[14]);
- if(argc == 16)
+ // Check arguments
+ if (argc < 14)
{
- font.AssignCat(argv[14]);
- font.AssignCat(" ");
- font.AssignCat(argv[15]);
+ di<<"Error: "<<argv[0]<<" - invalid number of arguments\n";
+ di<<"Usage: type help "<<argv[0]<<"\n";
+ return 1; //TCL_ERROR
}
- if(argc == 17)
+
+ Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+
+ // Create 3D view if it doesn't exist
+ if ( aContext.IsNull() )
{
- font.AssignCat(argv[14]);
- font.AssignCat(" ");
- font.AssignCat(argv[15]);
- font.AssignCat(" ");
- font.AssignCat(argv[16]);
+ ViewerTest::ViewerInit();
+ aContext = ViewerTest::GetAISContext();
+ if( aContext.IsNull() )
+ {
+ di << "Error: Cannot create a 3D view\n";
+ return 1; //TCL_ERROR
+ }
}
- aColor.SetValues( R, G, B, Quantity_TOC_RGB );
+ // Text position
+ const Standard_Real X = atof(argv[2]);
+ const Standard_Real Y = atof(argv[3]);
+ const Standard_Real Z = atof(argv[4]);
+ const gp_Pnt pnt(X,Y,Z);
- Handle(AIS_InteractiveContext) aContext= ViewerTest::GetAISContext();
+ // Text color
+ const Quantity_Parameter R = atof(argv[5])/255.;
+ const Quantity_Parameter G = atof(argv[6])/255.;
+ const Quantity_Parameter B = atof(argv[7])/255.;
+ const Quantity_Color aColor( R, G, B, Quantity_TOC_RGB );
- Handle(MyTextClass) my=new MyTextClass(argv[1],pnt,aColor,hor_align,ver_align,angle,zoom,height,aspect,font.ToCString());
+ // Text alignment
+ const int hor_align = atoi(argv[8]);
+ const int ver_align = atoi(argv[9]);
- aContext->Display(my,Standard_True);
+ // Text angle
+ const Standard_Real angle = atof(argv[10]);
- if(aContext.IsNull())
+ // Text zooming
+ const Standard_Boolean zoom = atoi(argv[11]);
+
+ // Text height
+ const Standard_Real height = atof(argv[12]);
+
+ // Text aspect
+ const OSD_FontAspect aspect = OSD_FontAspect(atoi(argv[13]));
+
+ // Text font
+ TCollection_AsciiString font;
+ if(argc < 15)
+ font.AssignCat("Courier");
+ else
+ font.AssignCat(argv[14]);
+
+ // Text is multibyte
+ const Standard_Boolean isMultibyte = (argc < 16)? Standard_False : (atoi(argv[15]) != 0);
+
+ // Read text string
+ TCollection_ExtendedString name;
+ if (isMultibyte)
{
- di << "use 'vinit' command before " << argv[0] << "\n";
- return -1;
+ const char *str = argv[1];
+ while (*str)
+ {
+ unsigned short c1 = *str++;
+ unsigned short c2 = *str++;
+ if (!c1 || !c2) break;
+ name += (Standard_ExtCharacter)((c1 << 8) | c2);
+ }
}
+ else
+ {
+ name += argv[1];
+ }
+
+ if (name.Length())
+ {
+ Handle(MyTextClass) myT = new MyTextClass(name,pnt,aColor,hor_align,ver_align,angle,zoom,height,aspect,font.ToCString());
+ aContext->Display(myT,Standard_True);
+ }
+
return 0;
}
if (anActivePlanes < aView->View()->PlaneLimit())
{
aView->SetPlaneOn (aPlaneV3d); // add to enabled planes list
- aView->Update();
+ aView->Update();
}
else
{
__FILE__,VCircleBuilder,group);
theCommands.Add("vdrawtext",
- "vdrawtext : vdrawtext name X Y Z R G B hor_align ver_align angle zoomable height Aspect FONT ",
+ "vdrawtext : vdrawtext name X Y Z R G B hor_align ver_align angle zoomable height Aspect [Font [isMultiByte]]",
__FILE__,VDrawText,group);
theCommands.Add("vdrawsphere",
theCommands.Add("vclipplane",
"vclipplane : vclipplane [x y z dx dy dz] [planeId {on/off/del/display/hide}]",
__FILE__,VClipPlane,group);
-
}