-// File: ViewerTest.cxx
-// Created: Wed Jul 23 14:14:01 1997
-// Author: Henri JEANNIN
-// <bbl@entrax.paris3.matra-dtv.fr>
-// Modified by Eric Gouthiere [sep-oct 98] -> add commands for display...
+// Created on: 1997-07-23
+// Created by: Henri JEANNIN
+// Copyright (c) 1997-1999 Matra Datavision
+// Copyright (c) 1999-2012 OPEN CASCADE SAS
+//
+// The content of this file is subject to the Open CASCADE Technology Public
+// License Version 6.5 (the "License"). You may not use the content of this file
+// except in compliance with the License. Please obtain a copy of the License
+// at http://www.opencascade.org and read it completely before using this file.
+//
+// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
+// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
+// The Original Code and all software distributed under the License is
+// distributed on an "AS IS" basis, without warranty of any kind, and the
+// Initial Developer hereby disclaims all such warranties, including without
+// limitation, any warranties of merchantability, fitness for a particular
+// purpose or non-infringement. Please see the License for the specific terms
+// and conditions governing the rights and limitations under the License.
+
+// Modified by Eric Gouthiere [sep-oct 98] -> add commands for display...
// Modified by Robert Coublanc [nov 16-17-18 1998]
// -split ViewerTest.cxx into 3 files : ViewerTest.cxx,
// ViewerTest_ObjectCommands.cxx
#include <BRepAdaptor_Curve.hxx>
#include <StdSelect_ShapeTypeFilter.hxx>
#include <AIS.hxx>
+#include <AIS_Drawer.hxx>
#include <AIS_InteractiveObject.hxx>
#include <AIS_Trihedron.hxx>
#include <AIS_Axis.hxx>
#include <AIS_SignatureFilter.hxx>
#include <AIS_ListOfInteractive.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
-#include <Image_PixMap.hxx>
+#include <Aspect_InteriorStyle.hxx>
+#include <Graphic3d_AspectFillArea3d.hxx>
+#include <Image_AlienPixMap.hxx>
+#include <Prs3d_ShadingAspect.hxx>
#ifdef HAVE_CONFIG_H
# include <config.h>
#include <NIS_Triangulated.hxx>
extern int ViewerMainLoop(Standard_Integer argc, const char** argv);
-//=======================================================================
-//function : GetColorFromName
-//purpose : get the Quantity_NameOfColor from a string
-//=======================================================================
-
-#include <Quantity_NameOfColor.hxx>
#include <Quantity_Color.hxx>
#include <Quantity_NameOfColor.hxx>
#define DEFAULT_COLOR Quantity_NOC_GOLDENROD
#define DEFAULT_MATERIAL Graphic3d_NOM_BRASS
-static Quantity_NameOfColor GetColorFromName( const char *name )
-{
- Quantity_NameOfColor ret = DEFAULT_COLOR;
+//=======================================================================
+//function : GetColorFromName
+//purpose : get the Quantity_NameOfColor from a string
+//=======================================================================
- Standard_Boolean Found = Standard_False;
- Standard_CString colstring;
- for(Standard_Integer i=0;i<=514 && !Found;i++)
+Quantity_NameOfColor ViewerTest::GetColorFromName (const Standard_CString theName)
+{
+ for (Standard_Integer anIter = Quantity_NOC_BLACK; anIter <= Quantity_NOC_WHITE; ++anIter)
+ {
+ Standard_CString aColorName = Quantity_Color::StringName (Quantity_NameOfColor (anIter));
+ if (strcasecmp (theName, aColorName) == 0)
{
- colstring = Quantity_Color::StringName(Quantity_NameOfColor(i));
- if (!strcasecmp(name,colstring)) {
- ret = (Quantity_NameOfColor)i;
- Found = Standard_True;
- }
+ return Quantity_NameOfColor (anIter);
}
+ }
- return ret;
+ return DEFAULT_COLOR;
}
//=======================================================================
else if ( !strcasecmp(name,"STONE" ) ) mat = Graphic3d_NOM_STONE;
else if ( !strcasecmp(name,"CHROME" ) ) mat = Graphic3d_NOM_CHROME;
else if ( !strcasecmp(name,"ALUMINIUM" ) ) mat = Graphic3d_NOM_ALUMINIUM;
- else if ( !strcasecmp(name,"STONE" ) ) mat = Graphic3d_NOM_STONE;
else if ( !strcasecmp(name,"NEON_PHC" ) ) mat = Graphic3d_NOM_NEON_PHC;
else if ( !strcasecmp(name,"NEON_GNC" ) ) mat = Graphic3d_NOM_NEON_GNC;
else if ( !strcasecmp(name,"PLASTER" ) ) mat = Graphic3d_NOM_PLASTER;
aMap.UnBind2 (theName);
}
+ if (theAISObj.IsNull())
+ {
+ // object with specified name already unbound
+ return Standard_True;
+ }
+
// unbind AIS object if was bound with another name
aMap.UnBind1 (theAISObj);
Handle(AIS_InteractiveObject) aisPickedShape =
Handle(AIS_InteractiveObject)::DownCast(aContext->DetectedInteractive());
ret = aisPickedShape;
-#ifdef DEB
- const char *name =
-#endif
- ( GetMapOfAIS().IsBound1(aisPickedShape) )?
- GetMapOfAIS().Find1(aisPickedShape).ToCString() :
- (char *) "????";
}
}
return ret;
return 0;
}
+//==============================================================================
+//function : VSelPrecision
+//purpose : To set the selection precision mode and tolerance value
+//Draw arg : Selection precision mode (0 for window, 1 for view) and tolerance
+// value (integer number of pixel for window mode, double value of
+// sensitivity for view mode). Without arguments the function just
+// prints the current precision mode and the corresponding tolerance.
+//==============================================================================
+static int VSelPrecision(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if( argc > 3 )
+ {
+ di << "Use: " << argv[0] << " [precision_mode [tolerance_value]]\n";
+ return 1;
+ }
+
+ Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+ if( aContext.IsNull() )
+ return 1;
+
+ if( argc == 1 )
+ {
+ StdSelect_SensitivityMode aMode = aContext->SensitivityMode();
+ if( aMode == StdSelect_SM_WINDOW )
+ {
+ Standard_Integer aPixelTolerance = aContext->PixelTolerance();
+ di << "Precision mode : 0 (window)\n";
+ di << "Pixel tolerance : " << aPixelTolerance << "\n";
+ }
+ else if( aMode == StdSelect_SM_VIEW )
+ {
+ Standard_Real aSensitivity = aContext->Sensitivity();
+ di << "Precision mode : 1 (view)\n";
+ di << "Sensitivity : " << aSensitivity << "\n";
+ }
+ }
+ else if( argc > 1 )
+ {
+ StdSelect_SensitivityMode aMode = ( StdSelect_SensitivityMode )atoi( argv[1] );
+ aContext->SetSensitivityMode( aMode );
+ if( argc > 2 )
+ {
+ if( aMode == StdSelect_SM_WINDOW )
+ {
+ Standard_Integer aPixelTolerance = atoi( argv[2] );
+ aContext->SetPixelTolerance( aPixelTolerance );
+ }
+ else if( aMode == StdSelect_SM_VIEW )
+ {
+ Standard_Real aSensitivity = atof( argv[2] );
+ aContext->SetSensitivity( aSensitivity );
+ }
+ }
+ }
+ return 0;
+}
+
//==============================================================================
//function : VDump
//purpose : To dump the active view snapshot to image file
return 1;
}
- Image_TypeOfImage aBufferType = Image_TOI_RGB;
-
+ Graphic3d_BufferType aBufferType = Graphic3d_BT_RGB;
if (argc > 2)
{
TCollection_AsciiString aBuffTypeStr (argv[2]);
if (TCollection_AsciiString::ISSIMILAR (aBuffTypeStr, TCollection_AsciiString ("rgb")))
{
- aBufferType = Image_TOI_RGB;
+ aBufferType = Graphic3d_BT_RGB;
}
else if (TCollection_AsciiString::ISSIMILAR (aBuffTypeStr, TCollection_AsciiString ("rgba")))
{
- aBufferType = Image_TOI_RGBA;
+ aBufferType = Graphic3d_BT_RGBA;
}
else if (TCollection_AsciiString::ISSIMILAR (aBuffTypeStr, TCollection_AsciiString ("depth")))
{
- aBufferType = Image_TOI_FLOAT;
+ aBufferType = Graphic3d_BT_Depth;
}
}
Handle(AIS_InteractiveContext) IC;
Handle(V3d_View) view;
GetCtxAndView (IC, view);
- if (!view.IsNull())
+ if (view.IsNull())
{
- if (aWidth > 0 && aHeight > 0)
- {
- return view->ToPixMap (aWidth, aHeight, aBufferType)->Dump (argv[1]) ? 0 : 1;
- }
- else
+ di << "Cannot find an active viewer/view\n";
+ return 1;
+ }
+
+ if (aWidth <= 0 || aHeight <= 0)
+ {
+ if (!view->Dump (argv[1], aBufferType))
{
- return view->Dump (argv[1], aBufferType) ? 0 : 1;
+ di << "Dumping failed!\n";
+ return 1;
}
+ return 0;
}
- else
+
+ Image_AlienPixMap aPixMap;
+ if (!view->ToPixMap (aPixMap, aWidth, aHeight, aBufferType))
+ {
+ di << "Dumping failed!\n";
+ return 1;
+ }
+
+ if (aPixMap.SizeX() != Standard_Size(aWidth)
+ || aPixMap.SizeY() != Standard_Size(aHeight))
+ {
+ std::cout << "Warning! Dumped dimensions " << aPixMap.SizeX() << "x" << aPixMap.SizeY()
+ << " are lesser than requested " << aWidth << "x" << aHeight << "\n";
+ }
+ if (!aPixMap.Save (argv[1]))
{
- di << "Cannot find an active viewer/view" << "\n";
+ di << "Saving image failed!\n";
return 1;
}
+ return 0;
}
Standard_Boolean ThereIsCurrent;
Standard_Boolean ThereIsArgument;
Standard_Boolean IsBound = Standard_False ;
- Standard_Boolean HaveToSet;
- if (!strcasecmp( argv[0],"vsetcolor")) HaveToSet=Standard_True;
- else HaveToSet=Standard_False;
+ const Standard_Boolean HaveToSet=(strcasecmp( argv[0],"vsetcolor") == 0);
if (HaveToSet) {
- if ( argc<2 || argc > 3 ) { di << argv[0] << " syntax error: Passez 2 ou 3 arguments" << "\n"; return 1; }
- if ( argc == 2 ) {ThereIsArgument=Standard_False;}
- else ThereIsArgument=Standard_True;
-
+ if ( argc < 2 || argc > 3 ) { di << argv[0] << " syntax error: Give 2 or 3 arguments" << "\n"; return 1; }
+ ThereIsArgument = (argc != 2);
}
else {
- if ( argc > 2 ) { di << argv[0] << " syntax error: Passez au plus un argument" << "\n"; return 1; }
- if(argc==2) ThereIsArgument=Standard_True;
- else ThereIsArgument=Standard_False;
+ if ( argc > 2 ) { di << argv[0] << " syntax error: Given too many arguments" << "\n"; return 1; }
+ ThereIsArgument = (argc == 2);
}
if ( !a3DView().IsNull() ) {
Handle(AIS_InteractiveObject) ashape =
Handle(AIS_InteractiveObject)::DownCast (anObj);
#ifdef DEB
- //cout << "HaveToSet "<<HaveToSet <<" Color Given "<< argv[2] << " Color returned "<< GetColorFromName(argv[2]) << endl;
if (HaveToSet)
- di << "HaveToSet "<< "1" <<" Color Given "<< argv[2] << " Color returned "<< GetColorFromName(argv[2]) << "\n";
+ di << "HaveToSet "<< "1" <<" Color Given "<< argv[2] << " Color returned "<< ViewerTest::GetColorFromName(argv[2]) << "\n";
else
- di << "HaveToSet "<< "0" <<" Color Given "<< argv[2] << " Color returned "<< GetColorFromName(argv[2]) << "\n";
+ di << "HaveToSet 0\n";
#endif
- if(HaveToSet) {
- TheAISContext()->SetColor(ashape,GetColorFromName(argv[2]) );
- }
+ if(HaveToSet)
+ TheAISContext()->SetColor(ashape,ViewerTest::GetColorFromName(argv[2]) );
else
TheAISContext()->UnsetColor(ashape);
} else if (anObj->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) {
Handle(NIS_Triangulated) ashape =
Handle(NIS_Triangulated)::DownCast (anObj);
- if (ashape.IsNull() == Standard_False)
- ashape->SetColor (GetColorFromName(argv[2]));
+ if (!ashape.IsNull())
+ ashape->SetColor (ViewerTest::GetColorFromName(argv[2]));
}
}
TheAISContext() -> MoreCurrent() ;
TheAISContext() ->NextCurrent() )
{
- const Handle(AIS_InteractiveObject) ashape= TheAISContext()->Current();
+ const Handle(AIS_InteractiveObject) ashape= TheAISContext()->Current();
if (ashape.IsNull())
continue;
#ifdef DEB
- //cout << "HaveToSet "<<HaveToSet <<" Color Given "<< argv[2] << " Color returned "<< GetColorFromName(argv[2]) << endl;
- if (HaveToSet)
- di << "HaveToSet "<< "1" <<" Color Given "<< argv[2] << " Color returned "<< GetColorFromName(argv[2]) << "\n";
- else
- di << "HaveToSet "<< "0" <<" Color Given "<< argv[2] << " Color returned "<< GetColorFromName(argv[2]) << "\n";
+ if (HaveToSet)
+ di << "HaveToSet "<< "1" <<" Color Given "<< argv[2] << " Color returned "<< ViewerTest::GetColorFromName(argv[2]) << "\n";
+ else
+ di << "HaveToSet 0\n";
#endif
- if(HaveToSet)
- TheAISContext()->SetColor(ashape,GetColorFromName(argv[1]),Standard_False);
- else
- TheAISContext()->UnsetColor(ashape,Standard_False);
+ if(HaveToSet)
+ TheAISContext()->SetColor(ashape,ViewerTest::GetColorFromName(argv[1]),Standard_False);
+ else
+ TheAISContext()->UnsetColor(ashape,Standard_False);
}
TheAISContext()->UpdateCurrentViewer();
else if (!ThereIsCurrent && !ThereIsArgument){
ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it(GetMapOfAIS());
while ( it.More() ) {
- const Handle(AIS_InteractiveObject) ashape =
+ const Handle(AIS_InteractiveObject) ashape =
Handle(AIS_InteractiveObject)::DownCast(it.Key1());
if (!ashape.IsNull())
if(HaveToSet)
- TheAISContext()->SetColor(ashape,GetColorFromName(argv[1]),
- Standard_False);
+ TheAISContext()->SetColor(ashape,ViewerTest::GetColorFromName(argv[1]),Standard_False);
else
TheAISContext()->UnsetColor(ashape,Standard_False);
- it.Next();
+ it.Next();
}
TheAISContext()->UpdateCurrentViewer();
}
//Draw arg : vtransparency [name] TransparencyCoeficient
//==============================================================================
-
static int VTransparency (Draw_Interpretor& di, Standard_Integer argc,
const char** argv)
{
Standard_Boolean ThereIsCurrent;
Standard_Boolean ThereIsArgument;
Standard_Boolean IsBound = Standard_False ;
- Standard_Boolean HaveToSet;
- if (!strcasecmp( argv[0],"vsettransparency"))
- HaveToSet=Standard_True;
- else
- HaveToSet=Standard_False;
+ const Standard_Boolean HaveToSet = (strcasecmp( argv[0],"vsettransparency") == 0);
if (HaveToSet) {
if ( argc < 2 || argc > 3 ) { di << argv[0] << " syntax error passez 1 ou 2 arguments" << "\n"; return 1; }
- if ( argc == 2 ) {ThereIsArgument=Standard_False;}
- else ThereIsArgument=Standard_True;
+ ThereIsArgument = (argc != 2);
}
else{
if ( argc > 2 ) { di << argv[0] << " syntax error: Passez au plus un argument" << "\n"; return 1; }
- if(argc==2) ThereIsArgument=Standard_True;
- else ThereIsArgument=Standard_False;
+ ThereIsArgument = (argc == 2);
}
if ( !a3DView().IsNull() ) {
TheAISContext()->SetTransparency(ashape,atof(argv[2]) );
else
TheAISContext()->UnsetTransparency(ashape);
-} else if (anObj->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) {
+ } else if (anObj->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) {
const Handle(NIS_InteractiveObject) ashape =
Handle(NIS_InteractiveObject)::DownCast(anObj);
if(HaveToSet)
TheAISContext() -> MoreCurrent() ;
TheAISContext() ->NextCurrent() )
{
- Handle(AIS_InteractiveObject) ashape = TheAISContext() -> Current();
- if(HaveToSet) {
- TheAISContext()->SetTransparency(ashape,atof(argv[1]),Standard_False);
- }
- else
- TheAISContext()->UnsetTransparency(ashape,Standard_False);
+ Handle(AIS_InteractiveObject) ashape = TheAISContext() -> Current();
+ if(HaveToSet)
+ TheAISContext()->SetTransparency(ashape,atof(argv[1]),Standard_False);
+ else
+ TheAISContext()->UnsetTransparency(ashape,Standard_False);
}
TheAISContext()->UpdateCurrentViewer();
ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
it(GetMapOfAIS());
while ( it.More() ) {
- Handle(AIS_InteractiveObject) ashape =
+ Handle(AIS_InteractiveObject) ashape =
Handle(AIS_InteractiveObject)::DownCast(it.Key1());
if (!ashape.IsNull())
if(HaveToSet)
- TheAISContext()->SetTransparency(ashape,atof(argv[1]),
- Standard_False);
+ TheAISContext()->SetTransparency(ashape,atof(argv[1]),Standard_False);
else
TheAISContext()->UnsetTransparency(ashape,Standard_False);
- it.Next();
+ it.Next();
}
TheAISContext()->UpdateCurrentViewer();
}
Standard_Boolean ThereIsName;
Standard_Boolean IsBound = Standard_False ;
- Standard_Boolean HaveToSet;
- if (!strcasecmp( argv[0],"vsetmaterial")) HaveToSet=Standard_True;
- else HaveToSet=Standard_False;
+ const Standard_Boolean HaveToSet = (strcasecmp( argv[0],"vsetmaterial") == 0);
if (HaveToSet) {
if ( argc < 2 || argc > 3 ) { di << argv[0] << " syntax error passez 1 ou 2 arguments" << "\n"; return 1; }
- if ( argc == 2 ) {ThereIsName=Standard_False;}
- else ThereIsName=Standard_True;
+ ThereIsName = (argc != 2);
}
else {
if ( argc>2 ) { di << argv[0] << " syntax error passez au plus un argument" << "\n"; return 1; }
- if (argc==2) ThereIsName=Standard_True;
- else ThereIsName=Standard_False;
-
+ ThereIsName = (argc == 2);
}
if ( !a3DView().IsNull() ) {
Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2(name));
if (!ashape.IsNull())
if (HaveToSet)
- TheAISContext()->SetMaterial (ashape,
- GetMaterialFromName (argv[2]) );
+ TheAISContext()->SetMaterial(ashape,GetMaterialFromName(argv[2]));
else
TheAISContext()->UnsetMaterial(ashape);
}
TheAISContext() -> MoreCurrent() ;
TheAISContext() ->NextCurrent() )
{
- Handle(AIS_InteractiveObject) ashape = TheAISContext() -> Current();
- if (HaveToSet)
- TheAISContext()->SetMaterial(ashape,GetMaterialFromName(argv[1]),
- Standard_False);
- else
- TheAISContext()->UnsetMaterial(ashape,Standard_False);
+ Handle(AIS_InteractiveObject) ashape = TheAISContext()->Current();
+ if (HaveToSet)
+ TheAISContext()->SetMaterial(ashape,GetMaterialFromName(argv[1]),Standard_False);
+ else
+ TheAISContext()->UnsetMaterial(ashape,Standard_False);
}
TheAISContext()->UpdateCurrentViewer();
}
ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
it(GetMapOfAIS());
while ( it.More() ) {
- Handle(AIS_InteractiveObject) ashape =
+ Handle(AIS_InteractiveObject) ashape =
Handle(AIS_InteractiveObject)::DownCast (it.Key1());
- if (!ashape.IsNull())
+ if (!ashape.IsNull())
if (HaveToSet)
- TheAISContext()->SetMaterial(ashape,GetMaterialFromName(argv[1]),
- Standard_False );
+ TheAISContext()->SetMaterial(ashape,GetMaterialFromName(argv[1]),Standard_False);
else
TheAISContext()->UnsetMaterial(ashape,Standard_False);
- it.Next();
+ it.Next();
}
TheAISContext()->UpdateCurrentViewer();
}
Standard_Boolean ThereIsArgument;
Standard_Boolean IsBound = Standard_False ;
- Standard_Boolean HaveToSet;
- if (!strcasecmp( argv[0],"vsetwidth")) HaveToSet=Standard_True;
- else HaveToSet=Standard_False;
+ const Standard_Boolean HaveToSet = (strcasecmp( argv[0],"vsetwidth") == 0);
if (HaveToSet) {
if ( argc < 2 || argc > 3 ) { di << argv[0] << " syntax error passez 1 ou 2 arguments" << "\n"; return 1; }
- if ( argc == 2 ) {ThereIsArgument=Standard_False;}
- else ThereIsArgument=Standard_True;
+ ThereIsArgument = (argc != 2);
}
else {
if ( argc>2 ) { di << argv[0] << " syntax error passez au plus 1 argument" << "\n"; return 1; }
- if (argc==2) ThereIsArgument=Standard_True;
- else ThereIsArgument=Standard_False;
+ ThereIsArgument = (argc == 2);
}
if ( !a3DView().IsNull() ) {
TCollection_AsciiString name;
TheAISContext() -> MoreCurrent() ;
TheAISContext() ->NextCurrent() )
{
- Handle(AIS_InteractiveObject) ashape = TheAISContext() -> Current();
- if (HaveToSet)
- TheAISContext()->SetWidth(ashape,atof (argv[1]),Standard_False);
- else
- TheAISContext()->UnsetWidth (ashape,Standard_False);
-
+ Handle(AIS_InteractiveObject) ashape = TheAISContext() -> Current();
+ if (HaveToSet)
+ TheAISContext()->SetWidth(ashape,atof(argv[1]),Standard_False);
+ else
+ TheAISContext()->UnsetWidth(ashape,Standard_False);
}
TheAISContext()->UpdateCurrentViewer();
}
Handle(AIS_InteractiveObject)::DownCast (it.Key1());
if (!ashape.IsNull())
if (HaveToSet)
- TheAISContext()->SetWidth(ashape,atof (argv[1]),Standard_False );
+ TheAISContext()->SetWidth(ashape,atof(argv[1]),Standard_False);
else
- TheAISContext()->UnsetWidth (ashape,Standard_False);
+ TheAISContext()->UnsetWidth(ashape,Standard_False);
it.Next();
}
TheAISContext()->UpdateCurrentViewer();
}
return 0;
}
+
+//==============================================================================
+//function : VInteriorStyle
+//purpose : sets interior style of the a selected or named or displayed shape
+//Draw arg : vsetinteriorstyle [shape] style
+//==============================================================================
+static void SetInteriorStyle (const Handle(AIS_InteractiveObject)& theIAO,
+ const Standard_Integer theStyle,
+ Draw_Interpretor& di)
+{
+ if (theStyle < Aspect_IS_EMPTY || theStyle > Aspect_IS_HIDDENLINE) {
+ di << "Style must be within a range [0 (Aspect_IS_EMPTY), " << Aspect_IS_HIDDENLINE <<
+ " (Aspect_IS_HIDDENLINE)]\n";
+ return;
+ }
+ const Handle(Prs3d_Drawer)& aDrawer = theIAO->Attributes();
+ Handle(Prs3d_ShadingAspect) aShadingAspect = aDrawer->ShadingAspect();
+ Handle(Graphic3d_AspectFillArea3d) aFillAspect = aShadingAspect->Aspect();
+ Aspect_InteriorStyle aStyle = (Aspect_InteriorStyle) (theStyle);
+ aFillAspect->SetInteriorStyle (aStyle);
+ TheAISContext()->RecomputePrsOnly (theIAO, Standard_False /*update*/, Standard_True /*all modes*/);
+}
+
+static int VInteriorStyle (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 2 || argc > 3) {
+ di << argv[0] << " requires 2 or 3 arguments\n";
+ di << "Usage : " << argv[0] << " [shape] Style : Set interior style" << "\n";
+ di << "Style must match Aspect_InteriorStyle and be one of:\n";
+ di << " 0 = EMPTY, 1 = HOLLOW, 2 = HATCH, 3 = SOLID, 4 = HIDDENLINE\n";
+ return 1;
+ }
+
+ Standard_Boolean ThereIsCurrent;
+ Standard_Boolean ThereIsArgument;
+ Standard_Boolean IsBound = Standard_False ;
+
+ ThereIsArgument = (argc > 2);
+ if ( !a3DView().IsNull() ) {
+ TCollection_AsciiString name;
+ if (ThereIsArgument) {
+ name = argv[1];
+ IsBound= GetMapOfAIS().IsBound2(name);
+ }
+ if (TheAISContext()->HasOpenedContext())
+ TheAISContext()->CloseLocalContext();
+
+ if (TheAISContext() -> NbCurrents() > 0 )
+ ThereIsCurrent =Standard_True;
+ else
+ ThereIsCurrent =Standard_False;
+
+ if ( ThereIsArgument && IsBound ) {
+ const Handle(Standard_Transient) anObj = GetMapOfAIS().Find2(name);
+ if (anObj->IsKind(STANDARD_TYPE(AIS_InteractiveObject))) {
+ const Handle(AIS_InteractiveObject) ashape =
+ Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
+ SetInteriorStyle (ashape, atoi (argv[2]), di);
+ }
+ }
+ //=======================================================================
+ // No arguments specified
+ // But there are one or more selected objects
+ //=======================================================================
+ if (ThereIsCurrent && !ThereIsArgument) {
+ for (TheAISContext() -> InitCurrent() ;
+ TheAISContext() -> MoreCurrent() ;
+ TheAISContext() ->NextCurrent() )
+ {
+ Handle(AIS_InteractiveObject) ashape = TheAISContext() -> Current();
+ SetInteriorStyle (ashape, atoi (argv[1]), di);
+ }
+ }
+ //=======================================================================
+ // No arguments specified and there are no selected objects
+ //=======================================================================
+ else if (!ThereIsCurrent && !ThereIsArgument){
+ ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
+ it(GetMapOfAIS());
+ while ( it.More() ) {
+ Handle(AIS_InteractiveObject) ashape =
+ Handle(AIS_InteractiveObject)::DownCast (it.Key1());
+ if (!ashape.IsNull())
+ SetInteriorStyle (ashape, atoi (argv[1]), di);
+ it.Next();
+ }
+ }
+ TheAISContext()->UpdateCurrentViewer();
+ }
+ return 0;
+}
+
//==============================================================================
//function : VDonly2
//author : ege
//purpose : Sharpen or roughten the quality of the shading
//Draw arg : vshading ShapeName 0.1->0.00001 1 deg-> 30 deg
//==============================================================================
-static int VShading(Draw_Interpretor& ,Standard_Integer argc, const char** argv) {
- Standard_Boolean HaveToSet;
-// Standard_Real myDevAngle;
+static int VShading(Draw_Interpretor& ,Standard_Integer argc, const char** argv)
+{
Standard_Real myDevCoef;
Handle(AIS_InteractiveObject) TheAisIO;
// Verifications
- if (!strcasecmp(argv[0],"vsetshading") ) HaveToSet=Standard_True;
- else HaveToSet=Standard_False;
+ const Standard_Boolean HaveToSet = (strcasecmp(argv[0],"vsetshading") == 0);
+
if (TheAISContext()->HasOpenedContext())
TheAISContext()->CloseLocalContext();
myDevCoef =atof(argv[2]);
}
-
TCollection_AsciiString name=argv[1];
if (GetMapOfAIS().IsBound2(name ))
- TheAisIO =
- Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
+ TheAisIO = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
if (TheAisIO.IsNull())
TheAisIO=GetAISShapeFromName((const char *)name.ToCString());
- if (HaveToSet) {
+ if (HaveToSet)
TheAISContext()->SetDeviationCoefficient(TheAisIO,myDevCoef,Standard_True);
- }
-
- else {
+ else
TheAISContext()->SetDeviationCoefficient(TheAisIO,0.0008,Standard_True);
- }
-
TheAISContext()->Redisplay(TheAisIO);
return 0;
}
static int VActivatedMode (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
- Standard_Boolean HaveToSet;
Standard_Boolean ThereIsName = Standard_False ;
if(!a3DView().IsNull()){
- if (!strcasecmp(argv[0],"vsetam")) HaveToSet=Standard_True;
- else HaveToSet=Standard_False;
-
+ const Standard_Boolean HaveToSet = (strcasecmp(argv[0],"vsetam") == 0);
// verification des arguments
if (HaveToSet) {
if (argc<2||argc>3) { di<<" Syntaxe error"<<"\n";return 1;}
- if (argc==3) ThereIsName=Standard_True;
- else ThereIsName=Standard_False;
+ ThereIsName = (argc == 3);
}
else {
// vunsetam
if (argc>1) {di<<" Syntaxe error"<<"\n";return 1;}
else {
- di<<" R.A.Z de tous les modes de selecion"<<"\n";
- di<<" Fermeture du Context local"<<"\n";
+ di<<" R.A.Z de tous les modes de selecion"<<"\n";
+ di<<" Fermeture du Context local"<<"\n";
if (TheAISContext()->HasOpenedContext())
TheAISContext()->CloseLocalContext();
}
-
}
-
// IL n'y a aps de nom de shape passe en argument
if (HaveToSet && !ThereIsName){
Standard_Integer aMode=atoi(argv [1]);
const char *cmode="???";
-
switch (aMode) {
case 0: cmode = "Shape"; break;
case 1: cmode = "Vertex"; break;
}
if( !TheAISContext()->HasOpenedContext() ) {
- // il n'y a pas de Context local d'ouvert
- // on en ouvre un et on charge toutes les shapes displayees
- // on load tous les objets displayees et on Activate les objets de la liste
- AIS_ListOfInteractive ListOfIO;
- // on sauve dans une AISListOfInteractive tous les objets currents
- if (TheAISContext()->NbCurrents()>0 ){
- TheAISContext()->UnhilightCurrents(Standard_False);
-
- for (TheAISContext()->InitCurrent(); TheAISContext()->MoreCurrent(); TheAISContext()->NextCurrent() ){
- ListOfIO.Append(TheAISContext()->Current() );
-
+ // il n'y a pas de Context local d'ouvert
+ // on en ouvre un et on charge toutes les shapes displayees
+ // on load tous les objets displayees et on Activate les objets de la liste
+ AIS_ListOfInteractive ListOfIO;
+ // on sauve dans une AISListOfInteractive tous les objets currents
+ if (TheAISContext()->NbCurrents()>0 ){
+ TheAISContext()->UnhilightCurrents(Standard_False);
+
+ for (TheAISContext()->InitCurrent(); TheAISContext()->MoreCurrent(); TheAISContext()->NextCurrent() ){
+ ListOfIO.Append(TheAISContext()->Current() );
}
}
//==============================================================================
static int VState(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
- Standard_Boolean ThereIsCurrent=Standard_False;
- Standard_Boolean ThereIsArguments=Standard_False;
TheAISContext()->CloseAllContexts();
- if (argc>=2 ) {
- ThereIsArguments=Standard_True;
- }
- if (TheAISContext()->NbCurrents()>0 ) {
- ThereIsCurrent=Standard_True;
- }
+ const Standard_Boolean ThereIsArguments=(argc>=2);
+ const Standard_Boolean ThereIsCurrent=(TheAISContext()->NbCurrents()>0);
// Debut...
// ==================
// Il y a un argument
// ==================
- if (ThereIsArguments ) {
+ if (ThereIsArguments) {
for (int cpt=1;cpt<argc;cpt++) {
// Verification que lq piece est bien bindee.
if (GetMapOfAIS().IsBound2(argv[cpt]) ) {
}
Standard_Boolean IsBound = GetMapOfAIS().IsBound2(shapeName);
- Standard_Boolean IsDatum = Standard_False;
Handle(Standard_Transient) anObj;
if ( IsBound ) {
anObj = GetMapOfAIS().Find2(shapeName);
/////////////////////
TopoDS_Shape aShape = DBRep::Get(a[1]);
aContext2D->EraseAll(Standard_True);
- Standard_Integer aPolyAlgo = 0;
+ //Standard_Integer aPolyAlgo = 0;
Standard_Boolean IsPoly = Standard_False;
gp_Ax2 anAx2 = gp::XOY();
/////////////////////
TopoDS_Shape aShape = DBRep::Get(a[1]);
aContext2D->EraseAll(Standard_True);
- Standard_Integer aPolyAlgo = 0;
+ //Standard_Integer aPolyAlgo = 0;
Standard_Boolean IsPoly = Standard_True;
gp_Ax2 anAx2 = gp::XOY();
ViewerTest::ObjectCommands(theCommands);
ViewerTest::FilletCommands(theCommands);
ViewerTest::VoxelCommands(theCommands);
+ ViewerTest::OpenGlCommands(theCommands);
const char *group = "AIS_Display";
"vunsetwidth : vwidth [name of shape]",
__FILE__,VWidth,group);
+ theCommands.Add("vsetinteriorstyle",
+ "vsetinteriorstyle : vsetinteriorstyle [name of shape] style",
+ __FILE__,VInteriorStyle,group);
+
theCommands.Add("vardis",
"vardis : display activeareas",
__FILE__,VDispAreas,group);
"vardisp : erase active entities",
__FILE__,VClearSensi,group);
+ theCommands.Add("vselprecision",
+ "vselprecision : vselprecision [precision_mode [tolerance_value]]",
+ __FILE__,VSelPrecision,group);
+
theCommands.Add("vperf",
"vperf: vperf ShapeName 1/0(Transfo/Location) 1/0(Primitives sensibles ON/OFF)",
__FILE__,VPerf,group);