return TheMap;
}
+
+//==============================================================================
+//function : VDisplayAISObject
+//purpose : register interactive object in the map of AIS objects;
+// if other object with such name already registered, it will be kept
+// or replaced depending on value of <theReplaceIfExists>,
+// if "true" - the old object will be cleared from AIS context;
+// returns Standard_True if <theAISObj> registered in map;
+//==============================================================================
+Standard_EXPORT Standard_Boolean VDisplayAISObject (const TCollection_AsciiString& theName,
+ const Handle(AIS_InteractiveObject)& theAISObj,
+ Standard_Boolean theReplaceIfExists = Standard_True)
+{
+ ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
+ Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
+ if (aContextAIS.IsNull())
+ {
+ std::cout << "AIS context is not available.\n";
+ return Standard_False;
+ }
+
+ if (aMap.IsBound2 (theName))
+ {
+ if (!theReplaceIfExists)
+ {
+ std::cout << "Other interactive object has been already "
+ << "registered with name: " << theName << ".\n"
+ << "Please use another name.\n";
+ return Standard_False;
+ }
+
+ // stop displaying object
+ Handle(AIS_InteractiveObject) anOldObj =
+ Handle(AIS_InteractiveObject)::DownCast (aMap.Find2 (theName));
+
+ if (!anOldObj.IsNull())
+ aContextAIS->Clear (anOldObj, Standard_True);
+
+ // remove name and old object from map
+ aMap.UnBind2 (theName);
+ }
+
+ // unbind AIS object if was bound with another name
+ aMap.UnBind1 (theAISObj);
+
+ // can be registered without rebinding
+ aMap.Bind (theAISObj, theName);
+ aContextAIS->Display (theAISObj, Standard_True);
+ return Standard_True;
+}
+
static TColStd_MapOfInteger theactivatedmodes(8);
static TColStd_ListOfTransient theEventMgrs;
Handle(V3d_Viewer) ViewerTest::GetViewerFromContext()
{
- return TheAISContext()->CurrentViewer();
+ return !TheAISContext().IsNull() ? TheAISContext()->CurrentViewer() : Handle(V3d_Viewer)();
}
Handle(V3d_Viewer) ViewerTest::GetCollectorFromContext()
{
- return TheAISContext()->CurrentViewer();
+ return !TheAISContext().IsNull() ? TheAISContext()->CurrentViewer() : Handle(V3d_Viewer)();
}
} else if (it.Key1()->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) {
const Handle(NIS_InteractiveObject) anObj =
Handle(NIS_InteractiveObject)::DownCast (it.Key1());
- TheNISContext()->Remove(anObj,Standard_False);
+ TheNISContext()->Remove(anObj);
}
it.Next();
}
TheAISContext()->UpdateCurrentViewer();
- TheNISContext()->UpdateViews();
+// TheNISContext()->UpdateViews();
GetMapOfAIS().Clear();
}
}
} else if (it.Key1()->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) {
const Handle(NIS_InteractiveObject) aShape =
Handle(NIS_InteractiveObject)::DownCast(it.Key1());
- TheNISContext()->Erase(aShape,Standard_False);
+ TheNISContext()->Erase(aShape);
}
it.Next();
}
Handle(AIS_InteractiveObject)::DownCast (anObj);
TheAISContext()->Display(aShape, Standard_False);
} else if (anObj->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) {
- const Handle(NIS_InteractiveObject) aShape =
+ Handle(NIS_InteractiveObject) aShape =
Handle(NIS_InteractiveObject)::DownCast (anObj);
- TheNISContext()->Display(aShape, 0L, Standard_False);
+ TheNISContext()->Display(aShape);
}
}
}
TheAISContext() ->UpdateCurrentViewer();
- TheNISContext() ->UpdateViews();
+// TheNISContext() ->UpdateViews();
}
return 0;
}
} else if (it.Key1()->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) {
const Handle(NIS_InteractiveObject) aShape =
Handle(NIS_InteractiveObject)::DownCast(it.Key1());
- TheNISContext()->Erase(aShape,Standard_False);
+ TheNISContext()->Erase(aShape);
}
it.Next();
}
TheAISContext() ->UpdateCurrentViewer();
- TheNISContext()->UpdateViews();
+// TheNISContext()->UpdateViews();
}
//===============================================================
} else if (anObj->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) {
const Handle(NIS_InteractiveObject) aShape =
Handle(NIS_InteractiveObject)::DownCast (anObj);
- TheNISContext()->Erase(aShape,Standard_False);
+ TheNISContext()->Erase(aShape);
}
}
}
TheAISContext() ->UpdateCurrentViewer();
- TheNISContext() ->UpdateViews();
+// TheNISContext() ->UpdateViews();
}
return 0;
}
} else if (it.Key1()->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) {
const Handle(NIS_InteractiveObject) aShape =
Handle(NIS_InteractiveObject)::DownCast(it.Key1());
- TheNISContext()->Erase(aShape,Standard_False);
+ TheNISContext()->Erase(aShape);
}
it.Next();
}
TheAISContext() ->UpdateCurrentViewer();
- TheNISContext() ->UpdateViews();
+// TheNISContext() ->UpdateViews();
return 0;
}
} else if (it.Key1()->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) {
const Handle(NIS_InteractiveObject) aShape =
Handle(NIS_InteractiveObject)::DownCast(it.Key1());
- TheNISContext()->Erase(aShape,Standard_False);
+ TheNISContext()->Erase(aShape);
}
it.Next();
}
Handle(AIS_InteractiveObject)::DownCast(it.Key1());
TheAISContext()->Display(aShape, Standard_False);
} else if (it.Key1()->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) {
- const Handle(NIS_InteractiveObject) aShape =
+ Handle(NIS_InteractiveObject) aShape =
Handle(NIS_InteractiveObject)::DownCast(it.Key1());
- TheNISContext()->Display(aShape, 0L, Standard_False);
+ TheNISContext()->Display(aShape);
}
it.Next();
}
TheAISContext() ->UpdateCurrentViewer();
- TheNISContext() ->UpdateViews();
+// TheNISContext() ->UpdateViews();
}
return 0;
}
if(myAISContext.IsNull())
{
di << "use 'vinit' command before " << argv[0] << "\n";
- return 0;
+ return 1;
}
Handle(AIS_InteractiveObject) TheAisIO;
Handle(AIS_TexturedShape) myShape;
Standard_Integer myPreviousMode = 0;
- if (!argv[1])
+ if (argc<2 || !argv[1])
{
di << argv[0] <<" syntax error - Type 'help vtex'"<<"\n";
- return 0;
+ return 1;
}
TCollection_AsciiString name = argv[1];
if (TheAisIO.IsNull())
{
di <<"shape "<<name.ToCString()<<" doesn\'t exist"<<"\n";
- return 0;
+ return 1;
}
if (TheAisIO->IsKind(STANDARD_TYPE(AIS_TexturedShape)) && !TheAisIO.IsNull())
}
else
{
- myAISContext->Erase(TheAisIO,Standard_False);
+ myAISContext->Clear(TheAisIO,Standard_False);
myShape = new AIS_TexturedShape (DBRep::Get(argv[1]));
GetMapOfAIS().UnBind1(TheAisIO);
GetMapOfAIS().UnBind2(name);
if(argc<=1)
{
di << argv[0] <<" syntax error - Type 'help vtex'" << "\n";
- return 0;
+ return 1;
}
- if (argv[2])
+ if (argc>2 && argv[2])
{
if(strcasecmp(argv[2],"?")==0)
{
if(argc<2)
{
di << argv[0] <<" syntax error - Type 'help vtex'" << "\n";
- return 0;
+ return 1;
}
myShape->SetTextureScale (( argv[2] ? Standard_True : Standard_False ),
if(argc<2)
{
di << argv[0] <<" syntax error - Type 'help vtex'" << "\n";
- return 0;
+ return 1;
}
myShape->SetTextureOrigin (( argv[2] ? Standard_True : Standard_False ),
( argv[2] ? atof(argv[2]) : 0.0 ),
if(argc<2)
{
di << argv[0] <<" syntax error - Type 'help vtex'" << "\n";
- return 0;
+ return 1;
}
- if (argv[2])
+ if (argc>2 && argv[2])
{
di <<"Texture repeat enabled"<<"\n";
myShape->SetTextureRepeat(Standard_True, atof(argv[2]), atof(argv[argc-1]) );
if(argc<2)
{
di << argv[0] <<" syntax error - Type 'help vtex'" << "\n";
- return 0;
+ return 1;
}
myShape->SetTextureRepeat(Standard_False);
myShape->SetTextureOrigin(Standard_False);
myAISContext->Display(myShape, Standard_True);
myAISContext->Update(myShape,Standard_True);
}
- return 1;
+ return 0;
}
//==============================================================================
} else if (anObj->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) {
Handle(NIS_InteractiveObject) aShape =
Handle(NIS_InteractiveObject)::DownCast(anObj);
- TheNISContext()->Display(aShape, 0L, Standard_False);
+ TheNISContext()->Display(aShape);
}
}
else { // Create the AIS_Shape from a name
}
// Upadate the screen and redraw the view
TheAISContext()->UpdateCurrentViewer();
- TheNISContext()->UpdateViews();
+// TheNISContext()->UpdateViews();
return 0;
}
Standard_Integer curindex = (TheType == AIS_KOI_None) ? 0 : TheAISContext()->OpenLocalContext();
// step 1: prepare the data
- if(curindex != 0){
+ if(curindex !=0){
Handle(AIS_SignatureFilter) F1 = new AIS_SignatureFilter(TheType,TheSignature);
TheAISContext()->AddFilter(F1);
}
// step 1: prepare the data
- if(curindex != 0){
+ if(curindex !=0){
Handle(AIS_SignatureFilter) F1 = new AIS_SignatureFilter(TheType,TheSignature);
TheAISContext()->AddFilter(F1);
}
IO = TheAISContext()->SelectedInteractive();
}
- if(curindex != 0)
+ if(curindex!=0)
TheAISContext()->CloseLocalContext(curindex);
return IO;
}
static int VEraseType( Draw_Interpretor& , Standard_Integer argc, const char** argv)
{
- if(argc != 2) return 1;
+ if(argc!=2) return 1;
AIS_KindOfInteractive TheType;
Standard_Integer TheSign(-1);