From: mbs Date: Mon, 6 Mar 2023 19:12:23 +0000 (+0000) Subject: added debug messages only X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=682dcead3cf28c98a2d88570c9c66e88e6e42031;p=modules%2Fgeom.git added debug messages only --- diff --git a/src/GEOMGUI/GEOMGUI_OCCSelector.cxx b/src/GEOMGUI/GEOMGUI_OCCSelector.cxx index d967d6752..bad30b4ce 100644 --- a/src/GEOMGUI/GEOMGUI_OCCSelector.cxx +++ b/src/GEOMGUI/GEOMGUI_OCCSelector.cxx @@ -52,6 +52,13 @@ #include +//--------------------------------------------------------- +#define USE_DEBUG +//#define MB_IGNORE_QT +#define MBCLASSNAME "GEOMGUI_OCCSelector" +#include "MBDebug.h" +//--------------------------------------------------------- + //================================================================ // Function : GEOMGUI_OCCSelector // Purpose : @@ -59,6 +66,7 @@ GEOMGUI_OCCSelector::GEOMGUI_OCCSelector( OCCViewer_Viewer* viewer, SUIT_SelectionMgr* mgr ) : LightApp_OCCSelector( viewer, mgr ) { + DBG_FUN(); } //================================================================ @@ -67,6 +75,7 @@ GEOMGUI_OCCSelector::GEOMGUI_OCCSelector( OCCViewer_Viewer* viewer, SUIT_Selecti //================================================================ GEOMGUI_OCCSelector::~GEOMGUI_OCCSelector() { + DBG_FUN(); } //================================================================ @@ -75,6 +84,7 @@ GEOMGUI_OCCSelector::~GEOMGUI_OCCSelector() //================================================================ void GEOMGUI_OCCSelector::getSelection( SUIT_DataOwnerPtrList& aList ) const { + DBG_FUN(); OCCViewer_Viewer* vw = viewer(); if (!vw) return; @@ -177,6 +187,7 @@ static void getEntityOwners( const Handle(AIS_InteractiveObject)& theObj, //================================================================ void GEOMGUI_OCCSelector::setSelection( const SUIT_DataOwnerPtrList& aList ) { + DBG_FUN(); OCCViewer_Viewer* vw = viewer(); if ( !vw || !vw->isSelectionEnabled()) return; diff --git a/src/GEOMGUI/GEOMGUI_Selection.cxx b/src/GEOMGUI/GEOMGUI_Selection.cxx index 2b11f63fe..ad8a0c939 100644 --- a/src/GEOMGUI/GEOMGUI_Selection.cxx +++ b/src/GEOMGUI/GEOMGUI_Selection.cxx @@ -74,6 +74,13 @@ // VTK Includes #include +//--------------------------------------------------------- +#define USE_DEBUG +//#define MB_IGNORE_QT +#define MBCLASSNAME "GEOMGUI_Selection" +#include "MBDebug.h" +//--------------------------------------------------------- + #define OCC_DISPLAY_MODE_TO_STRING( str, dm ) { \ if ( dm == AIS_WireFrame ) \ str = QString( "Wireframe" ); \ @@ -113,14 +120,18 @@ GEOMGUI_Selection::GEOMGUI_Selection() : LightApp_Selection() { + DBG_FUN(); } GEOMGUI_Selection::~GEOMGUI_Selection() { + DBG_FUN(); } void GEOMGUI_Selection::init( const QString& context, LightApp_SelectionMgr* selMgr ) { + DBG_FUN(); + ARG(context); LightApp_Selection::init( context, selMgr ); myObjects.resize( count() ); @@ -144,6 +155,8 @@ void GEOMGUI_Selection::init( const QString& context, LightApp_SelectionMgr* sel //QVariant GEOMGUI_Selection::contextParameter( const QString& p ) const QVariant GEOMGUI_Selection::parameter( const QString& p ) const { + DBG_FUN(); + ARG(p); QVariant v; if ( p == "isOCC" ) v = activeViewType() == OCCViewer_Viewer::Type(); @@ -163,6 +176,9 @@ QVariant GEOMGUI_Selection::parameter( const QString& p ) const //QVariant GEOMGUI_Selection::objectParameter( const int idx, const QString& p ) const QVariant GEOMGUI_Selection::parameter( const int idx, const QString& p ) const { + DBG_FUN(); + ARG(idx); + ARG(p); QVariant v; if ( p == "type" ) v = typeName( idx ); @@ -217,6 +233,7 @@ QVariant GEOMGUI_Selection::parameter( const int idx, const QString& p ) const // the method to skip temporary objects from selection (called from LightApp) bool GEOMGUI_Selection::processOwner( const LightApp_DataOwner* theOwner ) { + DBG_FUN(); if ( theOwner->entry().contains( GEOMGUI_AnnotationMgr::GetEntrySeparator() ) ) { myAnnotationEntries.append( theOwner->entry() ); } diff --git a/src/GEOMGUI/GEOM_Displayer.cxx b/src/GEOMGUI/GEOM_Displayer.cxx index cc78136fe..f2cc7547d 100644 --- a/src/GEOMGUI/GEOM_Displayer.cxx +++ b/src/GEOMGUI/GEOM_Displayer.cxx @@ -130,6 +130,14 @@ #include #endif +//--------------------------------------------------------- +#define USE_DEBUG +//#define MB_IGNORE_QT +#define MBCLASSNAME "GEOM_Displayer" +#include "MBDebug.h" +#include "MBOCC.h" +//--------------------------------------------------------- + // If the next macro is defined, autocolor feature works for all sub-shapes; // if it is undefined, autocolor feature works for groups only #define GENERAL_AUTOCOLOR @@ -360,6 +368,8 @@ bool GEOM_Displayer::isCompoundOfVertices( const TopoDS_Shape& theShape ) //================================================================ SUIT_SelectionFilter* GEOM_Displayer::getFilter( const int theMode ) { + DBG_FUN(); + ARG(theMode); SUIT_SelectionFilter* aFilter; int aTopAbsMode = getTopAbsMode( theMode ); @@ -396,6 +406,7 @@ SUIT_SelectionFilter* GEOM_Displayer::getFilter( const int theMode ) //================================================================ SUIT_SelectionFilter* GEOM_Displayer::getComplexFilter( const QList* aSubShapes) { + DBG_FUN(); GEOM_CompoundFilter* aFilter = 0; if(aSubShapes != NULL ) { @@ -473,6 +484,7 @@ static std::string getName( GEOM::GEOM_BaseObject_ptr object ) GEOM_Displayer::GEOM_Displayer() : myUpdateColorScale(true), myIsRedisplayed( false ) { + DBG_FUN(); SUIT_Session* session = SUIT_Session::session(); myApp = dynamic_cast( session->activeApplication() ); @@ -530,6 +542,7 @@ GEOM_Displayer::GEOM_Displayer() //================================================================= GEOM_Displayer::~GEOM_Displayer() { + DBG_FUN(); } //================================================================= @@ -542,6 +555,7 @@ void GEOM_Displayer::Display( const Handle(SALOME_InteractiveObject)& theIO, const bool updateViewer, SALOME_View* theViewFrame ) { + DBG_FUN(); SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView(); if ( vf ) { @@ -570,6 +584,7 @@ void GEOM_Displayer::Display( const Handle(SALOME_InteractiveObject)& theIO, //================================================================= void GEOM_Displayer::Display( GEOM::GEOM_BaseObject_ptr theObj, const bool updateViewer ) { + DBG_FUN(); if ( theObj->_is_nil() ) return; @@ -591,6 +606,7 @@ void GEOM_Displayer::Erase( const Handle(SALOME_InteractiveObject)& theIO, const bool updateViewer, SALOME_View* theViewFrame ) { + DBG_FUN(); if ( theIO.IsNull() ) return; @@ -620,6 +636,7 @@ void GEOM_Displayer::Erase( GEOM::GEOM_BaseObject_ptr theObj, const bool updateViewer, SALOME_View* theViewFrame) { + DBG_FUN(); std::string entry = getEntry( theObj ); if ( entry != "" ) { @@ -639,6 +656,7 @@ void GEOM_Displayer::Redisplay( const Handle(SALOME_InteractiveObject)& theIO, const bool updateViewer, const bool checkActiveViewer ) { + DBG_FUN(); bool aRedisplayed = myIsRedisplayed; myIsRedisplayed = true; // Remove the object permanently ( == true) @@ -684,6 +702,7 @@ void GEOM_Displayer::Redisplay( const Handle(SALOME_InteractiveObject)& theIO, const bool theUpdateViewer, SALOME_View* theViewFrame ) { + DBG_FUN(); SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView(); if ( !vf ) { @@ -717,6 +736,7 @@ void GEOM_Displayer::Redisplay( const Handle(SALOME_InteractiveObject)& theIO, //================================================================= void GEOM_Displayer::Display( const SALOME_ListIO& theIOList, const bool updateViewer ) { + DBG_FUN(); SALOME_ListIteratorOfListIO Iter( theIOList ); for ( ; Iter.More(); Iter.Next() ) { Display( Iter.Value(), false ); @@ -727,6 +747,8 @@ void GEOM_Displayer::Display( const SALOME_ListIO& theIOList, const bool updateV void GEOM_Displayer::UpdateVisibility( SALOME_View* v, const SALOME_Prs* p, bool on ) { + DBG_FUN(); + ARG(on); SalomeApp_Study* aStudy = getStudy(); int vId = -1; if ( v ) vId = getViewManagerId( v ); @@ -762,6 +784,7 @@ QColor GEOM_Displayer::colorFromResources( const QString& property, const QColor void GEOM_Displayer::updateShapeProperties( const Handle(GEOM_AISShape)& AISShape, bool create ) { + DBG_FUN(); // check that shape is not null if ( AISShape.IsNull() ) return; @@ -1042,6 +1065,7 @@ void GEOM_Displayer::updateShapeProperties( const Handle(GEOM_AISShape)& AISShap void GEOM_Displayer::updateActorProperties( GEOM_Actor* actor, bool create ) { + DBG_FUN(); // check that actor is not null if ( !actor ) return; @@ -1222,6 +1246,7 @@ void GEOM_Displayer::updateDimensions( const Handle(SALOME_InteractiveObject)& t SALOME_OCCPrs* thePrs, const gp_Ax3& theShapeLCS ) { + DBG_FUN(); SalomeApp_Study* aStudy = getStudy(); if ( !aStudy ) { @@ -1401,6 +1426,7 @@ void GEOM_Displayer::Erase( const SALOME_ListIO& theIOList, const bool forced, const bool updateViewer ) { + DBG_FUN(); SALOME_ListIteratorOfListIO Iter( theIOList ); for ( ; Iter.More(); Iter.Next() ) Erase( Iter.Value(), forced, false ); @@ -1419,6 +1445,7 @@ void GEOM_Displayer::Redisplay( const SALOME_ListIO& theIOList, const bool updateViewer, const bool checkActiveViewer ) { + DBG_FUN(); SALOME_ListIteratorOfListIO Iter( theIOList ); for ( ; Iter.More(); Iter.Next() ) Redisplay( Iter.Value(), false, checkActiveViewer ); @@ -1437,6 +1464,7 @@ void GEOM_Displayer::Redisplay( const SALOME_ListIO& theIOList, const bool theUpdateViewer, SALOME_View* theViewFrame ) { + DBG_FUN(); SALOME_ListIteratorOfListIO anIter( theIOList ); for ( ; anIter.More(); anIter.Next() ) { @@ -1458,6 +1486,7 @@ void GEOM_Displayer::Redisplay( const SALOME_ListIO& theIOList, //================================================================= void GEOM_Displayer::Update( SALOME_OCCPrs* prs ) { + DBG_FUN(); SOCC_Prs* occPrs = dynamic_cast( prs ); SalomeApp_Study* study = getStudy(); @@ -1593,6 +1622,7 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs ) //================================================================= void GEOM_Displayer::Update( SALOME_VTKPrs* prs ) { + DBG_FUN(); SVTK_Prs* vtkPrs = dynamic_cast( prs ); SalomeApp_Study* study = getStudy(); @@ -1696,6 +1726,7 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs ) //================================================================= SALOME_Prs* GEOM_Displayer::BuildPrs( GEOM::GEOM_Object_ptr theObj ) { + DBG_FUN(); if ( theObj->_is_nil() ) return 0; @@ -1725,6 +1756,7 @@ SALOME_Prs* GEOM_Displayer::BuildPrs( GEOM::GEOM_Object_ptr theObj ) //================================================================= SALOME_Prs* GEOM_Displayer::BuildPrs( const TopoDS_Shape& theShape ) { + DBG_FUN(); myViewFrame = GetActiveView(); if ( theShape.IsNull() || myViewFrame == 0 ) return 0; @@ -1753,6 +1785,8 @@ SALOME_Prs* GEOM_Displayer::BuildPrs( const TopoDS_Shape& theShape ) SALOME_Prs* GEOM_Displayer::buildPresentation( const QString& entry, SALOME_View* theViewFrame ) { + DBG_FUN(); + ARG(entry); SALOME_Prs* prs = 0; internalReset(); @@ -1832,6 +1866,9 @@ SALOME_Prs* GEOM_Displayer::buildSubshapePresentation(const TopoDS_Shape& aShape const QString& entry, SALOME_View* theViewFrame) { + DBG_FUN(); + ARG(aShape); + ARG(entry); SALOME_Prs* prs = 0; internalReset(); @@ -1867,6 +1904,7 @@ SALOME_Prs* GEOM_Displayer::buildSubshapePresentation(const TopoDS_Shape& aShape //================================================================= void GEOM_Displayer::internalReset() { + DBG_FUN(); myIO.Nullify(); myShape.Nullify(); @@ -1887,6 +1925,7 @@ void GEOM_Displayer::internalReset() //================================================================= void GEOM_Displayer::LocalSelection( const Handle(SALOME_InteractiveObject)& theIO, const std::list modes ) { + DBG_FUN(); SUIT_Session* session = SUIT_Session::session(); SalomeApp_Application* app = dynamic_cast( session->activeApplication() ); if ( !app ) @@ -1916,6 +1955,7 @@ void GEOM_Displayer::LocalSelection( const Handle(SALOME_InteractiveObject)& the //================================================================= void GEOM_Displayer::LocalSelection( const Handle(SALOME_InteractiveObject)& theIO, const int theMode ) { + DBG_FUN(); std::list modes; modes.push_back( theMode ); LocalSelection( theIO, modes ); @@ -1930,6 +1970,9 @@ void GEOM_Displayer::LocalSelection( const Handle(SALOME_InteractiveObject)& the //================================================================= void GEOM_Displayer::GlobalSelection( const int theMode, const bool update ) { + DBG_FUN(); + ARG(theMode); + ARG(update); TColStd_MapOfInteger aModes; aModes.Add( theMode ); GlobalSelection( aModes, update ); @@ -1945,6 +1988,7 @@ void GEOM_Displayer::GlobalSelection( const int theMode, const bool update ) void GEOM_Displayer::GlobalSelection( const TColStd_MapOfInteger& theModes, const bool update, const QList* theSubShapes ) { + DBG_FUN(); SUIT_Session* session = SUIT_Session::session(); SalomeApp_Application* app = dynamic_cast( session->activeApplication() ); if ( !app ) @@ -2036,6 +2080,7 @@ void GEOM_Displayer::GlobalSelection( const TColStd_MapOfInteger& theModes, //================================================================= void GEOM_Displayer::LocalSelection( const SALOME_ListIO& theIOList, const std::list modes ) { + DBG_FUN(); SALOME_ListIteratorOfListIO Iter( theIOList ); for ( ; Iter.More(); Iter.Next() ) LocalSelection( Iter.Value(), modes ); @@ -2050,6 +2095,8 @@ void GEOM_Displayer::LocalSelection( const SALOME_ListIO& theIOList, const std:: //================================================================= void GEOM_Displayer::LocalSelection( const SALOME_ListIO& theIOList, const int theMode ) { + DBG_FUN(); + ARG(theMode); std::list modes; modes.push_back( theMode ); LocalSelection( theIOList, modes ); @@ -2064,6 +2111,7 @@ void GEOM_Displayer::LocalSelection( const SALOME_ListIO& theIOList, const int t //================================================================= void GEOM_Displayer::BeforeDisplay( SALOME_View* v, const SALOME_OCCPrs* ) { + DBG_FUN(); SOCC_Viewer* vf = dynamic_cast( v ); if ( vf ) { @@ -2078,6 +2126,7 @@ void GEOM_Displayer::BeforeDisplay( SALOME_View* v, const SALOME_OCCPrs* ) void GEOM_Displayer::AfterDisplay( SALOME_View* v, const SALOME_OCCPrs* p ) { + DBG_FUN(); UpdateColorScale(); // visualize annotations for displayed presentation @@ -2095,12 +2144,14 @@ void GEOM_Displayer::AfterDisplay( SALOME_View* v, const SALOME_OCCPrs* p ) void GEOM_Displayer::BeforeErase( SALOME_View* v, const SALOME_OCCPrs* p ) { + DBG_FUN(); LightApp_Displayer::BeforeErase( v, p ); releaseTextures( p ); } void GEOM_Displayer::AfterErase( SALOME_View* v, const SALOME_OCCPrs* p ) { + DBG_FUN(); LightApp_Displayer::AfterErase( v, p ); UpdateColorScale(); @@ -2123,6 +2174,8 @@ void GEOM_Displayer::AfterErase( SALOME_View* v, const SALOME_OCCPrs* p ) //================================================================= void GEOM_Displayer::SetColor( const int color ) { + DBG_FUN(); + ARG2(color,DWORD); if ( color == -1 ) UnsetColor(); else @@ -2159,6 +2212,7 @@ void GEOM_Displayer::UnsetColor() //================================================================= double GEOM_Displayer::SetTransparency( const double transparency ) { + DBG_FUN(); double prevTransparency = myTransparency; myTransparency = transparency; return prevTransparency; @@ -2325,6 +2379,7 @@ bool GEOM_Displayer::ToActivate() const //================================================================= void GEOM_Displayer::clearTemporary( LightApp_SelectionMgr* theSelMgr ) { + DBG_FUN(); SALOME_ListIO selected, toSelect; theSelMgr->selectedObjects( selected ); @@ -2339,11 +2394,14 @@ void GEOM_Displayer::clearTemporary( LightApp_SelectionMgr* theSelMgr ) void GEOM_Displayer::SetName( const char* theName ) { + DBG_FUN(); + ARG(theName); myName = theName; } void GEOM_Displayer::UnsetName() { + DBG_FUN(); myName = ""; } @@ -2359,6 +2417,8 @@ void GEOM_Displayer::setIO( const Handle(SALOME_InteractiveObject)& theIO ) void GEOM_Displayer::setShape( const TopoDS_Shape& theShape ) { + DBG_FUN(); + ARG(theShape); myShape = theShape; } @@ -2369,6 +2429,7 @@ void GEOM_Displayer::setFieldStepInfo( const GEOM::field_data_type theFieldDataT const double theFieldStepRangeMin, const double theFieldStepRangeMax ) { + DBG_FUN(); myFieldDataType = theFieldDataType; myFieldDimension = theFieldDimension; myFieldStepData = theFieldStepData; @@ -2379,17 +2440,25 @@ void GEOM_Displayer::setFieldStepInfo( const GEOM::field_data_type theFieldDataT bool GEOM_Displayer::canBeDisplayed( const QString& entry, const QString& viewer_type ) const { + MSGEL(".....GEOM_Displayer: [" << entry.toStdString() << "] can be displayed in \"" << viewer_type.toStdString() << "\"?"); _PTR(SObject) anObj = getStudy()->studyDS()->FindObjectID( (const char*)entry.toUtf8() ); //if ( ! GeometryGUI::IsInGeomComponent( anObj )) return false; - GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(anObj)); // enable displaying of GEOM objects - GEOM::GEOM_FieldStep_var aFieldStepObj = GEOM::GEOM_FieldStep::_narrow(GeometryGUI::ClientSObjectToObject(anObj)); // enable displaying of GEOM field steps - GEOM::GEOM_Gen_var aCompObj = GEOM::GEOM_Gen::_narrow(GeometryGUI::ClientSObjectToObject(anObj)); // enable displaying of whole GEOM component - return ( !CORBA::is_nil( aGeomObj ) || !CORBA::is_nil( aFieldStepObj ) || !CORBA::is_nil( aCompObj ) ) && + CORBA::Object_var anOrbObj = GeometryGUI::ClientSObjectToObject(anObj); + bool isCorbaObj = (!CORBA::is_nil(anOrbObj)); + GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(anOrbObj); // enable displaying of GEOM objects + GEOM::GEOM_FieldStep_var aFieldStepObj = GEOM::GEOM_FieldStep::_narrow(anOrbObj); // enable displaying of GEOM field steps + GEOM::GEOM_Gen_var aCompObj = GEOM::GEOM_Gen::_narrow(anOrbObj); // enable displaying of whole GEOM component + bool isGeomObj = (!CORBA::is_nil( aGeomObj ) || !CORBA::is_nil( aFieldStepObj ) || !CORBA::is_nil( aCompObj )); + bool ret = ( isGeomObj ) && (viewer_type == SOCC_Viewer::Type() || viewer_type == SVTK_Viewer::Type()); + MSGEL("..... --> isCorbaObj=" << YesNo(isCorbaObj) << ", isGeomObj=" << YesNo(isGeomObj) << ", canBeDisp=" << YesNo(ret)); + return ret; } int GEOM_Displayer::SetDisplayMode( const int theMode ) { + DBG_FUN(); + ARG(theMode); int aPrevMode = myDisplayMode; if ( theMode != -1 ) { myDisplayMode = theMode; @@ -2408,6 +2477,7 @@ int GEOM_Displayer::GetDisplayMode() const int GEOM_Displayer::UnsetDisplayMode() { + DBG_FUN(); int aPrevMode = myDisplayMode; SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); myDisplayMode = resMgr->integerValue( "Geometry", "display_mode", 0 ); @@ -2743,6 +2813,7 @@ SALOMEDS::Color GEOM_Displayer::getColor(GEOM::GEOM_Object_var theGeomObject, bo void GEOM_Displayer::EraseWithChildren(const Handle(SALOME_InteractiveObject)& theIO, const bool eraseOnlyChildren) { + DBG_FUN(); LightApp_DataObject* parent = getStudy()->findObjectByEntry(theIO->getEntry()); if( !parent) @@ -2976,6 +3047,7 @@ QList GEOM_Displayer::groupFieldData( const QList& theFieldS void GEOM_Displayer::UpdateColorScale() { + DBG_FUN(); if ( !myUpdateColorScale ) return; @@ -3055,6 +3127,7 @@ void GEOM_Displayer::UpdateColorScale() bool GEOM_Displayer::SetUpdateColorScale( bool toUpdate ) // IPAL54049 { + DBG_FUN(); bool previous = myUpdateColorScale; myUpdateColorScale = toUpdate; if ( myUpdateColorScale && !previous ) diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index e6724c4fb..fda1342bf 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -132,8 +132,16 @@ #include "GEOM_version.h" #include "GEOMImpl_Types.hxx" // dangerous hxx (defines short-name macros) - include after all +//--------------------------------------------------------- +#define USE_DEBUG +//#define MB_IGNORE_QT +#define MBCLASSNAME "GeometryGUI" +#include "MBDebug.h" +//--------------------------------------------------------- + extern "C" { Standard_EXPORT CAM_Module* createModule() { + DBG_FUNC(); return new GeometryGUI(); } @@ -146,6 +154,7 @@ GEOM::GEOM_Gen_var GeometryGUI::myComponentGeom = GEOM::GEOM_Gen::_nil(); GEOM::GEOM_Gen_var GeometryGUI::GetGeomGen() { + DBG_FUNC(); // Bug 12290: exception in Mesh GUI on GEOMBase::GetShape() if Geometry GUI hasn't been loaded if (CORBA::is_nil(myComponentGeom)) InitGeomGen(); @@ -154,6 +163,7 @@ GEOM::GEOM_Gen_var GeometryGUI::GetGeomGen() bool GeometryGUI::InitGeomGen() { + DBG_FUNC(); GeometryGUI aGG; if ( CORBA::is_nil( myComponentGeom ) ) return false; return true; @@ -219,6 +229,7 @@ void GeometryGUI::Modified (bool theIsUpdateActions) //======================================================================= GeometryGUI::GeometryGUI() : SalomeApp_Module( "GEOM" ) { + DBG_FUN(); if ( CORBA::is_nil( myComponentGeom ) ) { SALOME_NamingService_Abstract *ns = SalomeApp_Application::namingService(); @@ -250,6 +261,7 @@ GeometryGUI::GeometryGUI() : SalomeApp_Module( "GEOM" ) //======================================================================= GeometryGUI::~GeometryGUI() { + DBG_FUN(); while (!myOCCSelectors.isEmpty()) delete myOCCSelectors.takeFirst(); @@ -266,6 +278,8 @@ GeometryGUI::~GeometryGUI() typedef GEOMGUI* (*LibraryGUI)( GeometryGUI* ); GEOMGUI* GeometryGUI::getLibrary( const QString& libraryName ) { + DBG_FUN(); + ARG(libraryName); if ( !myGUIMap.contains( libraryName ) ) { // try to load library if it is not loaded yet #if defined(WIN32) @@ -316,6 +330,8 @@ GEOMGUI* GeometryGUI::getLibrary( const QString& libraryName ) typedef GEOMPluginGUI* (*PluginLibraryGUI)( GeometryGUI* ); GEOMPluginGUI* GeometryGUI::getPluginLibrary( const QString& libraryName ) { + DBG_FUN(); + ARG(libraryName); if ( !myGUIMap.contains( libraryName ) ) { // try to load library if it is not loaded yet @@ -366,6 +382,7 @@ GEOMPluginGUI* GeometryGUI::getPluginLibrary( const QString& libraryName ) //======================================================================= void GeometryGUI::ActiveWorkingPlane() { + DBG_FUN(); gp_Dir DZ = myWorkingPlane.Direction(); gp_Dir DY = myWorkingPlane.YDirection(); @@ -423,6 +440,7 @@ GEOMGUI_TextTreeWdg* GeometryGUI::GetTextTreeWdg() const //======================================================================= void GeometryGUI::SetActiveDialogBox( QDialog* aDlg ) { + DBG_FUN(); myActiveDialogBox = (QDialog*)aDlg; } @@ -460,6 +478,7 @@ void GeometryGUI::EmitSignalDefaultStepValueChanged(double newVal) //======================================================================= void GeometryGUI::OnGUIEvent() { + DBG_FUN(); const QObject* obj = sender(); if ( !obj || !obj->inherits( "QAction" ) ) return; @@ -474,6 +493,8 @@ void GeometryGUI::OnGUIEvent() //======================================================================= void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam ) { + DBG_FUN(); + ARG(id); SUIT_Application* anApp = application(); if (!anApp) return; SUIT_Desktop* desk = anApp->desktop(); @@ -487,6 +508,7 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam ) #else bool ViewDep = 0; #endif + MSGEL("....Flags: " << X_(ViewOCC) << " " << X_(ViewVTK) << " " << X_(ViewDep)); // if current viewframe is not of OCC and not of VTK type - return immediately // fix for IPAL8958 - allow some commands to execute even when NO viewer is active (rename for example) QList NotViewerDependentCommands; @@ -808,6 +830,7 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam ) //================================================================================= bool GeometryGUI::activateOperation( int actionId ) { + DBG_FUN(); OnGUIEvent(actionId); return true; } @@ -818,6 +841,8 @@ bool GeometryGUI::activateOperation( int actionId ) //================================================================================= bool GeometryGUI::activateOperation( const QString& actionId ) { + DBG_FUN(); + ARG(actionId); bool isOk = false; int id = actionId.toInt(&isOk); @@ -833,6 +858,9 @@ bool GeometryGUI::activateOperation( const QString& actionId ) //================================================================================= bool GeometryGUI::activateOperation( const QString& actionId, const QString& plugin ) { + DBG_FUN(); + ARG(actionId); + ARG(plugin); bool isOk = false; QString pluginLib = plugin; @@ -908,6 +936,9 @@ void GeometryGUI::OnMousePress( SUIT_ViewWindow* w, QMouseEvent* e ) void GeometryGUI::createGeomAction( const int id, const QString& label, const QString& icolabel, const int accel, const bool toggle, const QString& shortcutAction ) { + DBG_FUN(); + ARG(id); + ARG(label); SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); QPixmap icon = icolabel.isEmpty() ? resMgr->loadPixmap( "GEOM", tr( (QString( "ICO_" )+label).toLatin1().constData() ), false ) : resMgr->loadPixmap( "GEOM", tr( icolabel.toLatin1().constData() ) ); @@ -929,6 +960,7 @@ void GeometryGUI::createGeomAction( const int id, const QString& label, const QS //======================================================================= void GeometryGUI::createOriginAndBaseVectors() { + DBG_FUN(); SalomeApp_Study* appStudy = dynamic_cast( application()->activeStudy() ); bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked(); if ( aLocked ) { @@ -968,6 +1000,7 @@ void GeometryGUI::createOriginAndBaseVectors() //======================================================================= void GeometryGUI::initialize( CAM_Application* app ) { + DBG_FUN(); SalomeApp_Module::initialize( app ); // ----- create actions -------------- @@ -1771,6 +1804,7 @@ void GeometryGUI::initialize( CAM_Application* app ) //======================================================================= void GeometryGUI::addPluginActions() { + DBG_FUN(); // Resource manager SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); if (!resMgr) return; @@ -1861,6 +1895,7 @@ namespace //======================================================================= bool GeometryGUI::activateModule( SUIT_Study* study ) { + DBG_FUN(); // Fill in: Help Panel SalomeApp_Application* app = dynamic_cast( application() ); app->infoPanel()->setTitle(tr("INFO_WELCOME_TO_GEOM")); @@ -2007,6 +2042,7 @@ bool GeometryGUI::activateModule( SUIT_Study* study ) //======================================================================= bool GeometryGUI::deactivateModule( SUIT_Study* study ) { + DBG_FUN(); QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId ); if ( viewMenu ) disconnect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) ); @@ -2057,6 +2093,7 @@ bool GeometryGUI::deactivateModule( SUIT_Study* study ) //======================================================================= void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win ) { + DBG_FUN(); if ( !win ) return; @@ -2101,6 +2138,8 @@ void GeometryGUI::viewManagers( QStringList& lst ) const void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm ) { + DBG_FUN(); + if (vm) { SHOW(vm->getType()); } if ( vm && vm->getType() == OCCViewer_Viewer::Type() ) { qDebug( "connect" ); @@ -2139,6 +2178,8 @@ void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm ) void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm ) { + DBG_FUN(); + if (vm) { SHOW(vm->getType()); } SUIT_ViewModel* viewer = vm->getViewModel(); if ( vm->getType() == OCCViewer_Viewer::Type() ) { @@ -2176,6 +2217,7 @@ void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm ) void GeometryGUI::updateCreationInfo() { + DBG_FUN(); if ( myCreationInfoWdg ) myCreationInfoWdg->clear(); @@ -2225,6 +2267,7 @@ void GeometryGUI::updateCreationInfo() void GeometryGUI::onAutoBringToFront() { + DBG_FUN(); bool isAutoBringToFront = SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "auto_bring_to_front", "false" ); if( !isAutoBringToFront ) return; @@ -2314,11 +2357,14 @@ Handle(TColStd_HArray1OfByte) GeometryGUI::getTexture (int theId, int& theWidth, LightApp_Selection* GeometryGUI::createSelection() const { + DBG_FUN(); return new GEOMGUI_Selection(); } void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title ) { + DBG_FUN(); + ARG(client); SalomeApp_Module::contextMenuPopup( client, menu, title ); SALOME_ListIO lst; getApp()->selectionMgr()->selectedObjects( lst ); @@ -2378,12 +2424,15 @@ void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& void GeometryGUI::OnSetMaterial(const QString& theName) { + DBG_FUN(); + ARG(theName); OnGUIEvent( GEOMOp::OpPredefMaterial, QVariant( theName ) ); } void GeometryGUI::createPreferences() { + DBG_FUN(); SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) ); @@ -2942,6 +2991,7 @@ void GeometryGUI::preferencesChanged( const QString& section, const QString& par LightApp_Displayer* GeometryGUI::displayer() { + DBG_FUN(); if ( !myDisplayer ) myDisplayer = new GEOM_Displayer(); return myDisplayer; @@ -2949,6 +2999,8 @@ LightApp_Displayer* GeometryGUI::displayer() void GeometryGUI::setLocalSelectionMode(const int mode) { + DBG_FUN(); + ARG(mode); myLocalSelectionMode = mode; } @@ -2968,6 +3020,7 @@ const char gDigitsSep = ':'; // character used to separate numeric parameter val */ void GeometryGUI::storeVisualParameters (int savePoint) { + DBG_FUN(); SalomeApp_Study* appStudy = dynamic_cast(application()->activeStudy()); if ( !appStudy || !appStudy->studyDS() ) return; @@ -3167,6 +3220,7 @@ void GeometryGUI::storeVisualParameters (int savePoint) */ void GeometryGUI::restoreVisualParameters (int savePoint) { + DBG_FUN(); SalomeApp_Study* appStudy = dynamic_cast(application()->activeStudy()); if (!appStudy || !appStudy->studyDS()) return; @@ -3357,6 +3411,7 @@ void GeometryGUI::restoreVisualParameters (int savePoint) // Compute current name mode of the viewer void UpdateNameMode( SalomeApp_Application* app ) { + DBG_FUNC(); bool isMode = false; SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() ); SUIT_ViewWindow* viewWindow = app->desktop()->activeWindow(); @@ -3381,6 +3436,7 @@ void UpdateNameMode( SalomeApp_Application* app ) void GeometryGUI::onViewAboutToShow() { + DBG_FUN(); SUIT_ViewWindow* window = application()->desktop()->activeWindow(); QAction* a = action( GEOMOp::OpSwitchVectors ); QAction* aVerticesAction = action( GEOMOp::OpSwitchVertices ); @@ -3425,6 +3481,8 @@ QAction* GeometryGUI::getAction(const int id) { */ void GeometryGUI::message(const QString& msg) { + DBG_FUNC(); + ARG(msg); // dispatch message QStringList data = msg.split("/"); const int nbStrings = data.count(); @@ -3456,6 +3514,7 @@ void GeometryGUI::message(const QString& msg) */ void GeometryGUI::ClearShapeBuffer( GEOM::GEOM_Object_ptr theObj ) { + DBG_FUNC(); if ( CORBA::is_nil( theObj ) ) return; @@ -3555,6 +3614,9 @@ bool GeometryGUI::renameAllowed( const QString& entry) const { */ bool GeometryGUI::renameObject( const QString& entry, const QString& name) { + DBG_FUN(); + ARG(entry); + ARG(name); bool result = false; SalomeApp_Application* app = @@ -3596,6 +3658,7 @@ bool GeometryGUI::renameObject( const QString& entry, const QString& name) void GeometryGUI::updateMaterials() { + DBG_FUN(); LightApp_Preferences* pref = preferences(); if ( pref ) { QStringList materials = Material_ResourceMgr::resourceMgr()->materials(); @@ -3705,6 +3768,7 @@ bool GeometryGUI::isDropAccepted( const SUIT_DataObject* where ) const void GeometryGUI::dropObjects( const DataObjectList& what, SUIT_DataObject* where, const int row, Qt::DropAction action ) { + DBG_FUN(); if (action != Qt::CopyAction && action != Qt::MoveAction) return; // unsupported action diff --git a/src/GEOMGUI/MBDebug.h b/src/GEOMGUI/MBDebug.h new file mode 100644 index 000000000..5a8ab7208 --- /dev/null +++ b/src/GEOMGUI/MBDebug.h @@ -0,0 +1,245 @@ +#ifndef MBDebug_HeaderFile +#define MBDebug_HeaderFile + +//--------------------------------------------------------------- +// Usage of the logging facilities: +// +// (1) At the beginning of each class file to be debugged, there +// should be a static string variable defined with the name +// of the class. Then, include the "MBDebug.h" header file. +// +// //--------------------------------------------------------- +// #define USE_DEBUG +// //#define MB_IGNORE_QT +// #define MBCLASSNAME "ClassName" +// #include "MBDebug.h" +// //--------------------------------------------------------- +// +// (2) At the beginning of each class method, call the DBG_FUN +// macro. +// +// int ClassName::MyMethod(int x) +// { +// DBG_FUN(); +// ... +// } +// +// NOTE: For static methods, call the DBG_FUNC() macro!! +//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// This debugging/logging class is a "header-only" solution and +// does NOT require any additional implementation (.cpp) file! +//--------------------------------------------------------------- + +#include +#include +#include +#include +#include +#include +#include +#include +#ifndef MB_IGNORE_QT +# include +#endif + +//--------------------------------------------------------------- +// Set the debug flags dependent on the preprocessor definitions +//--------------------------------------------------------------- +#ifdef USE_DEBUG +# define MBS_DEBUG_FLAG MBDebug::DF_DEBUG +#else +# define MBS_DEBUG_FLAG 0 +#endif /*DEBUG*/ + +#define MBS_DBG_FLAGS (MBS_DEBUG_FLAG) + + +//--------------------------------------------------------------- +// Define the global debug macros +//--------------------------------------------------------------- +#define DLOG MBDebug::LogPrint() +#define RETURN(var) { RET(var); return (var); } + +#ifdef USE_DEBUG + +# define DBG_FUN() MBDebug _dbg(MBCLASSNAME, __FUNCTION__, MBS_DBG_FLAGS, (void*)this) +# define DBG_FUNC() MBDebug _dbg(MBCLASSNAME, __FUNCTION__, MBS_DBG_FLAGS) +# define DBG_FUNB(blk) MBDebug _dbg(MBCLASSNAME, blk, MBS_DBG_FLAGS) +# define MSGEL(txt) MBDebug::LogPrint() << txt << std::endl +# define PRINT(txt) MBDebug::LogPrint() << txt +# define SHOW2(var,typ) DumpVar(#var,(typ)(var)) +# define SHOW(var) DumpVar(#var,var) +# define ARG(var) do { PRINT("in:"); DumpVar(#var,var); } while (0) +# define ARG2(var,typ) do { PRINT("in:"); DumpVar(#var,(typ)(var)); } while (0) +# define RET(var) do { PRINT("out:"); DumpVar(#var,var); } while (0) +# define MSG(txt) MBDebug::LogPrint() << txt + +#else /*!USE_DEBUG*/ + +# define DBG_FUN() +# define DBG_FUNC() +# define DBG_FUNB(blk) +# define MSGEL(txt) +# define PRINT(txt) +# define SHOW2(var,typ) +# define SHOW(var) +# define ARG(var) +# define ARG2(var,typ) +# define RET(var) +# define MSG(txt) + +#endif /*USE_DEBUG*/ + + +//--------------------------------------------------------------- +// Declare the debugging and profiling class +//--------------------------------------------------------------- +class MBDebug +{ +public: + enum { + DF_NONE = 0x00, // no debug + DF_DEBUG = 0x01 // debug a function + }; + + MBDebug(const char* aClassName, const char* aFuncName, const short aFlag, void* aThis=NULL) + :mClassName(aClassName),mFuncName(aFuncName),mThis(aThis),mFlags((unsigned char)aFlag) + { + if (mFlags & (DF_DEBUG)) + { + std::cout << "{ENTER: " << mClassName + "::" + mFuncName; + if (mThis) std::cout << "(this=" << mThis << ")"; + std::cout << std::endl; + } + } + virtual ~MBDebug() + { + if (mFlags & (DF_DEBUG)) + std::cout << "}LEAVE: " << mClassName << "::" << mFuncName << std::endl; + } + + // Log file output management + static std::ostream& LogPrint() { return std::cout; } + +private: + std::string mClassName; // Name of class to be debugged + std::string mFuncName; // Name of function to be debugged + void* mThis; // The "this" pointer to the class being debugged + unsigned char mFlags; // Debug mode flags +}; + + + +#define YesNo(b) (b ? "Yes" : "No") +#define X_(b) (b ? "[x] " #b : "[ ] " #b) + + + +inline std::string w2s(std::wstring ws) +{ + using convert_typeX = std::codecvt_utf8; + std::wstring_convert converterX; + return(converterX.to_bytes(ws)); +} + +// Primitive types +inline void DumpVar(const char *szName, char value) +{ + DLOG << "[chr]: " << szName << "='" << value << "'" << std::endl; +} + +inline void DumpVar(const char *szName, bool value) +{ + DLOG << "[bool]: " << szName << "=" << (value ? "true" : "false") << std::endl; +} + +inline void DumpVar(const char *szName, short value) +{ + DLOG << "[shrt]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, int value) +{ + DLOG << "[int]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, long value) +{ + DLOG << "[long]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, double value) +{ + DLOG << "[dbl]: " << szName << "=" << value << std::endl; +} + +inline void DumpVar(const char *szName, unsigned char value) +{ + DLOG << "[byte]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, unsigned short value) +{ + DLOG << "[word]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, unsigned int value) +{ + DLOG << "[uint]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, unsigned long value) +{ + DLOG << "[dword]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; +} + +inline void DumpVar(const char *szName, const char* value) +{ + DLOG << "[str]: " << szName << "=\"" << (value ? value : "") << "\"" << std::endl; +} + +inline void DumpVar(const char *szName, const std::string &value) +{ + DLOG << "[Str]: " << szName << "=\"" << value << "\"" << std::endl; +} + +inline void DumpVar(const char *szName, const std::wstring &value) +{ + DLOG << "[WStr]: " << szName << "=\"" << w2s(value) << "\"" << std::endl; +} + +#ifndef MB_IGNORE_QT +inline void DumpVar(const char *szName, const QString &value) +{ + DLOG << "[QStr]: " << szName << "=\"" << value.toStdString() << "\"" << std::endl; +} +#endif + +inline void DumpVar(const char *szName, const void* value) +{ + DLOG << "[ptr]: " << szName << "=" << value << std::endl; +} + + +// Collection of primitive types +inline void DumpVar(const char *szName, const std::set &values) +{ + DLOG << "[intSet]: " << szName << "={" << values.size() << "}["; + bool bFirst = true; + for (auto it=values.cbegin(); it!=values.cend(); ++it) + DLOG << (bFirst ? "" : ",") << *it; + DLOG << "]" << std::endl; +} + +inline void DumpVar(const char *szName, const std::list& values) +{ + DLOG << "[boolList]: " << szName << "={" << values.size() << "}["; + bool bFirst = true; + for (auto it=values.cbegin(); it!=values.cend(); ++it) + DLOG << (bFirst ? "" : ",") << (*it ? "Y" : "N"); + DLOG << "]" << std::endl; +} + + +#endif // MBDebug_HeaderFile + diff --git a/src/GEOMGUI/MBOCC.h b/src/GEOMGUI/MBOCC.h new file mode 100644 index 000000000..4561248b6 --- /dev/null +++ b/src/GEOMGUI/MBOCC.h @@ -0,0 +1,436 @@ +#ifndef MBOCC_H +#define MBOCC_H + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +//-------------------------------------------------------------------------- +// Function declarations +//-------------------------------------------------------------------------- +static std::string ShapeTypeStr(const TopoDS_Shape shp); +static std::string EvolutionStr(const TNaming_Evolution evol); + +static void DumpEvolution(Handle(TNaming_NamedShape) aNS); +static void DumpShapeHistory(const TDF_Label& theLabel, const TopoDS_Shape& theShape); + +static void DumpVar(const char *szName, Handle(TNaming_NamedShape) aNS); +static void DumpVar(const char *szName, Handle(TDF_Attribute) aAttr); +static void DumpVar(const char *szName, const TDF_Label &lbl); +static void DumpVar(const char *szName, const TopoDS_Shape &aShape); + + + + + +//========================================================================== +static std::string ShapeTypeStr(const TopoDS_Shape shp) { + if (shp.IsNull()) + return "null"; + + switch (shp.ShapeType()) { + case TopAbs_COMPOUND: return "COMPOUND"; + case TopAbs_COMPSOLID: return "COMPSOLID"; + case TopAbs_SOLID: return "SOLID"; + case TopAbs_SHELL: return "SHELL"; + case TopAbs_FACE: return "FACE"; + case TopAbs_WIRE: return "WIRE"; + case TopAbs_EDGE: return "EDGE"; + case TopAbs_VERTEX: return "VERTEX"; + case TopAbs_SHAPE: return "SHAPE"; + } + return "??"; +} + +//========================================================================== +static std::string EvolutionStr(const TNaming_Evolution evol) { + switch (evol) { + case TNaming_PRIMITIVE: return "PRIMITIVE"; + case TNaming_GENERATED: return "GENERATED"; + case TNaming_MODIFY: return "MODIFY"; + case TNaming_DELETE: return "DELETE"; + case TNaming_REPLACE: return "REPLACE"; + case TNaming_SELECTED: return "SELECTED"; + } + return "??"; +} + +//========================================================================== +static void SaveShape(const TopoDS_Shape &shp, const char* szFileName) { + std::string fn("/home/bernhard/brep/"); + std::chrono::high_resolution_clock::time_point now_t = std::chrono::high_resolution_clock::now(); + unsigned long long now_c = *((unsigned long long*)&now_t); + fn = fn + std::to_string(now_c) + "_" + szFileName + ".brep"; + MSGEL("...saving shape \"" << szFileName << "\"to [" << fn << "]"); + BRepTools::Write(shp, fn.c_str()); +} + +//========================================================================== +static void DumpChildren(const TDF_Label& aLabel) { + TDF_ChildIterator it; + //TCollection_AsciiString as; + for (it.Initialize(aLabel); it.More(); it.Next()) { + SHOW(it.Value()); + DumpChildren(it.Value()); + // TDF_Tool::Entry(it.Value(),as); + // MSGEL("* [Label]: child=" << as.ToCString()); + } + } + +//========================================================================== +static void DumpShapeHistory(const TDF_Label& theLabel, const TopoDS_Shape& theShape) +{ + SHOW(theLabel); + SHOW(theShape); + DLOG << "{-------ShapeHistory-------------------------" << std::endl; + TopoDS_Shape anOldShape; // old shape in the pair old shape->theShape in the named shape + TopoDS_Shape aShapeContainer; // old shape of the shape that contains theShape as sub-element + Handle(TNaming_NamedShape) aCandidatInThis, aCandidatContainer; + // use child and this label (the lowest priority) + TDF_ChildIDIterator aNSIter(theLabel, TNaming_NamedShape::GetID(), Standard_True); + bool aUseThis = !aNSIter.More(); + while(anOldShape.IsNull() && (aNSIter.More() || aUseThis)) { + Handle(TNaming_NamedShape) aNS; + if (aUseThis) { + if (!theLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) + break; + } else { + aNS = Handle(TNaming_NamedShape)::DownCast(aNSIter.Value()); + } + for(TNaming_Iterator aShapesIter(aNS); aShapesIter.More(); aShapesIter.Next()) { + if (aShapesIter.Evolution() == TNaming_SELECTED || aShapesIter.Evolution() == TNaming_DELETE) + continue; // don't use the selection evolution + + if (aShapesIter.NewShape().IsSame(theShape)) { // found the original shape + aCandidatInThis = aNS; + if (aCandidatInThis->Evolution() == TNaming_MODIFY) { + anOldShape = aShapesIter.OldShape(); + MSG("* modified from: "); SHOW(anOldShape); + } + // otherwise may we searching for another item of this shape with longer history + if (!anOldShape.IsNull()) + break; + } + // check that the shape contains theShape as sub-shape to fill container + if (aShapesIter.NewShape().ShapeType() < theShape.ShapeType() && aCandidatContainer.IsNull()) { + TopExp_Explorer anExp(aShapesIter.NewShape(), theShape.ShapeType()); + for(; anExp.More(); anExp.Next()) { + if (theShape.IsSame(anExp.Current())) { + aCandidatContainer = aNS; + aShapeContainer = aShapesIter.NewShape(); + } + } + } + } + // iterate to the next label or to the body label in the end + if (!aUseThis) + aNSIter.Next(); + if (!aNSIter.More()) { + if (aUseThis) + break; + aUseThis = true; + } + } + DLOG << "}--------------------------------------------" << std::endl; +} + + + +//========================================================================== +static void DumpEvolution(Handle(TNaming_NamedShape) aNS) { + DLOG << "{"; + // TNaming_Iterator iterates in reversed way than it was put in Builder, so, keep it in container + // and iterate from end to begin + NCollection_List aOlds; + NCollection_List aNews; + NCollection_List aEvol; + for (TNaming_Iterator anIt(aNS); anIt.More(); anIt.Next()) { + aOlds.Prepend(anIt.OldShape()); + aNews.Prepend(anIt.NewShape()); + aEvol.Prepend(anIt.Evolution()); + } + NCollection_List::Iterator aOldIter(aOlds); + NCollection_List::Iterator aNewIter(aNews); + NCollection_List::Iterator aEvolIter(aEvol); + for(; aOldIter.More(); aOldIter.Next(), aNewIter.Next(), aEvolIter.Next()) { + switch (aEvolIter.Value()) { + case TNaming_PRIMITIVE : + DLOG << " * primitive " << ShapeTypeStr(aNewIter.Value()) << std::endl; + break; + case TNaming_GENERATED : + DLOG << " * generated from " << ShapeTypeStr(aOldIter.Value()) << " to " << ShapeTypeStr(aNewIter.Value()) << std::endl; + break; + case TNaming_MODIFY : + DLOG << " * modified from " << ShapeTypeStr(aOldIter.Value()) << " to " << ShapeTypeStr(aNewIter.Value()) << std::endl; + break; + case TNaming_DELETE : + DLOG << " * deleted " << ShapeTypeStr(aOldIter.Value()) << std::endl; + break; + case TNaming_SELECTED : + DLOG << " * selected in " << ShapeTypeStr(aNewIter.Value()) << " a(n) " << ShapeTypeStr(aOldIter.Value()) << std::endl; + break; + default: + break; + } + } + DLOG << "}" << std::endl; +} + +//========================================================================== +static void DumpVar(const char *szName, Handle(TNaming_NamedShape) aNS) { + if (aNS.IsNull()) { + DLOG << "[NamShp]: " << szName << "=Null" << std::endl; + return; + } + DLOG << "[NamShp]: " << szName << " vers=" << aNS->Version() << " Evol=[" << EvolutionStr(aNS->Evolution()) << "] Shape=\"" << ShapeTypeStr(aNS->Get()) << "\"" << std::endl; + //DumpEvolution(aNS); +} + +//========================================================================== +static void DumpVar(const char *szName, Handle(TDF_Attribute) attr) { + if (attr.IsNull()) { + DLOG << "[TDFAttr]: " << szName << "=Null" << std::endl; + return; + } + int trans = attr->Transaction(); + std::string state(" state=["); + state = state + (attr->IsValid() ? "valid" : "invalid"); + state = state + "|" + (attr->IsNew() ? "new" : "old"); + state = state + "|" + (attr->IsForgotten() ? "forgot" : "known") + "]"; + Handle(TDataStd_AsciiString) aAS = Handle(TDataStd_AsciiString)::DownCast(attr); + if (!aAS.IsNull()) { + DLOG << "[TDFAttr_AscStr]: " << szName << "=\"" << aAS->Get() << "\"" << " trans=" << trans << state << std::endl; + return; + } + Handle(TDataStd_BooleanArray) aBoolArr = Handle(TDataStd_BooleanArray)::DownCast(attr); + if (!aBoolArr.IsNull()) { + DLOG << "[TDFAttr_BoolArr]: " << szName << "=" << aBoolArr->Length() << " ["; + if (aBoolArr->Length() > 0) { + for (int i=aBoolArr->Lower(); i<=aBoolArr->Upper(); i++) { + DLOG << (i == aBoolArr->Lower() ? "" : ",") << YesNo(aBoolArr->Value(i)); + } + } + DLOG << "]" << " trans=" << trans << state << std::endl; + return; + } + Handle(TDataStd_BooleanList) aBoolLst = Handle(TDataStd_BooleanList)::DownCast(attr); + if (!aBoolLst.IsNull()) { + const TDataStd_ListOfByte& lst = aBoolLst->List(); + DLOG << "[TDFAttr_BoolLst]: " << szName << "=" << lst.Size() << " ["; + if (!lst.IsEmpty()) { + for (auto b=lst.cbegin(); b!=lst.cend(); ++b) { + DLOG << (b == lst.cbegin() ? "" : ",") << YesNo(*b); + } + } + DLOG << "]" << " trans=" << trans << state << std::endl; + return; + } + Handle(TDataStd_Comment) aCmt = Handle(TDataStd_Comment)::DownCast(attr); + if (!aCmt.IsNull()) { + DLOG << "[TDFAttr_Comment]: " << szName << "=\"" << aCmt->Get() << "\"" << " trans=" << trans << state << std::endl; + return; + } + Handle(TDataStd_ExtStringList) aESLst = Handle(TDataStd_ExtStringList)::DownCast(attr); + if (!aESLst.IsNull()) { + const TDataStd_ListOfExtendedString& lst = aESLst->List(); + DLOG << "[TDFAttr_ExStrLst]: " << szName << "=" << lst.Size() << " ["; + if (!lst.IsEmpty()) { + for (auto str=lst.cbegin(); str!=lst.cend(); ++str) { + //std::wstring ws((wchar_t*)(*str).ToExtString()); + DLOG << (str == lst.cbegin() ? "" : ",") << "\"" << *str << "\""; + } + } + DLOG << "]" << " trans=" << trans << state << std::endl; + return; + } + Handle(TDataStd_Integer) aInt = Handle(TDataStd_Integer)::DownCast(attr); + if (!aInt.IsNull()) { + DLOG << "[TDFAttr_Int]: " << szName << "=" << aInt->Get() << " trans=" << trans << state << std::endl; + return; + } + Handle(TDataStd_IntegerArray) aIntArr = Handle(TDataStd_IntegerArray)::DownCast(attr); + if (!aIntArr.IsNull()) { + DLOG << "[TDFAttr_IntArr]: " << szName << "=" << aIntArr->Length() << " ["; + if (aIntArr->Length() > 0) { + for (int i=aIntArr->Lower(); i<=aIntArr->Upper(); i++) { + DLOG << (i == aIntArr->Lower() ? "" : ",") << aIntArr->Value(i); + } + } + DLOG << "]" << " trans=" << trans << state << std::endl; + return; + } + + Handle(TDataStd_Name) aNam = Handle(TDataStd_Name)::DownCast(attr); + if (!aNam.IsNull()) { + DLOG << "[TDFAttr_Name]: " << szName << "=\"" << aNam->Get() << "\"" << " trans=" << trans << state << std::endl; + return; + } + Handle(TNaming_NamedShape) aNS = Handle(TNaming_NamedShape)::DownCast(attr); + if (!aNS.IsNull()) { + DLOG << "[TDFAttr_NamShp]: " << szName << "=\"" << ShapeTypeStr(aNS->Get()) << "\" trans=" << trans << state << std::endl; + DLOG << aNS; + TNaming_Iterator it(aNS); + for (; it.More(); it.Next()) { + MSGEL("[NamShp]: child: Modif=" << YesNo(it.IsModification()) << " Evol=[" << EvolutionStr(it.Evolution()) << "] Old=\"" << ShapeTypeStr(it.OldShape()) << "\" New=\""<< ShapeTypeStr(it.NewShape()) << "\""); + } + //SHOW(aNS); + return; + } + Handle(TDataStd_Real) aReal = Handle(TDataStd_Real)::DownCast(attr); + if (!aReal.IsNull()) { + DLOG << "[TDFAttr_Real]: " << szName << "=" << aReal->Get() << " trans=" << trans << state << std::endl; + return; + } + Handle(TDF_Reference) aRef = Handle(TDF_Reference)::DownCast(attr); + if (!aRef.IsNull()) { + TCollection_AsciiString entry; + TDF_Tool::Entry(aRef->Get(), entry); + DLOG << "[TDFAttr_Ref]: " << szName << "=" << entry << " trans=" << trans << state << std::endl; + return; + } + Handle(TDataStd_ReferenceArray) aRefArr = Handle(TDataStd_ReferenceArray)::DownCast(attr); + if (!aRefArr.IsNull()) { + DLOG << "[TDFAttr_RefArr]: " << szName << "=" << aRefArr->Length() << " ["; + if (aRefArr->Length() > 0) { + TCollection_AsciiString entry; + for (int i=aRefArr->Lower(); i<=aRefArr->Upper(); i++) { + TDF_Tool::Entry(aRefArr->Value(i), entry); + DLOG << (i == aRefArr->Lower() ? "" : ",") << entry; + } + } + DLOG << "]" << " trans=" << trans << state << std::endl; + return; + } + Handle(TDataStd_ReferenceList) aRefLst = Handle(TDataStd_ReferenceList)::DownCast(attr); + if (!aRefLst.IsNull()) { + const TDF_LabelList& lst = aRefLst->List(); + DLOG << "[TDFAttr_RefLst]: " << szName << "=" << lst.Size() << " ["; + if (!lst.IsEmpty()) { + TCollection_AsciiString entry; + for (auto ref=lst.cbegin(); ref!=lst.cend(); ++ref) { + TDF_Tool::Entry(*ref, entry); + DLOG << (ref == lst.cbegin() ? "" : ",") << entry; + } + } + DLOG << "]" << " trans=" << trans << state << std::endl; + return; + } + Handle(TDF_TagSource) aTS = Handle(TDF_TagSource)::DownCast(attr); + if (!aTS.IsNull()) { + DLOG << "[TDFAttr_TagSrc]: " << szName << "=" << aTS->Get() << " trans=" << trans << state << std::endl; + return; + } + Handle(TDataStd_UAttribute) aUA = Handle(TDataStd_UAttribute)::DownCast(attr); + if (!aUA.IsNull()) { + DLOG << "[TDFAttr_UAttr]: " << szName << "= trans=" << trans << state << std::endl; + return; + } + DLOG << "[" << attr->DynamicType()->Name() << "]" << attr << std::endl; +} + +//========================================================================== +static void DumpVar(const char *szName, const TDF_Label &lbl) { + try { + if (lbl.IsNull()) { + DLOG << "[Label]: " << szName << "=Null" << std::endl; + } else { + TCollection_AsciiString entry; TDF_Tool::Entry(lbl, entry); + std::string imp = (lbl.IsImported() ? "import" : "noimp"); + std::string modif = (lbl.MayBeModified() ? "modif" : "nomodif"); + int nAttr = (lbl.HasAttribute() ? lbl.NbAttributes() : 0); + int nChild = (lbl.HasChild() ? lbl.NbChildren() : 0); + DLOG << "[Label]: " << szName << "={" << entry << " state=[" << imp << "|" << modif << "] nAttr=" << nAttr << " nChild=" << nChild << (nChild > 0 || nAttr > 0 ? "" : "}") << std::endl; + if (nAttr > 0) { + // Dump all attributes + for (TDF_AttributeIterator itr(lbl); itr.More(); itr.Next()) { + Handle(TDF_Attribute) attr = itr.Value(); + SHOW(attr); + } + } + if (nChild > 0) { + TDF_Label child; + for (TDF_ChildIterator it(lbl); it.More(); it.Next()) { + child = it.Value(); + SHOW(child); + } + } + if (nAttr > 0 || nChild > 0) { + MSGEL("}"); + } + } + } + catch (...) { } +} + +//========================================================================== +static void DumpVar(const char *szName, const TopoDS_Shape &aShape) { + if (aShape.IsNull()) { + DLOG << "[TopShp]: " << szName << "=Null" << std::endl; + } else { + std::string typ = ShapeTypeStr(aShape); + DLOG << "[TopShp]: " << szName << "=" << aShape.TShape().get() << " ShapeType=" << typ; + if (aShape.ShapeType() == TopAbs_COMPOUND) { + int children[TopAbs_SHAPE+1] = {0}; + int nbChild = 0; + for (TopoDS_Iterator Iter(aShape); Iter.More(); Iter.Next()) { + if (!Iter.Value().IsNull()) { + children[(int)Iter.Value().ShapeType()]++; + nbChild++; + } + } + DLOG << " NumChild=" << nbChild; + if (nbChild > 0) { + bool bFirst = true; + DLOG << " ("; + for (int i=TopAbs_COMPOUND; i 0) { + if (!bFirst) DLOG << ", "; + DLOG << children[i] << " " << TopAbs::ShapeTypeToString((TopAbs_ShapeEnum)i); + bFirst = false; + } + } + DLOG << ")"; + } + } + else if (aShape.ShapeType() == TopAbs_COMPSOLID) { + DLOG << " NumChild=" << aShape.NbChildren(); + } + DLOG << std::endl; + } +} + +#endif // MBOCC_H \ No newline at end of file