1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

Integration of OCCT 6.5.0 from SVN

This commit is contained in:
bugmaster
2011-03-16 07:30:28 +00:00
committed by bugmaster
parent 4903637061
commit 7fd59977df
16375 changed files with 3882564 additions and 0 deletions

43
src/DPrsStd/DPrsStd.cdl Executable file
View File

@@ -0,0 +1,43 @@
-- File: DPrsStd.cdl
-- Created: Thu Oct 2 09:30:03 1997
-- Author: Denis PASCAL
-- <dp@dingox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
package DPrsStd
---Purpose: commands for presentation based on AIS
-- ======================================
uses Draw
is
---Purpose: Presentation commands
-- =====================
AllCommands (I : in out Interpretor from Draw);
---Purpose: to load all sketch commands
AISPresentationCommands (I : in out Interpretor from Draw);
---Purpose: to display....etc... ais presentation
AISViewerCommands (I : in out Interpretor from Draw);
---Purpose: to repaint...etc... ais viewer
BasicCommands (I : in out Interpretor from Draw);
---Purpose: set/get position attribute
Factory (theDI : out Interpretor from Draw);
---Purpose: Loads all Draw commands of TKDCAF. Used for plugin.
end DPrsStd;

132
src/DPrsStd/DPrsStd.cxx Executable file
View File

@@ -0,0 +1,132 @@
// File: DPrsStd.cxx
// Created: Mon Jun 29 16:32:13 1998
// Author: Denis PASCAL
// <dp@dingox.paris1.matra-dtv.fr>
#include <DPrsStd.ixx>
#include <Draw_Interpretor.hxx>
#include <Draw.hxx>
#include <Draw_PluginMacro.hxx>
#include <DNaming.hxx>
#include <DDataStd.hxx>
#include <DDF.hxx>
#include <DDocStd.hxx>
//#include <AppStdL_Application.hxx>
#include <AppStd_Application.hxx>
#include <TCollection_AsciiString.hxx>
#include <OSD_Path.hxx>
#include <OSD_Environment.hxx>
#include <OSD_Directory.hxx>
#include <OSD_File.hxx>
// avoid warnings on 'extern "C"' functions returning C++ classes
#ifdef WNT
#pragma warning(4:4190)
#endif
//static Handle(AppStdL_Application) stdApp;
static Handle(AppStd_Application) stdApp;
//=======================================================================
//function : AllComands
//purpose :
//=======================================================================
void DPrsStd::AllCommands (Draw_Interpretor& theCommands)
{
static Standard_Boolean done = Standard_False;
if (done) return;
done = Standard_True;
// APPLICATION
if (stdApp.IsNull()) stdApp = new AppStd_Application ();//new AppStdL_Application ();
DPrsStd::AISPresentationCommands(theCommands);
DPrsStd::AISViewerCommands(theCommands);
//DPrsStd::BasicCommands(theCommands);
}
//==============================================================================
// Found standard CAF Plugin
//==============================================================================
static Standard_Boolean FoundCAFPlugin () {
// Define Environment Variable
char *plugin, *casroot, *standard;
plugin = getenv("CSF_PluginDefaults");
standard = getenv("CSF_StandardDefaults");
casroot = getenv("CASROOT");
Standard_Boolean hasPlugin = Standard_False;
TCollection_AsciiString PluginName ;
if ( !plugin ) {
if ( casroot ) {
PluginName = TCollection_AsciiString (casroot);
PluginName+="/src/StdResource" ;
hasPlugin = Standard_True ;
}
} else {
PluginName = TCollection_AsciiString (plugin);
hasPlugin = Standard_True ;
}
if ( hasPlugin ) {
OSD_Path aPath ( PluginName );
OSD_Directory aDir(aPath);
if ( aDir.Exists () ) {
TCollection_AsciiString PluginFileName = PluginName + "/Plugin" ;
OSD_File PluginFile ( PluginFileName );
if ( PluginFile.Exists() ) {
if (!plugin) {
OSD_Environment PluginEnv ( "CSF_PluginDefaults" , PluginName );
PluginEnv.Build();
if ( PluginEnv.Failed() ) {
cout << " Problem when initialise CSF_PluginDefaults whith " << PluginName.ToCString() << endl;
}
}
if (!standard) {
OSD_Environment StandardEnv ( "CSF_StandardDefaults" , PluginName );
StandardEnv .Build();
if ( StandardEnv.Failed() ) {
cout << " Problem when initialise CSF_StandardDefaults whith " << PluginName.ToCString() << endl;
}
}
} else {
hasPlugin = Standard_False;
}
} else {
hasPlugin = Standard_False;
}
}
if ( !hasPlugin ) {
cout << " an environement variable named : CSF_PluginDefaults is mandatory to use OCAF " <<endl;
Standard_Failure::Raise ( "an environement variable named : CSF_PluginDefaults is mandatory to use OCAF" );
}
return hasPlugin ;
}
//==============================================================================
// DPrsStd::Factory
//==============================================================================
void DPrsStd::Factory(Draw_Interpretor& theDI)
{
if(!FoundCAFPlugin())
return;
static Standard_Boolean DPrsStdFactoryDone = Standard_False;
if (DPrsStdFactoryDone) return;
DPrsStdFactoryDone = Standard_True;
DDF::AllCommands(theDI);
DNaming::AllCommands(theDI);
DDataStd::AllCommands(theDI);
DPrsStd::AllCommands(theDI);
DDocStd::AllCommands(theDI);
#ifdef DEB
cout << "Draw Plugin : All DF commands are loaded" << endl;
#endif
}
// Declare entry point PLUGINFACTORY
DPLUGIN(DPrsStd)

View File

@@ -0,0 +1,681 @@
// File: DPrsStd_AISPresentationCommands.cxx
// Created: Wed Oct 7 11:24:34 1998
// Author: Denis PASCAL
// <dp@dingox.paris1.matra-dtv.fr>
#include <DPrsStd.hxx>
#include <Draw.hxx>
#include <Draw_Appli.hxx>
#include <Draw_Interpretor.hxx>
#include <Draw_ColorKind.hxx>
#include <TCollection_AsciiString.hxx>
#include <TDocStd_Document.hxx>
#include <TDF_Label.hxx>
#include <TDF_Data.hxx>
#include <DDF.hxx>
#include <DDocStd.hxx>
#include <ViewerTest.hxx>
#include <V3d_View.hxx>
// for AIS
#include <TPrsStd_AISPresentation.hxx>
#include <TPrsStd_AISViewer.hxx>
#include <ViewerTest.hxx>
#include <AIS_InteractiveContext.hxx>
#include <AIS_InteractiveObject.hxx>
#include <AIS_Drawer.hxx>
#include <ViewerTest.hxx>
#include <ViewerTest_Tool.hxx>
#include <V3d_View.hxx>
#include <TCollection_ExtendedString.hxx>
#include <Quantity_NameOfColor.hxx>
#include <Graphic3d_NameOfMaterial.hxx>
#include <TDataXtd_Axis.hxx>
#include <TDataXtd_Constraint.hxx>
#include <TDataXtd_Geometry.hxx>
#include <TNaming_NamedShape.hxx>
#include <TDataXtd_Plane.hxx>
#include <TDataXtd_Point.hxx>
#include <Standard_PCharacter.hxx>
//#include <TSketchStd_Geometry.hxx>
//#include <TSketchStd_Edge.hxx>
//=======================================================================
//function : DPrsStd_AISDisplay
//purpose : DDisplay (DOC,entry, not_update)
//=======================================================================
static Standard_Integer DPrsStd_AISDisplay (Draw_Interpretor& di,
Standard_Integer nb,
const char** arg)
{
Handle(TDocStd_Document) D;
if (!DDocStd::GetDocument(arg[1],D)) return 1;
TDF_Label L;
if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
Handle(TPrsStd_AISPresentation) prs;
if(!L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) return 1;
if (nb == 3) {
prs->Display(Standard_True);
TPrsStd_AISViewer::Update(L);
return 0;
}
else {
prs->Display();
TPrsStd_AISViewer::Update(L);
return 0;
}
di << "DPrsStd_AISDisplay : Error" << "\n";
return 1;
}
//=======================================================================
//function : DPrsStd_AISRemove
//purpose : AISRemove (DOC,entry)
//=======================================================================
static Standard_Integer DPrsStd_AISRemove (Draw_Interpretor& di,
Standard_Integer nb,
const char** arg)
{
if (nb == 3) {
Handle(TDocStd_Document) D;
if (!DDocStd::GetDocument(arg[1],D)) return 1;
TDF_Label L;
if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
Handle(TPrsStd_AISPresentation) P;
if(!L.FindAttribute(TPrsStd_AISPresentation::GetID(), P)) return 1;
P->Erase(Standard_True);
TPrsStd_AISViewer::Update(L);
return 0;
}
di << "DPrsStd_AISRedisplay : Error" << "\n";
return 1;
}
//=======================================================================
//function : DPrsStd_AISErase
//purpose : AISErase (DOC,entry)
//=======================================================================
static Standard_Integer DPrsStd_AISErase (Draw_Interpretor& di,
Standard_Integer nb,
const char** arg)
{
if (nb == 3) {
Handle(TDocStd_Document) D;
if (!DDocStd::GetDocument(arg[1],D)) return 1;
TDF_Label L;
if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
Handle(TPrsStd_AISPresentation) prs;
if(!L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) return 1;
prs->Erase();
TPrsStd_AISViewer::Update(L);
return 0;
}
di << "DPrsStd_AISErase : Error" << "\n";
return 1;
}
//=======================================================================
//function : DPrsStd_AISUpdate
//purpose : AISUpdate (DOC,entry)
//=======================================================================
static Standard_Integer DPrsStd_AISUpdate (Draw_Interpretor& di,
Standard_Integer nb,
const char** arg)
{
if (nb == 3) {
Handle(TDocStd_Document) D;
if (!DDocStd::GetDocument(arg[1],D)) return 1;
TDF_Label L;
if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
Handle(TPrsStd_AISPresentation) prs;
if(!L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) return 1;
prs->Update();
TPrsStd_AISViewer::Update(L);
return 0;
}
di << "DPrsStd_AISUpdate : Error" << "\n";
return 1;
}
//=======================================================================
//function : DPrsStd_AISSet
//purpose : AISSet (DOC,entry, id)
//=======================================================================
static Standard_Integer DPrsStd_AISSet (Draw_Interpretor& di,
Standard_Integer nb,
const char** arg)
{
if (nb == 4) {
Handle(TDocStd_Document) D;
if (!DDocStd::GetDocument(arg[1],D)) return 1;
TDF_Label L;
if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
Standard_GUID guid;
TCollection_ExtendedString str = arg[3];
#ifdef DEB
cout << "Inputed parameter > " << str << endl;
#endif
if ( str == "A" ) //axis
guid = TDataXtd_Axis::GetID(); //"2a96b601-ec8b-11d0-bee7-080009dc3333"
else if( str == "C") //constraint
guid = TDataXtd_Constraint::GetID(); //"2a96b602-ec8b-11d0-bee7-080009dc3333"
else if( str == "NS" ) //namedshape
guid = TNaming_NamedShape::GetID(); //"c4ef4200-568f-11d1-8940-080009dc3333"
else if( str == "G" ) //geometry
guid = TDataXtd_Geometry::GetID(); //"2a96b604-ec8b-11d0-bee7-080009dc3333"
else if( str == "PL" ) //plane
guid = TDataXtd_Plane::GetID(); //"2a96b60c-ec8b-11d0-bee7-080009dc3333"
else if( str == "PT" ) //point
guid = TDataXtd_Point::GetID(); //"2a96b60d-ec8b-11d0-bee7-080009dc3333"
// else if( str == "SG" ) //TSketch_Geometry
// guid = TSketchStd_Geometry::GetID(); //"b3aac909-5b78-11d1-8940-080009dc3333"
// else if( str == "E" ) //TSketch_Edge
// guid = TSketchStd_Edge::GetID(); //"b3aac90a-5b78-11d1-8940-080009dc3333"
Handle(TPrsStd_AISPresentation) prs= TPrsStd_AISPresentation::Set(L, guid);
#ifdef DEB
cout << "Driver GUID = ";
prs->GetDriverGUID().ShallowDump(cout);
cout << "\n";
#endif
Standard_Character resS[37];
Standard_PCharacter presS;
presS=resS;
guid.ToCString(presS);
di<<resS;
return 0;
}
di << "DPrsStd_AISSet : Error" << "\n";
return 1;
}
//=======================================================================
//function : DPrsStd_AISDriver
//purpose : AISDriver (DOC,entry, [ID])
//=======================================================================
static Standard_Integer DPrsStd_AISDriver (Draw_Interpretor& di,
Standard_Integer nb,
const char** arg)
{
if (nb >= 3) {
Handle(TDocStd_Document) D;
if (!DDocStd::GetDocument(arg[1],D)) return 1;
TDF_Label L;
if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
Standard_GUID guid;
Handle(TPrsStd_AISPresentation) prs;
if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
if( nb == 3 ) {
guid = prs->GetDriverGUID();
Standard_Character str[37];
Standard_PCharacter pstr;
pstr=str;
guid.ToCString( pstr );
di << str ;
return 0;
}
else {
TCollection_ExtendedString str = arg[3];
#ifdef DEB
cout << "Inputed parameter > " << str << endl;
#endif
if ( str == "A" ) //axis
guid = TDataXtd_Axis::GetID(); //"2a96b601-ec8b-11d0-bee7-080009dc3333"
else if( str == "C") //constraint
guid = TDataXtd_Constraint::GetID(); //"2a96b602-ec8b-11d0-bee7-080009dc3333"
else if( str == "NS" ) //namedshape
guid = TNaming_NamedShape::GetID(); //"c4ef4200-568f-11d1-8940-080009dc3333"
else if( str == "G" ) //geometry
guid = TDataXtd_Geometry::GetID(); //"2a96b604-ec8b-11d0-bee7-080009dc3333"
else if( str == "PL" ) //plane
guid = TDataXtd_Plane::GetID(); //"2a96b60c-ec8b-11d0-bee7-080009dc3333"
else if( str == "PT" ) //point
guid = TDataXtd_Point::GetID(); //"2a96b60d-ec8b-11d0-bee7-080009dc3333"
// else if( str == "SG" ) //TSketch_Geometry
// guid = TSketchStd_Geometry::GetID(); //"b3aac909-5b78-11d1-8940-080009dc3333"
// else if( str == "E" ) //TSketch_Edge
// guid = TSketchStd_Edge::GetID(); //"b3aac90a-5b78-11d1-8940-080009dc3333"
prs->SetDriverGUID(guid);
Standard_Character resS[37];
Standard_PCharacter presS;
//modified by NIZNHY-PKV Tue Apr 22 16:15:02 2008f
presS=resS;
//modified by NIZNHY-PKV Tue Apr 22 16:15:05 2008t
guid.ToCString( presS );
di << resS ;
return 0;
}
}
}
di << "DPrsStd_AISDriver : Error" << "\n";
return 1;
}
//=======================================================================
//function : DPrsStd_AISUnset
//purpose : AISUnset (DOC,entry)
//=======================================================================
static Standard_Integer DPrsStd_AISUnset (Draw_Interpretor& di,
Standard_Integer nb,
const char** arg)
{
if (nb == 3) {
Handle(TDocStd_Document) D;
if (!DDocStd::GetDocument(arg[1],D)) return 1;
TDF_Label L;
if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
TPrsStd_AISPresentation::Unset(L);
TPrsStd_AISViewer::Update(L);
return 0;
}
di << "DPrsStd_AISDriver : Error" << "\n";
return 1;
}
//=======================================================================
//function : DPrsStd_AISTransparency
//purpose : AISTransparency (DOC,entry,[real])
//=======================================================================
static Standard_Integer DPrsStd_AISTransparency (Draw_Interpretor& di,
Standard_Integer nb,
const char** arg)
{
if (nb >= 3 ) {
Handle(TDocStd_Document) D;
if (!DDocStd::GetDocument(arg[1],D)) return 1;
TDF_Label L;
if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
Handle(TPrsStd_AISViewer) viewer;
if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
Handle(TPrsStd_AISPresentation) prs;
if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
if( nb == 4 ) {
prs->SetTransparency(atof(arg[3]));
TPrsStd_AISViewer::Update(L);
}
else {
if (prs->HasOwnTransparency()){
di << "Transparency = " << prs->Transparency() << "\n";
di<<prs->Transparency();
}
else{
di << "DPrsStd_AISTransparency: Warning : Transparency wasn't set" << "\n";
di<<(-1);
}
}
return 0;
}
}
di << "DPrsStd_AISTransparency : Error" << "\n";
return 1;
}
//=======================================================================
//function : DPrsStd_AISDefaultTransparency
//purpose : AISDefaultTransparency (DOC,entry)
//=======================================================================
static Standard_Integer DPrsStd_AISDefaultTransparency (Draw_Interpretor& di,
Standard_Integer nb,
const char** arg)
{
if (nb == 3) {
Handle(TDocStd_Document) D;
if (!DDocStd::GetDocument(arg[1],D)) return 1;
TDF_Label L;
if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
Handle(TPrsStd_AISPresentation) prs;
if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
prs->UnsetTransparency();
TPrsStd_AISViewer::Update(L);
return 0;
}
}
di << "DPrsStd_AISDefaultTransparency : Error" << "\n";
return 1;
}
//=======================================================================
//function : DPrsStd_AISColor
//purpose : AISColor (DOC,entry,[color])
//=======================================================================
static Standard_Integer DPrsStd_AISColor (Draw_Interpretor& di,
Standard_Integer nb,
const char** arg)
{
if (nb >= 3) {
Handle(TDocStd_Document) D;
if (!DDocStd::GetDocument(arg[1],D)) return 1;
TDF_Label L;
if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
Handle(TPrsStd_AISViewer) viewer;
if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
Handle(TPrsStd_AISPresentation) prs;
if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
if( nb == 4 ) {
prs->SetColor((Quantity_NameOfColor)atoi(arg[3]));
TPrsStd_AISViewer::Update(L);
}
else
if (prs->HasOwnColor()){
di << "Color = " << prs->Color() << "\n";
di<<prs->Color();
}
else{
di << "DPrsStd_AISColor: Warning : Color wasn't set" << "\n";
di<<(-1);
}
return 0;
}
}
di << "DPrsStd_AISColor : Error" << "\n";
return 1;
}
//=======================================================================
//function : DPrsStd_AISDefaultColor
//purpose : AISDefaultColor (DOC,entry)
//=======================================================================
static Standard_Integer DPrsStd_AISDefaultColor (Draw_Interpretor& di,
Standard_Integer nb,
const char** arg)
{
if (nb == 3) {
Handle(TDocStd_Document) D;
if (!DDocStd::GetDocument(arg[1],D)) return 1;
TDF_Label L;
if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
Handle(TPrsStd_AISViewer) viewer;
if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
Handle(TPrsStd_AISPresentation) prs;
if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
prs->UnsetColor();
TPrsStd_AISViewer::Update(L);
return 0;
}
}
di << "DPrsStd_AISDefaultColor : Error" << "\n";
return 1;
}
//=======================================================================
//function : DPrsStd_AISMaterial
//purpose : AISMaterial (DOC,entry,[material])
//=======================================================================
static Standard_Integer DPrsStd_AISMaterial (Draw_Interpretor& di,
Standard_Integer nb,
const char** arg)
{
if (nb >= 3) {
Handle(TDocStd_Document) D;
if (!DDocStd::GetDocument(arg[1],D)) return 1;
TDF_Label L;
if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
Handle(TPrsStd_AISViewer) viewer;
if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
Handle(TPrsStd_AISPresentation) prs;
if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
if( nb == 4 ) {
prs->SetMaterial((Graphic3d_NameOfMaterial)atoi(arg[3]));
TPrsStd_AISViewer::Update(L);
}
else {
if (prs->HasOwnMaterial()){
di << "Material = " << prs->Material() << "\n";
di<<prs->Material();
}
else{
di << "DPrsStd_AISMaterial: Warning : Material wasn't set" << "\n";
di<<(-1);
}
}
return 0;
}
}
di << "DPrsStd_AISMaterial : Error" << "\n";
return 1;
}
//=======================================================================
//function : DPrsStd_AISDefaultMaterial
//purpose : AISDefaultMaterial (DOC,entry)
//=======================================================================
static Standard_Integer DPrsStd_AISDefaultMaterial (Draw_Interpretor& di,
Standard_Integer nb,
const char** arg)
{
if (nb == 3) {
Handle(TDocStd_Document) D;
if (!DDocStd::GetDocument(arg[1],D)) return 1;
TDF_Label L;
if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
Handle(TPrsStd_AISViewer) viewer;
if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
Handle(TPrsStd_AISPresentation) prs;
if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
prs->UnsetMaterial();
TPrsStd_AISViewer::Update(L);
return 0;
}
}
di << "DPrsStd_AISDefaultMaterial : Error" << "\n";
return 1;
}
//=======================================================================
//function : DPrsStd_AISHasOwnColor
//purpose : AISHasOwnColor (DOC,entry)
//return : Boolean
//=======================================================================
static Standard_Integer DPrsStd_AISHasOwnColor (Draw_Interpretor& di,
Standard_Integer nb,
const char** arg)
{
if (nb >= 3) {
if (nb > 3)
di << "DPrsStd_AISHasOwnColor : Warning : too many arguments" << "\n";
Handle(TDocStd_Document) D;
if (!DDocStd::GetDocument(arg[1],D)) return 1;
TDF_Label L;
if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
Handle(TPrsStd_AISViewer) viewer;
if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
Handle(TPrsStd_AISPresentation) prs;
if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
di<<Standard_Integer(prs->HasOwnColor());
return 0;
}
}
di << "DPrsStd_AISHasOwnColor : Error" << "\n";
return 1;
}
//=======================================================================
//function : DPrsStd_AISHasOwnMaterial
//purpose : AISHasOwnMaterial (DOC,entry)
//return : Boolean
//=======================================================================
static Standard_Integer DPrsStd_AISHasOwnMaterial (Draw_Interpretor& di,
Standard_Integer nb,
const char** arg)
{
if (nb >= 3) {
if (nb > 3)
di << "DPrsStd_AISHasOwnMaterial : Warning : too many arguments" << "\n";
Handle(TDocStd_Document) D;
if (!DDocStd::GetDocument(arg[1],D)) return 1;
TDF_Label L;
if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
Handle(TPrsStd_AISViewer) viewer;
if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
Handle(TPrsStd_AISPresentation) prs;
if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
di<<Standard_Integer(prs->HasOwnMaterial());
return 0;
}
}
di << "DPrsStd_AISHasOwnMaterial : Error" << "\n";
return 1;
}
//=======================================================================
//function : DPrsStd_AISHasOwnTransparency
//purpose : AISHasOwnColor (DOC,entry)
//return : Boolean
//=======================================================================
static Standard_Integer DPrsStd_AISHasOwnTransparency (Draw_Interpretor& di,
Standard_Integer nb,
const char** arg)
{
if (nb >= 3) {
if (nb > 3)
di << "DPrsStd_AISHasOwnTransparency : Warning : too many arguments" << "\n";
Handle(TDocStd_Document) D;
if (!DDocStd::GetDocument(arg[1],D)) return 1;
TDF_Label L;
if (!DDF::FindLabel(D->GetData(),arg[2],L)) return 1;
Handle(TPrsStd_AISViewer) viewer;
if( !TPrsStd_AISViewer::Find(L, viewer) ) return 1;
Handle(TPrsStd_AISPresentation) prs;
if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
di<<Standard_Integer(prs->HasOwnTransparency());
return 0;
}
}
di << "DPrsStd_AISHasOwnTransparency : Error" << "\n";
return 1;
}
//=======================================================================
//function : AISPresentationCommands
//purpose :
//=======================================================================
void DPrsStd::AISPresentationCommands (Draw_Interpretor& theCommands)
{
static Standard_Boolean done = Standard_False;
if (done) return;
done = Standard_True;
const char* g = "DPrsStd : standard presentation commands" ;
// standard commands working on AISPresentation
theCommands.Add ("AISDisplay",
"AISDisplay (DOC, entry, [not_update])",
__FILE__, DPrsStd_AISDisplay, g);
theCommands.Add ("AISErase",
"AISErase (DOC, entry)",
__FILE__, DPrsStd_AISErase, g);
theCommands.Add ("AISUpdate",
"AISUpdate (DOC, entry)",
__FILE__, DPrsStd_AISUpdate, g);
theCommands.Add ("AISSet",
"AISSet (DOC, entry, ID)",
__FILE__, DPrsStd_AISSet, g);
theCommands.Add ("AISDriver",
"AISDriver (DOC, entry, [ID]) - returns DriverGUID stored in attribute or sets new one",
__FILE__, DPrsStd_AISDriver, g);
theCommands.Add ("AISUnset",
"AISUnset (DOC, entry)",
__FILE__, DPrsStd_AISUnset, g);
theCommands.Add ("AISTransparency",
"AISTransparency (DOC, entry, [real])",
__FILE__, DPrsStd_AISTransparency, g);
theCommands.Add ("AISDefaultTransparency",
"AISDefaultTransparency (DOC, entry)",
__FILE__, DPrsStd_AISDefaultTransparency, g);
theCommands.Add ("AISHasOwnTransparency",
"AISHasOwnTransparency (DOC, entry) | AISHasOwnTransparency return Boolean",
__FILE__, DPrsStd_AISHasOwnTransparency, g);
theCommands.Add ("AISDefaultColor",
"AISDefaultColor (DOC, entry)",
__FILE__, DPrsStd_AISDefaultColor, g);
theCommands.Add ("AISColor",
"AISColor (DOC, entry, [color])",
__FILE__, DPrsStd_AISColor, g);
theCommands.Add ("AISHasOwnColor",
"AISHasOwnColor (DOC, entry) | AISHasOwnColor return Boolean",
__FILE__, DPrsStd_AISHasOwnColor, g);
theCommands.Add ("AISMaterial",
"AISMaterial (DOC, entry, [material])",
__FILE__, DPrsStd_AISMaterial, g);
theCommands.Add ("AISDefaultMaterial",
"AISDefaultMaterial (DOC, entry)",
__FILE__, DPrsStd_AISDefaultMaterial, g);
theCommands.Add ("AISHasOwnMaterial",
"AISHasOwnMaterial (DOC, entry) | AISHasOwnMaterial return Boolean",
__FILE__, DPrsStd_AISHasOwnMaterial, g);
theCommands.Add ("AISRemove",
"AISRemove (DOC, entry)",
__FILE__, DPrsStd_AISRemove, g);
}

View File

@@ -0,0 +1,117 @@
// File: DPrsStd_AISViewerCommnds.cxx
// Created: Tue Oct 27 10:24:49 1998
// Author: Denis PASCAL
// <dp@dingox.paris1.matra-dtv.fr>
#include <DPrsStd.hxx>
#include <DPrsStd.hxx>
#include <Draw.hxx>
#include <Draw_Appli.hxx>
#include <Draw_Interpretor.hxx>
#include <Draw_ColorKind.hxx>
#include <TCollection_AsciiString.hxx>
#include <TDocStd_Document.hxx>
#include <TDF_Label.hxx>
#include <TDF_Data.hxx>
#include <TDF_Tool.hxx>
#include <TDF_ChildIterator.hxx>
#include <DDF.hxx>
#include <DDocStd.hxx>
#include <TDocStd_Document.hxx>
#include <ViewerTest.hxx>
#include <V3d_View.hxx>
// for AIS
#include <TPrsStd_AISPresentation.hxx>
#include <TPrsStd_AISViewer.hxx>
#include <ViewerTest.hxx>
#include <AIS_InteractiveContext.hxx>
#include <ViewerTest.hxx>
#include <ViewerTest_Tool.hxx>
#include <V3d_View.hxx>
extern int ViewerMainLoop (Standard_Integer, const char**);
//=======================================================================
//function : DPrsStd_AISInitViewer
//purpose : AISInitViewer (DOC)
//=======================================================================
extern void ViewerTest_InitViewerTest (const Handle(AIS_InteractiveContext)&);
static Standard_Integer DPrsStd_AISInitViewer (Draw_Interpretor& di,
Standard_Integer nb,
const char** arg)
{
if (nb == 2) {
Handle(TDocStd_Document) D;
if (!DDocStd::GetDocument(arg[1],D)) return 1;
TDF_Label acces = D->GetData()->Root();
Handle(TPrsStd_AISViewer) viewer;
if (!TPrsStd_AISViewer::Find (acces,viewer)) {
TCollection_AsciiString title;
title.Prepend(arg[1]);
title.Prepend("_");
title.Prepend("Document");
Handle(V3d_Viewer) vw = ViewerTest_Tool::MakeViewer (title.ToCString());
viewer = TPrsStd_AISViewer::New (acces,vw);
}
ViewerTest_Tool::InitViewerTest (viewer->GetInteractiveContext());
DDF::ReturnLabel(di,viewer->Label());
return 0;
}
di << "DPrsStd_AISInitViewer : Error" << "\n";
return 1;
}
//=======================================================================
//function : TPrsStd_AISRepaint
//purpose :
//=======================================================================
static Standard_Integer DPrsStd_AISRepaint (Draw_Interpretor& di,
Standard_Integer nb,
const char** arg)
{
if (nb == 2) {
Handle(TDocStd_Document) D;
if (!DDocStd::GetDocument(arg[1],D)) return 1;
TDF_Label acces = D->GetData()->Root();
TPrsStd_AISViewer::Update(acces);
return 0;
}
di << "DPrsStd_AISRepaint : Error" << "\n";
return 1;
}
//=======================================================================
//function : AISViewerCommands
//purpose :
//=======================================================================
void DPrsStd::AISViewerCommands (Draw_Interpretor& theCommands)
{
static Standard_Boolean done = Standard_False;
if (done) return;
done = Standard_True;
const char* g = "DPrsStd : standard presentation commands" ;
// standard commands working on AISViewer
theCommands.Add ("AISInitViewer",
"AISInitViewer (DOC)",
__FILE__, DPrsStd_AISInitViewer, g);
theCommands.Add ("AISRepaint",
"update the AIS viewer",
__FILE__, DPrsStd_AISRepaint, g);
}

210
src/DPrsStd/DPrsStd_Sample.cxx Executable file
View File

@@ -0,0 +1,210 @@
// File: DPrsStd_Sample.cxx
// Created: Mon Dec 27 16:10:35 1999
// Author: Sergey RUIN
// <srn@popox.nnov.matra-dtv.fr>
#include <TDF_Data.hxx>
#include <TDF_Label.hxx>
#include <TNaming_NamedShape.hxx>
#include <TPrsStd_AISPresentation.hxx>
#include <TPrsStd_AISViewer.hxx>
#include <AIS_InteractiveContext.hxx>
#include <AIS_InteractiveObject.hxx>
#include <V3d_Viewer.hxx>
#include <Quantity_NameOfColor.hxx>
#include <TPrsStd_DriverTable.hxx>
#include <TPrsStd_NamedShapeDriver.hxx>
#include <TPrsStd_PlaneDriver.hxx>
#include <TDataXtd_Plane.hxx>
#ifdef DEB
static void Sample()
{
// Starting with data framework
Handle(TDF_Data) DF = new TDF_Data();
TDF_Label aLabel = DF->Root();
//----------------------------------- TPrsStd_AISViewer ----------------------------------------
//==============================================================================================
// Setting the TPrsStd_AISViewer in the framework
Handle(V3d_Viewer) aViewer;
//... Initialization of aViewer
//Creating the new AIS_InteractiveContext
Handle(AIS_InteractiveContext) ctx = new AIS_InteractiveContext(aViewer);
//Creating the new TPrsStd_AISViewer attribute initialized with AIS_InteractiveContext
Handle(TPrsStd_AISViewer) aisviewer;
if( !TPrsStd_AISViewer::Has(aLabel) ) { //Check if there has already been set TPrsStd_AISViewer in the framework
aisviewer = TPrsStd_AISViewer::New(aLabel, ctx);
}
//Finding TPrsStd_AISViewer attribute in the DataFramework
if( TPrsStd_AISViewer::Find(aLabel, aisviewer) ) {
aisviewer->Update(); //Update the viewer associated with this attribute
}
//Getting AIS_InteractiveContext from TPrsStd_AISViewer may be done in two ways:
//1. If we have already gotten TPrsStd_AISViewer attribute (strored in a variable <aisviewer>)
Handle(AIS_InteractiveContext) context1 = aisviewer->GetInteractiveContext();
//2. Getting AIS_InteractiveContext directly
Handle(AIS_InteractiveContext) context2;
if( TPrsStd_AISViewer::Find(aLabel, context2) ) {
//do something...
}
//----------------------------------- TPrsStd_Driver and TPrsStd_DriverTable -------------------
//==============================================================================================
// All work for building AIS_InteractiveObject to be presented by TPrsStd_AISPresentation is done
// by drivers which are descendants of deferred class TPrsStd_Driver
// There is a map of drivers with Standard_GUID as a key.
// Adding driver to the map of drivers
Handle(TPrsStd_NamedShapeDriver) NSDriver = new TPrsStd_NamedShapeDriver();
Handle(TPrsStd_DriverTable) table = TPrsStd_DriverTable::Get();
Standard_GUID guid = TNaming_NamedShape::GetID();
table->AddDriver(guid, NSDriver);
// When the first time called TPrsStd_DriverTable loads standard drivers defined in TPrsStd package
// Getting driver from the map of drivers
Standard_GUID driverguid = TNaming_NamedShape::GetID();
Handle(TPrsStd_NamedShapeDriver) driver;
if( table->FindDriver(driverguid, driver) )
cout << "Driver was found " << endl;
else
cout << "Driver wasn't found" << endl;
// Driver can be used to build AIS_InteractiveObject for presenting the given label
Handle(TPrsStd_PlaneDriver) planedriver;
if( table->FindDriver(TDataXtd_Plane::GetID(), planedriver) ) {
TDF_Label planelabel;
// Finding planelabel ...
Handle(AIS_InteractiveObject) aisobject;
planedriver->Update(planelabel, aisobject);
if( !aisobject.IsNull() ) {
// Do something with aisobject ...
}
}
//----------------------------------- TPrsStd_AISPresentation ----------------------------------
//==============================================================================================
TDF_Label ShapeLabel;
// ... Setting TNaming_NamedShape to <ShapeLabel>
// Setting the new TPrsStd_AISPresentation to <ShapeLabel>
// It can be done in two different ways:
Handle(TPrsStd_AISPresentation) Presenation;
// 1. By giving to TPrsStd_AISPresentation attribute Standard_GUID of an attribute to be displayed:
// This GUID will be used to find driver for building AIS_InteractiveObject in the map of drivers
Presenation = TPrsStd_AISPresentation::Set( ShapeLabel, TNaming_NamedShape::GetID() );
// 2. Or by giving the attribute itself to TPrsStd_AISPresentation attribute:
// An ID of attribute will be used to find driver for building AIS_InteractiveObject in the map of drivers
Handle(TNaming_NamedShape) NS;
if( ShapeLabel.FindAttribute( TNaming_NamedShape::GetID(), NS) ) {
Presenation = TPrsStd_AISPresentation::Set( NS );
}
// Displaying (recomputation of presentation of attribute is done only if presentation is null)
Handle(TPrsStd_AISPresentation) PRS;
if( ShapeLabel.FindAttribute(TPrsStd_AISPresentation::GetID(), PRS) ) PRS->Display();
//After call of the method PRS->Display() the presentation of the attribute is marked as displayed in
//AIS_InteractiveContext but not in viewer, in order to draw the object in viewer last has to be updated
TPrsStd_AISViewer::Update(ShapeLabel); //Update presentation of the attribute in a viewer's window
// Erasing
if( ShapeLabel.FindAttribute(TPrsStd_AISPresentation::GetID(), PRS) ) PRS->Erase();
// The method Erase() marks presentation of attribute as erased in AIS_InteractiveContext;
// in order to make changes visible in a viewer's window viewer has to be updated
TPrsStd_AISViewer::Update(ShapeLabel); //Update viewer to erase presenation of the attribute in a viewer's window
//Presentation of the attribute is erased from viewer but
// stays in AIS_InteractiveContext
if( ShapeLabel.FindAttribute(TPrsStd_AISPresentation::GetID(), PRS) ) PRS->Erase(Standard_True);
TPrsStd_AISViewer::Update(ShapeLabel);
//Presentation of the attribute is erased
//from viewer and removed from AIS_InteractiveContext
//Checking if attribute is displayed in viewer
if( ShapeLabel.FindAttribute(TPrsStd_AISPresentation::GetID(), PRS) )
Standard_Boolean isDisplayed = PRS->IsDisplayed();
Handle(TPrsStd_AISPresentation) P;
if( ShapeLabel.FindAttribute(TPrsStd_AISPresentation::GetID(), P) ) {
// Updating and displaying presentation of the attribute to be displayed
P->Display(Standard_True);
TPrsStd_AISViewer::Update(ShapeLabel); //Update presenation of the attribute in a viewer's window
//Getting Standard_GUID of attribute with which TPrsStd_AISPresentation attribute is associeted
Standard_GUID guid = P->GetDriverGUID();
//Setting a color to the displayd attribute
P->SetColor(Quantity_NOC_RED);
TPrsStd_AISViewer::Update(ShapeLabel); //Update viewer to make changes visible to user
//Getting transparency the displayd attribute
Standard_Real transparency = P->Transparency();
//Getting AIS_InteractiveObject built and stored in the AIS_Presentation attribute
Handle(AIS_InteractiveObject) AISObject = P->GetAIS();
}
// ... Attribute is modified
//Updating presentation of the attribute in viewer
if( ShapeLabel.FindAttribute(TPrsStd_AISPresentation::GetID(), PRS) )
PRS->Update(); //Updates presentation of attribute in AIS_InteractiveContext
TPrsStd_AISViewer::Update(ShapeLabel); //Updates presentation in viewer
return;
}
#endif

3
src/DPrsStd/FILES Executable file
View File

@@ -0,0 +1,3 @@
DPrsStd_AISPresentationCommands.cxx
DPrsStd_AISViewerCommands.cxx
DPrsStd_Sample.cxx