IPAL54049: Operations on multiple study objects are very long

Most of time was spent in GEOM_Displayer::UpdateColorScale() {
myApp->selectionMgr()->selectedObjects( aSelectedObjects );
}
This commit is contained in:
eap 2017-03-22 17:02:15 +03:00
parent 7c7eefda24
commit fb044eba69
19 changed files with 315 additions and 287 deletions

View File

@ -322,8 +322,8 @@ void BuildGUI_FaceDlg::updateConstraintsTree()
return;
for ( int i = 0, n = aList->length(); i < n; i++ ) {
TreeWidgetItem* item = new TreeWidgetItem( myTreeConstraints,
GEOM::GeomObjPtr( aList[i] ) );
/*TreeWidgetItem* item =*/
new TreeWidgetItem( myTreeConstraints, GEOM::GeomObjPtr( aList[i] ) );
}
myEditCurrentArgument->setEnabled(false);

View File

@ -475,10 +475,10 @@ void DependencyTree_View::parseTree()
std::string objectEntry = i->first;
addNode( objectEntry );
parseTreeWard( i->second.first );
if( i->second.first.size() > myMaxUpwardLevelsNumber )
if((int) i->second.first.size() > myMaxUpwardLevelsNumber )
myMaxUpwardLevelsNumber = i->second.first.size();
parseTreeWard( i->second.second );
if( i->second.second.size() > myMaxDownwardLevelsNumber )
if((int) i->second.second.size() > myMaxDownwardLevelsNumber )
myMaxDownwardLevelsNumber = i->second.second.size();
}
@ -518,13 +518,13 @@ void DependencyTree_View::parseTreeWard( const GEOMUtils::LevelsList& theWard )
//=================================================================================
void DependencyTree_View::parseTreeWardArrow( const GEOMUtils::LevelsList& theWard)
{
for( int j = 0; j < theWard.size(); j++ ) {
for( size_t j = 0; j < theWard.size(); j++ ) {
GEOMUtils::LevelInfo Level = theWard.at(j);
GEOMUtils::LevelInfo::const_iterator node;
for( node = Level.begin(); node != Level.end(); node++ ) {
DependencyTree_Object* object = myTreeMap[ node->first ];
std::vector<std::string> Links = node->second;
for( int link = 0; link < Links.size(); link++ ) {
for( size_t link = 0; link < Links.size(); link++ ) {
DependencyTree_Object* LinkObject = myTreeMap[ Links[ link ] ];
if( object && LinkObject )
addArrow( LinkObject, object );
@ -607,7 +607,7 @@ void DependencyTree_View::drawTree()
std::map< int, std::vector< std::string > >::const_iterator level;
for( level = levelObjects.begin(); level != levelObjects.end(); level++ ) {
int step = -horDistance * ( int(level->second.size()) - 1 ) / 2;
for( int objIter = 0; objIter < level->second.size(); objIter++ ) {
for( size_t objIter = 0; objIter < level->second.size(); objIter++ ) {
DependencyTree_Object* anObject = myTreeMap[ level->second.at( objIter ) ];
anObject->setPos( step, verDistance * level->first );
step += horDistance;
@ -647,7 +647,7 @@ void DependencyTree_View::drawWard( const GEOMUtils::LevelsList& theWard,
std::map< int, std::vector< std::string > >& theLevelObjects,
int theCurrentLevel, const int theLevelStep )
{
for( int level = 0; level < theWard.size(); level++ ) {
for( int level = 0, size = theWard.size(); level < size; level++ ) {
if( level >= myLevelsNumber )
return;
theCurrentLevel += theLevelStep;
@ -671,7 +671,7 @@ void DependencyTree_View::drawWard( const GEOMUtils::LevelsList& theWard,
//=================================================================================
void DependencyTree_View::drawWardArrows( const GEOMUtils::LevelsList& theWard )
{
for( int j = 0; j < theWard.size(); j++ ) {
for( int j = 0, size = theWard.size(); j < size; j++ ) {
if( j >= myLevelsNumber )
break;
GEOMUtils::LevelInfo Level = theWard.at(j);
@ -679,7 +679,7 @@ void DependencyTree_View::drawWardArrows( const GEOMUtils::LevelsList& theWard )
for( node = Level.begin(); node != Level.end(); node++ ) {
DependencyTree_Object* object = myTreeMap[ node->first ];
GEOMUtils::NodeLinks Links = node->second;
for( int link = 0; link < Links.size(); link++ ) {
for( size_t link = 0; link < Links.size(); link++ ) {
DependencyTree_Object* LinkObject = myTreeMap[ Links[ link ] ];
if( isItemAdded( object ) && isItemAdded( LinkObject ) ) {
DependencyTree_Arrow* arrow = myArrows[ std::pair<DependencyTree_Object*,DependencyTree_Object*>( LinkObject, object ) ];
@ -824,4 +824,5 @@ int DependencyTree_View::checkMaxLevelsNumber()
return myMaxUpwardLevelsNumber;
else if( myDisplayDescendants->isChecked() )
return myMaxDownwardLevelsNumber;
return 0;
}

View File

@ -89,7 +89,7 @@ GEOM::GEOM_Gen_ptr GEOMBase_Helper::getGeomEngine()
// Purpose :
//================================================================
GEOMBase_Helper::GEOMBase_Helper( SUIT_Desktop* desktop )
: myDesktop( desktop ), myViewWindow( 0 ), myDisplayer( 0 ), myCommand( 0 ), isPreview( false ),
: myDisplayer( 0 ), myCommand( 0 ), myViewWindow( 0 ), isPreview( false ), myDesktop( desktop ),
myIsApplyAndClose( false ), myIsOptimizedBrowsing( false ), myIsWaitCursorEnabled( true ),
myIsDisableBrowsing(false), myIsDisplayResult(true)
{

View File

@ -61,7 +61,7 @@ GEOMGUI_AnnotationMgr::GEOMGUI_AnnotationMgr( SalomeApp_Application* theApplicat
QString GEOMGUI_AnnotationMgr::GetEntrySeparator()
{
return "_annotation:";
return "_annotation:";
}
//================================================================
@ -113,7 +113,7 @@ SALOME_Prs* GEOMGUI_AnnotationMgr::CreatePresentation( const GEOMGUI_AnnotationA
setDisplayProperties( aPresentation, aView, getEntry( theObject ).c_str() );
// add Prs to preview
SUIT_ViewWindow* vw = getApplication()->desktop()->activeWindow();
//SUIT_ViewWindow* vw = getApplication()->desktop()->activeWindow();
SOCC_Prs* aPrs =
dynamic_cast<SOCC_Prs*>( ( aView )->CreatePrs( 0 ) );
@ -424,7 +424,6 @@ void GEOMGUI_AnnotationMgr::UpdateVisibleAnnotations( const QString& theEntry, S
if ( !aShape.IsNull() ) {
gp_Ax3 aShapeLCS = gp_Ax3().Transformed( aShape.Location().Transformation() );
GEOMGUI_AnnotationAttrs::SetupPresentation( aPresentation, aProperty, aShapeLCS );
if ( aProperty.ShapeType == TopAbs_SHAPE ) {
aPresentation->SetHilightShape( aShape );

View File

@ -538,10 +538,8 @@ bool GEOMGUI_Selection::isNameMode( const int index ) const
bool GEOMGUI_Selection::hasChildren( const _PTR(SObject)& obj )
{
if ( obj ) {
// as soon as Use Case browser data tree was added
return obj->GetStudy()->GetUseCaseBuilder()->HasChildren( obj );
}
// as soon as Use Case browser data tree was added
return obj ? obj->GetStudy()->GetUseCaseBuilder()->HasChildren( obj ) : false;
}
bool GEOMGUI_Selection::expandable( const _PTR(SObject)& obj )

View File

@ -171,7 +171,7 @@ namespace
if ( aPixmap.IsNull() ) {
QPixmap px(":images/default_texture.png");
if ( !px.isNull() )
aPixmap = OCCViewer_Utilities::imageToPixmap( px.toImage() );
aPixmap = OCCViewer_Utilities::imageToPixmap( px.toImage() );
}
return aPixmap;
}
@ -464,7 +464,7 @@ static std::string getName( GEOM::GEOM_BaseObject_ptr object )
*/
//=================================================================
GEOM_Displayer::GEOM_Displayer( SalomeApp_Study* st )
: myIsRedisplayed( false )
: myUpdateColorScale(true), myIsRedisplayed( false )
{
if( st )
myApp = dynamic_cast<SalomeApp_Application*>( st->application() );
@ -738,7 +738,7 @@ void GEOM_Displayer::UpdateVisibility( SALOME_View* v, const SALOME_Prs* p, bool
QString entry = p->GetEntry();
if ( !entry.isEmpty() ) {
if ( vId != -1 )
aStudy->setObjectProperty( vId, entry, GEOM::propertyName( GEOM::Visibility ), on );
aStudy->setObjectProperty( vId, entry, GEOM::propertyName( GEOM::Visibility ), on );
setVisibilityState( entry, on ? Qtx::ShownState : Qtx::HiddenState );
}
}
@ -1014,9 +1014,9 @@ void GEOM_Displayer::updateShapeProperties( const Handle(GEOM_AISShape)& AISShap
if ( !aTexture.IsNull() ) {
Handle(Prs3d_PointAspect) aTextureAspect =
new Prs3d_PointAspect( HasColor() ?
// predefined color, manually set to displayer via GEOM_Displayer::SetColor() function
(Quantity_NameOfColor)GetColor() :
// color from properties
// predefined color, manually set to displayer via GEOM_Displayer::SetColor() function
(Quantity_NameOfColor)GetColor() :
// color from properties
SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::PointColor ) ).value<QColor>() ),
aWidth, aHeight,
aTexture );
@ -2606,7 +2606,7 @@ PropMap GEOM_Displayer::getDefaultPropertyMap()
// - transparency (opacity = 1-transparency)
propMap.insert( GEOM::propertyName( GEOM::Transparency ),
resMgr->integerValue( "Geometry", "transparency", 0 ) / 100. );
resMgr->integerValue( "Geometry", "transparency", 0 ) / 100. );
// - display mode (take default value from preferences)
propMap.insert( GEOM::propertyName( GEOM::DisplayMode ),
@ -3046,43 +3046,41 @@ void GEOM_Displayer::UpdateColorScale( const bool theIsRedisplayFieldSteps, cons
Standard_Real aColorScaleMin = 0, aColorScaleMax = 0;
Standard_Boolean anIsBoolean = Standard_False;
SALOME_ListIO aSelectedObjects;
myApp->selectionMgr()->selectedObjects( aSelectedObjects );
if( aSelectedObjects.Extent() == 1 )
Handle(SALOME_InteractiveObject) anIO;
if ( myUpdateColorScale )
anIO = myApp->selectionMgr()->soleSelectedObject();
if( !anIO.IsNull() )
{
Handle(SALOME_InteractiveObject) anIO = aSelectedObjects.First();
if( !anIO.IsNull() )
SOCC_Prs* aPrs = dynamic_cast<SOCC_Prs*>( aViewModel->CreatePrs( anIO->getEntry() ) );
if( aPrs )
{
SOCC_Prs* aPrs = dynamic_cast<SOCC_Prs*>( aViewModel->CreatePrs( anIO->getEntry() ) );
if( aPrs )
AIS_ListOfInteractive aList;
aPrs->GetObjects( aList );
AIS_ListIteratorOfListOfInteractive anIter( aList );
for( ; anIter.More(); anIter.Next() )
{
AIS_ListOfInteractive aList;
aPrs->GetObjects( aList );
AIS_ListIteratorOfListOfInteractive anIter( aList );
for( ; anIter.More(); anIter.Next() )
Handle(GEOM_AISShape) aShape = Handle(GEOM_AISShape)::DownCast( anIter.Value() );
if( !aShape.IsNull() )
{
Handle(GEOM_AISShape) aShape = Handle(GEOM_AISShape)::DownCast( anIter.Value() );
if( !aShape.IsNull() )
GEOM::field_data_type aFieldDataType;
int aFieldDimension;
QList<QVariant> aFieldStepData;
TCollection_AsciiString aFieldStepName;
double aFieldStepRangeMin, aFieldStepRangeMax;
aShape->getFieldStepInfo( aFieldDataType,
aFieldDimension,
aFieldStepData,
aFieldStepName,
aFieldStepRangeMin,
aFieldStepRangeMax );
if( !aFieldStepData.isEmpty() && aFieldDataType != GEOM::FDT_String )
{
GEOM::field_data_type aFieldDataType;
int aFieldDimension;
QList<QVariant> aFieldStepData;
TCollection_AsciiString aFieldStepName;
double aFieldStepRangeMin, aFieldStepRangeMax;
aShape->getFieldStepInfo( aFieldDataType,
aFieldDimension,
aFieldStepData,
aFieldStepName,
aFieldStepRangeMin,
aFieldStepRangeMax );
if( !aFieldStepData.isEmpty() && aFieldDataType != GEOM::FDT_String )
{
anIsDisplayColorScale = Standard_True;
aColorScaleTitle = aFieldStepName;
aColorScaleMin = aFieldStepRangeMin;
aColorScaleMax = aFieldStepRangeMax;
anIsBoolean = aFieldDataType == GEOM::FDT_Bool;
}
anIsDisplayColorScale = Standard_True;
aColorScaleTitle = aFieldStepName;
aColorScaleMin = aFieldStepRangeMin;
aColorScaleMax = aFieldStepRangeMax;
anIsBoolean = aFieldDataType == GEOM::FDT_Bool;
}
}
}

View File

@ -230,6 +230,7 @@ public:
/* Update visibility and parameters of the currently selected field step's color scale */
void UpdateColorScale( const bool theIsRedisplayFieldSteps = false, const bool updateViewer = true );
void SetUpdateColorScale(bool toUpdate) { myUpdateColorScale = toUpdate; } // IPAL54049
protected:
/* internal methods */
@ -304,6 +305,7 @@ protected:
#if OCC_VERSION_MAJOR >= 7
Handle(AIS_ColorScale) myColorScale;
#endif
int myUpdateColorScale; // IPAL54049
// Attributes
Quantity_Color myShadingColor;

View File

@ -1189,7 +1189,7 @@ void GeometryGUI::initialize( CAM_Application* app )
// ---- create menus --------------------------
int fileId = createMenu( tr( "MEN_FILE" ), -1, -1 );
/*int fileId =*/ createMenu( tr( "MEN_FILE" ), -1, -1 );
int editId = createMenu( tr( "MEN_EDIT" ), -1, -1 );
createMenu( GEOMOp::OpDelete, editId, -1 );
@ -2246,7 +2246,7 @@ Handle(TColStd_HArray1OfByte) GeometryGUI::getTexture
aTexture = new TColStd_HArray1OfByte (1, aStream->length());
for (int i = 0; i < aStream->length(); i++)
for ( CORBA::ULong i = 0; i < aStream->length(); i++)
aTexture->SetValue( i+1, (Standard_Byte)aStream[i] );
aTextureMap[ theId ] = aTexture;
}
@ -2452,7 +2452,7 @@ void GeometryGUI::createPreferences()
resMgr->value("resources", "GEOM", aFontFile);
aFontFile = aFontFile + QDir::separator() + "Y14.5M-2009.ttf";
// add enginier font into combobox
int fontID = QFontDatabase::addApplicationFont( aFontFile );
/*int fontID =*/ QFontDatabase::addApplicationFont( aFontFile );
Handle(Font_SystemFont) sf = new Font_SystemFont(
new TCollection_HAsciiString("Y14.5M-2009"),
Font_FA_Regular,

View File

@ -90,54 +90,61 @@ static bool inUse( _PTR(Study) study, const QString& component, const QMap<QStri
QMap<QString, GEOM::GEOM_BaseObject_var> gobjects;
QMap<QString, QString>::ConstIterator oit;
std::list<_PTR(SObject)> aSelectedSO;
for ( oit = objects.begin(); oit != objects.end(); ++oit ) {
for ( oit = objects.begin(); oit != objects.end(); ++oit )
{
_PTR(SObject) so = study->FindObjectID( oit.key().toLatin1().data() );
if ( !so )
continue;
aSelectedSO.push_back(so);
CORBA::Object_var corbaObj_rem = GeometryGUI::ClientSObjectToObject( so );
CORBA::Object_var corbaObj_rem = GeometryGUI::ClientSObjectToObject( so );
GEOM::GEOM_BaseObject_var geomObj_rem = GEOM::GEOM_BaseObject::_narrow( corbaObj_rem );
if( CORBA::is_nil( geomObj_rem ) )
continue;
gobjects.insert( oit.key(), geomObj_rem );
if ( ! CORBA::is_nil( geomObj_rem ))
gobjects.insert( oit.key(), geomObj_rem );
}
// Search References with other Modules
std::list< _PTR(SObject) >::iterator itSO = aSelectedSO.begin();
for ( ; itSO != aSelectedSO.end(); ++itSO ) {
for ( ; itSO != aSelectedSO.end(); ++itSO )
{
std::vector<_PTR(SObject)> aReferences = study->FindDependances( *itSO );
int aRefLength = aReferences.size();
if (aRefLength) {
for (int i = 0; i < aRefLength; i++) {
_PTR(SObject) firstSO( aReferences[i] );
_PTR(SComponent) aComponent = firstSO->GetFatherComponent();
QString type = aComponent->ComponentDataType().c_str();
if ( type == "SMESH" )
return true;
}
for ( int i = 0; i < aRefLength; i++ )
{
_PTR(SObject) firstSO( aReferences[i] );
_PTR(SComponent) aComponent = firstSO->GetFatherComponent();
QString type = aComponent->ComponentDataType().c_str();
if ( type == "SMESH" )
return true;
}
}
// browse through all GEOM data tree
// browse through all GEOM data tree to find an object with is not deleted and depends
// on a deleted object
_PTR(ChildIterator) it ( study->NewChildIterator( comp ) );
for ( it->InitEx( true ); it->More(); it->Next() ) {
_PTR(SObject) child( it->Value() );
CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( child );
for ( it->InitEx( true ); it->More(); it->Next() )
{
_PTR(SObject) child = it->Value();
QString childID = child->GetID().c_str();
bool deleted = objects.contains( childID );
if ( deleted )
continue; // deleted object
CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( child );
GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
if( CORBA::is_nil( geomObj ) )
if ( CORBA::is_nil( geomObj ) )
continue;
GEOM::ListOfGBO_var list = geomObj->GetDependency();
if( list->length() == 0 )
continue;
GEOM::ListOfGBO_var dep = geomObj->GetDependency(); // child depends on dep
for( CORBA::ULong i = 0; i < dep->length(); i++ )
{
CORBA::String_var id = dep[i]->GetStudyEntry();
bool depends = objects.contains( id.in() ); // depends on deleted
for( int i = 0; i < list->length(); i++ ) {
bool depends = false;
bool deleted = false;
QMap<QString, GEOM::GEOM_BaseObject_var>::Iterator git;
for ( git = gobjects.begin(); git != gobjects.end() && ( !depends || !deleted ); ++git ) {
depends = depends || list[i]->_is_equivalent( *git );
deleted = deleted || git.key() == child->GetID().c_str() ;//geomObj->_is_equivalent( *git );
for ( git = gobjects.begin(); git != gobjects.end() && ( !depends || !deleted ); ++git )
{
depends = depends || dep[i]->_is_equivalent( *git );
deleted = deleted || git.key() == childID ;//geomObj->_is_equivalent( *git )
}
if ( depends && !deleted )
return true;
@ -150,8 +157,8 @@ static bool inUse( _PTR(Study) study, const QString& component, const QMap<QStri
// function : getGeomChildrenAndFolders
// purpose : Get direct (1-level) GEOM objects under each folder, sub-folder, etc. and these folders itself
//=======================================================================
static void getGeomChildrenAndFolders( _PTR(SObject) theSO,
QMap<QString,QString>& geomObjList,
static void getGeomChildrenAndFolders( _PTR(SObject) theSO,
QMap<QString,QString>& geomObjList,
QMap<QString,QString>& folderList ) {
if ( !theSO ) return;
_PTR(Study) aStudy = theSO->GetStudy();
@ -182,7 +189,7 @@ static void getGeomChildrenAndFolders( _PTR(SObject) theSO,
// purpose : Constructor
//=======================================================================
GEOMToolsGUI::GEOMToolsGUI( GeometryGUI* parent )
: GEOMGUI( parent )
: GEOMGUI( parent )
{
}
@ -444,6 +451,8 @@ void GEOMToolsGUI::OnEditDelete()
if ( !dlg.exec() )
return; // operation is cancelled by user
SUIT_OverrideCursor wc;
// get currently opened views
QList<SALOME_View*> views;
SALOME_View* view;
@ -457,7 +466,8 @@ void GEOMToolsGUI::OnEditDelete()
}
_PTR(StudyBuilder) aStudyBuilder (aStudy->NewBuilder());
GEOM_Displayer* disp = new GEOM_Displayer( appStudy );
GEOM_Displayer disp( appStudy );
disp.SetUpdateColorScale( false ); // IPAL54049
if ( isComponentSelected ) {
// GEOM component is selected: delete all objects recursively
@ -469,7 +479,7 @@ void GEOMToolsGUI::OnEditDelete()
for ( it->InitEx( false ); it->More(); it->Next() ) {
_PTR(SObject) child( it->Value() );
// remove object from GEOM engine
removeObjectWithChildren( child, aStudy, views, disp );
removeObjectWithChildren( child, aStudy, views, &disp );
// remove object from study
aStudyBuilder->RemoveObjectWithChildren( child );
// remove object from use case tree
@ -491,7 +501,7 @@ void GEOMToolsGUI::OnEditDelete()
for ( it = toBeDeleted.begin(); it != toBeDeleted.end(); ++it ) {
_PTR(SObject) obj ( aStudy->FindObjectID( it.key().toLatin1().data() ) );
// remove object from GEOM engine
removeObjectWithChildren( obj, aStudy, views, disp );
removeObjectWithChildren( obj, aStudy, views, &disp );
// remove objects from study
aStudyBuilder->RemoveObjectWithChildren( obj );
// remove object from use case tree
@ -501,7 +511,7 @@ void GEOMToolsGUI::OnEditDelete()
for ( it = toBeDelFolders.begin(); it != toBeDelFolders.end(); ++it ) {
_PTR(SObject) obj ( aStudy->FindObjectID( it.key().toLatin1().data() ) );
// remove object from GEOM engine
removeObjectWithChildren( obj, aStudy, views, disp );
removeObjectWithChildren( obj, aStudy, views, &disp );
// remove objects from study
aStudyBuilder->RemoveObjectWithChildren( obj );
// remove object from use case tree

View File

@ -530,6 +530,8 @@ void GEOMToolsGUI::OnDiscloseConcealChildren( bool show )
return;
}
SUIT_OverrideCursor wc;
disp->SetUpdateColorScale( false ); // IPAL54049
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
Handle(SALOME_InteractiveObject) IObject = It.Value();
@ -538,10 +540,12 @@ void GEOMToolsGUI::OnDiscloseConcealChildren( bool show )
if ( obj ) {
_PTR(AttributeExpandable) aExp = B->FindOrCreateAttribute( obj, "AttributeExpandable" );
aExp->SetExpandable( show );
if(!show)
if ( !show ) {
disp->EraseWithChildren(IObject,true);
}
} // if ( obj )
} // iterator
disp->SetUpdateColorScale( true );
}
}
app->updateObjectBrowser( false );
@ -593,7 +597,8 @@ void GEOMToolsGUI::OnUnpublishObject() {
QObject::tr( "WRN_STUDY_LOCKED" ) );
return;
}
SUIT_OverrideCursor wc;
disp->SetUpdateColorScale( false ); // IPAL54049
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
Handle(SALOME_InteractiveObject) IObject = It.Value();
@ -612,6 +617,7 @@ void GEOMToolsGUI::OnUnpublishObject() {
}
} // if ( obj )
} // iterator
disp->SetUpdateColorScale( true ); // IPAL54049
aSelMgr->clearSelected();
}
}
@ -857,7 +863,7 @@ void GEOMToolsGUI::OnCreateFolder()
if ( !aFatherSO ) return;
GeometryGUI::GetGeomGen()->CreateFolder( tr("NEW_FOLDER_NAME").toLatin1().constData(),
_CAST(SObject, aFatherSO)->GetSObject() );
_CAST(SObject, aFatherSO)->GetSObject() );
app->updateObjectBrowser( false );
}
@ -891,7 +897,7 @@ void GEOMToolsGUI::OnSortChildren()
#ifndef DISABLE_GRAPHICSVIEW
void GEOMToolsGUI::OnShowDependencyTree()
{
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
//SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
if ( !app ) return;

View File

@ -30,40 +30,54 @@
#include <QGridLayout>
#include <SUIT_MessageBox.h>
static bool isEntryLess( const QString& e1, const QString& e2 )
#include <iostream>
namespace
{
QStringList el1 = e1.split(":");
QStringList el2 = e2.split(":");
int e1c = el1.count(), e2c = el2.count();
for ( int i = 0; i < e1c && i < e2c; i++ ) {
int id1 = el1[i].toInt();
int id2 = el2[i].toInt();
if ( id1 < id2 ) return true;
else if ( id2 < id1 ) return false;
}
return el1.count() < el2.count();
struct NaturalCompare
{
bool operator () (const std::string& s1, const std::string& s2) const
{
// hope the entries are never empty and never equal
int diff21 = 0;
const char* p1 = s1.c_str();
const char* p2 = s2.c_str();
for ( ; ; ++p1, ++p2 )
{
if ( *p1 == *p2 )
{
if ( diff21 && !*p1 ) // both numbers ends
return diff21 > 0;
continue;
}
// different chars
bool d1 = isdigit( *p1 );
bool d2 = isdigit( *p2 );
if ( d1 != d2 ) // one number is shorter then another
return d2; // is s1 shorter?
if ( !d1 && diff21 ) // both numbers ends
return diff21 > 0;
if ( !diff21 ) // remember the first difference
diff21 = *p2 - *p1;
}
return diff21 > 0;
}
};
}
static QStringList objectsToNames( const QMap<QString, QString>& objects )
{
QStringList entries;
for ( QMap<QString, QString>::ConstIterator it = objects.begin(); it != objects.end(); ++it ) {
QString entry = it.key();
QStringList::Iterator iter;
bool added = false;
for ( iter = entries.begin(); iter != entries.end() && !added; ++iter ) {
if ( isEntryLess( entry, *iter ) ) {
entries.insert( iter, entry );
added = true;
}
}
if ( !added )
entries.append( entry );
}
typedef std::map< std::string, QString, NaturalCompare > TSortMap;
TSortMap sortedByEntry;
for ( QMap<QString, QString>::ConstIterator it = objects.begin(); it != objects.end(); ++it )
sortedByEntry.insert( sortedByEntry.end(), std::make_pair( it.key().toStdString(), it.value() ));
QStringList names;
for ( int i = 0; i < entries.count(); i++ ) {
int level = entries[i].count(":")-3;
names.append( QString( level*2, ' ' ) + objects[ entries[i] ] );
for ( TSortMap::iterator it = sortedByEntry.begin(); it != sortedByEntry.end(); ++it )
{
const std::string& entry = it->first;
int level = std::count( entry.begin(), entry.end(), ':' ) - 3;
names.append( QString( level * 2, ' ' ) + it->second );
}
return names;
}

View File

@ -778,7 +778,7 @@ void GEOMToolsGUI_MaterialPropertiesDlg::SelectionIntoArgument()
if ( study ) {
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aString, true);
}
/*int nbSel = */GEOMBase::GetNameOfSelectedIObjects(aSelList, aString, true);
}
myLineEditCurArg->setText( aString );
}

View File

@ -141,22 +141,22 @@ GEOMToolsGUI_PublishDlg::~GEOMToolsGUI_PublishDlg()
if ( appStudy ) {
_PTR(Study) aStudy = appStudy->studyDS();
if ( aStudy ) {
GEOM_Displayer displayer ( appStudy );
QTreeWidgetItemIterator it( myTreeWidget );
while ( *it ) {
QString entry = myEntryToItem.key( *it );
_PTR(SObject) SO ( aStudy->FindObjectID( qPrintable( entry ) ) );
if ( SO ) {
GEOM::GEOM_Object_var aGeomObject = GEOM::GEOM_Object::_narrow( GeometryGUI::ClientSObjectToObject( SO ) );
if ( CORBA::is_nil( aGeomObject ) ) continue;
if ( displayer.IsDisplayed( aGeomObject->GetStudyEntry() ) ) {
Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject( aGeomObject->GetStudyEntry(), "GEOM", "" );
displayer.Erase( io );
}
}
++it;
}
displayer.UpdateViewer();
GEOM_Displayer displayer ( appStudy );
QTreeWidgetItemIterator it( myTreeWidget );
while ( *it ) {
QString entry = myEntryToItem.key( *it );
_PTR(SObject) SO ( aStudy->FindObjectID( qPrintable( entry ) ) );
if ( SO ) {
GEOM::GEOM_Object_var aGeomObject = GEOM::GEOM_Object::_narrow( GeometryGUI::ClientSObjectToObject( SO ) );
if ( CORBA::is_nil( aGeomObject ) ) continue;
if ( displayer.IsDisplayed( aGeomObject->GetStudyEntry() ) ) {
Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject( aGeomObject->GetStudyEntry(), "GEOM", "" );
displayer.Erase( io );
}
}
++it;
}
displayer.UpdateViewer();
}
}
}
@ -346,10 +346,10 @@ void GEOMToolsGUI_PublishDlg::clickOnApply() {
}
// show references if any
std::vector< _PTR(SObject) > vso = aStudy->FindDependances(SO);
for ( int i = 0; i < vso.size(); i++ ) {
_PTR(SObject) refObj = vso[i];
aDrw = aBuilder->FindOrCreateAttribute( refObj, "AttributeDrawable" );
aDrw->SetDrawable( true );
for ( size_t i = 0; i < vso.size(); i++ ) {
_PTR(SObject) refObj = vso[i];
aDrw = aBuilder->FindOrCreateAttribute( refObj, "AttributeDrawable" );
aDrw->SetDrawable( true );
}
}
}

View File

@ -165,8 +165,8 @@ void GEOMToolsGUI_ReduceStudyDlg::init( const std::set<std::string>& theObjectEn
GEOM::string_array_var otherObjects = new GEOM::string_array();
GeometryGUI::GetGeomGen()->GetEntriesToReduceStudy( GeometryGUI::ClientStudyToStudy( myStudy ),
keptObjects, parentsObjects,
subObjects, otherObjects );
keptObjects, parentsObjects,
subObjects, otherObjects );
for ( int i = 0; i < keptObjects->length(); i++ )
myKeptObjects.insert( keptObjects[i].in() );
@ -349,7 +349,7 @@ void GEOMToolsGUI_ReduceStudyDlg::checkVisibleIcon( QTreeWidget* theWidget )
QTreeWidgetItemIterator it( theWidget );
while(*it) {
GEOMToolsGUI_TreeWidgetItem* item = dynamic_cast<GEOMToolsGUI_TreeWidgetItem*>(*it);
const char* entry = item->getStudyEntry();
//const char* entry = item->getStudyEntry();
if( item->flags() & Qt::ItemIsSelectable )
if( !item->isVisible() )
isInvisible = true;
@ -658,11 +658,11 @@ void GEOMToolsGUI_ReduceStudyDlg::clickOnOk()
}
if( myGroupIntermediates->checkedId() == 2 ) { // remove
if( !myCBSoftRemoval->isChecked() &&
SUIT_MessageBox::question( this,
tr( "GEOM_WRN_WARNING" ),
tr( "GEOM_REDUCE_STUDY_WARNING_DELETE" ),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::Yes ) == QMessageBox::No ) {
SUIT_MessageBox::question( this,
tr( "GEOM_WRN_WARNING" ),
tr( "GEOM_REDUCE_STUDY_WARNING_DELETE" ),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::Yes ) == QMessageBox::No ) {
return;
}
for( iter = myListParents.begin(); iter != myListParents.end(); ++iter )

View File

@ -116,97 +116,97 @@ bool IGESPlugin_GUI::importIGES( SUIT_Desktop* parent )
if ( igesOp.isNull() ) return false;
QStringList fileNames = app->getOpenFileNames( SUIT_FileDlg::getLastVisitedPath().isEmpty() ? QDir::currentPath() : QString(""),
tr( "IGES_FILES" ),
tr( "IMPORT_TITLE" ),
parent );
tr( "IGES_FILES" ),
tr( "IMPORT_TITLE" ),
parent );
if ( fileNames.count() > 0 )
{
QStringList entryList;
QStringList errors;
SUIT_MessageBox::StandardButton igesAnswer = SUIT_MessageBox::NoButton;
for ( int i = 0; i < fileNames.count(); i++ )
{
QString fileName = fileNames.at( i );
SUIT_OverrideCursor wc;
GEOM_Operation transaction( app, igesOp.get() );
bool ignoreUnits = false;
try
{
app->putInfo( tr( "GEOM_PRP_LOADING" ).arg( SUIT_Tools::file( fileName, true ) ) );
transaction.start();
CORBA::String_var units = igesOp->ReadValue( fileName.toUtf8().constData(), "LEN_UNITS" );
QString unitsStr( units.in() );
bool unitsOK = unitsStr.isEmpty() || unitsStr == "M" || unitsStr.toLower() == "metre";
if ( !unitsOK )
{
if( igesAnswer == SUIT_MessageBox::NoToAll )
{
ignoreUnits = true;
}
else if( igesAnswer != SUIT_MessageBox::YesToAll )
{
SUIT_MessageBox::StandardButtons btns = SUIT_MessageBox::Yes | SUIT_MessageBox::No | SUIT_MessageBox::Cancel;
if ( i < fileNames.count()-1 ) btns = btns | SUIT_MessageBox::YesToAll | SUIT_MessageBox::NoToAll;
igesAnswer = SUIT_MessageBox::question( parent,
tr( "WRN_WARNING" ),
tr( "SCALE_DIMENSIONS" ).arg( unitsStr ),
btns,
SUIT_MessageBox::No );
switch ( igesAnswer )
{
case SUIT_MessageBox::Cancel:
return true; // cancel (break) import operation
case SUIT_MessageBox::Yes:
case SUIT_MessageBox::YesToAll:
break; // scaling is confirmed
case SUIT_MessageBox::No:
case SUIT_MessageBox::NoAll:
ignoreUnits = true; // scaling is rejected
default:
break;
}
}
}
GEOM::ListOfGO_var result = igesOp->ImportIGES( fileName.toUtf8().constData(), ignoreUnits );
if ( result->length() > 0 && igesOp->IsDone() )
{
GEOM::GEOM_Object_var main = result[0];
QString publishName = GEOMBase::GetDefaultName( SUIT_Tools::file( fileName, true ) );
SALOMEDS::SObject_var so = GeometryGUI::GetGeomGen()->PublishInStudy( dsStudy,
SALOMEDS::SObject::_nil(),
main.in(),
publishName.toUtf8().constData() );
entryList.append( so->GetID() );
transaction.commit();
GEOM_Displayer( study ).Display( main.in() );
app->putInfo( tr( "GEOM_PRP_LOADING" ).arg( SUIT_Tools::file( fileName, true ) ) );
transaction.start();
CORBA::String_var units = igesOp->ReadValue( fileName.toUtf8().constData(), "LEN_UNITS" );
QString unitsStr( units.in() );
bool unitsOK = unitsStr.isEmpty() || unitsStr == "M" || unitsStr.toLower() == "metre";
if ( !unitsOK )
{
if( igesAnswer == SUIT_MessageBox::NoToAll )
{
ignoreUnits = true;
}
else if( igesAnswer != SUIT_MessageBox::YesToAll )
{
SUIT_MessageBox::StandardButtons btns = SUIT_MessageBox::Yes | SUIT_MessageBox::No | SUIT_MessageBox::Cancel;
if ( i < fileNames.count()-1 ) btns = btns | SUIT_MessageBox::YesToAll | SUIT_MessageBox::NoToAll;
igesAnswer = SUIT_MessageBox::question( parent,
tr( "WRN_WARNING" ),
tr( "SCALE_DIMENSIONS" ).arg( unitsStr ),
btns,
SUIT_MessageBox::No );
switch ( igesAnswer )
{
case SUIT_MessageBox::Cancel:
return true; // cancel (break) import operation
case SUIT_MessageBox::Yes:
case SUIT_MessageBox::YesToAll:
break; // scaling is confirmed
case SUIT_MessageBox::No:
case SUIT_MessageBox::NoAll:
ignoreUnits = true; // scaling is rejected
default:
break;
}
}
}
GEOM::ListOfGO_var result = igesOp->ImportIGES( fileName.toUtf8().constData(), ignoreUnits );
if ( result->length() > 0 && igesOp->IsDone() )
{
GEOM::GEOM_Object_var main = result[0];
QString publishName = GEOMBase::GetDefaultName( SUIT_Tools::file( fileName, true ) );
SALOMEDS::SObject_var so = GeometryGUI::GetGeomGen()->PublishInStudy( dsStudy,
SALOMEDS::SObject::_nil(),
main.in(),
publishName.toUtf8().constData() );
entryList.append( so->GetID() );
transaction.commit();
GEOM_Displayer( study ).Display( main.in() );
main->UnRegister();
}
else
{
transaction.abort();
errors.append( QString( "%1 : %2" ).arg( fileName ).arg( igesOp->GetErrorCode() ) );
}
}
else
{
transaction.abort();
errors.append( QString( "%1 : %2" ).arg( fileName ).arg( igesOp->GetErrorCode() ) );
}
}
catch( const SALOME::SALOME_Exception& e )
{
transaction.abort();
transaction.abort();
}
}
getGeometryGUI()->updateObjBrowser( true );
app->browseObjects( entryList );
if ( errors.count() > 0 )
{
SUIT_MessageBox::critical( parent,
tr( "GEOM_ERROR" ),
tr( "GEOM_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
tr( "GEOM_ERROR" ),
tr( "GEOM_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
}
}
return fileNames.count() > 0;
@ -245,10 +245,10 @@ bool IGESPlugin_GUI::exportIGES( SUIT_Desktop* parent )
QString version;
QString fileName = IGESPlugin_ExportDlg::getFileName( QString( io->getName() ),
tr( "IGES_FILES" ),
tr( "EXPORT_TITLE" ),
parent,
version );
tr( "IGES_FILES" ),
tr( "EXPORT_TITLE" ),
parent,
version );
if ( fileName.isEmpty() )
return false;
@ -266,15 +266,15 @@ bool IGESPlugin_GUI::exportIGES( SUIT_Desktop* parent )
if ( igesOp->IsDone() )
{
transaction.commit();
transaction.commit();
}
else
{
transaction.abort();
SUIT_MessageBox::critical( parent,
tr( "GEOM_ERROR" ),
tr( "GEOM_PRP_ABORT" ) + "\n" + tr( igesOp->GetErrorCode() ) );
return false;
transaction.abort();
SUIT_MessageBox::critical( parent,
tr( "GEOM_ERROR" ),
tr( "GEOM_PRP_ABORT" ) + "\n" + tr( igesOp->GetErrorCode() ) );
return false;
}
}
catch ( const SALOME::SALOME_Exception& e )
@ -288,8 +288,8 @@ bool IGESPlugin_GUI::exportIGES( SUIT_Desktop* parent )
if ( !ok )
{
SUIT_MessageBox::warning( parent,
tr( "WRN_WARNING" ),
tr( "GEOM_WRN_NO_APPROPRIATE_SELECTION" ) );
tr( "WRN_WARNING" ),
tr( "GEOM_WRN_NO_APPROPRIATE_SELECTION" ) );
}
return ok;
}

View File

@ -236,7 +236,7 @@ void MeasureGUI_AnnotationDlg::Init()
myIsScreenFixed->setChecked( myAnnotationProperties.IsScreenFixed );
int aSubShapeTypeIndex = -1;
int aTypesCount = aTypesCount = mySubShapeTypeCombo->count();
int aTypesCount = mySubShapeTypeCombo->count();
for ( int i = 0; i < aTypesCount && aSubShapeTypeIndex < 0; i++ ) {
int aType = mySubShapeTypeCombo->itemData( i ).toInt();
if ( aType == myAnnotationProperties.ShapeType )
@ -290,7 +290,7 @@ void MeasureGUI_AnnotationDlg::Init()
myIsScreenFixed->setChecked( myAnnotationProperties.IsScreenFixed );
int aSubShapeTypeIndex = -1;
int aTypesCount = aTypesCount = mySubShapeTypeCombo->count();
int aTypesCount = mySubShapeTypeCombo->count();
for ( int i = 0; i < aTypesCount && aSubShapeTypeIndex < 0; i++ ) {
int aType = mySubShapeTypeCombo->itemData( i ).toInt();
if ( aType == myAnnotationProperties.ShapeType )

View File

@ -418,7 +418,7 @@ void MeasureGUI_CheckCompoundOfBlocksDlg::onErrorsListSelectionChanged()
myListBox2->clear();
if (aCurItem < aErrs.length()) {
if (aCurItem < (int)aErrs.length()) {
GEOM::GEOM_IBlocksOperations::BCError aErr = aErrs[aCurItem];
GEOM::ListOfLong aObjLst = aErr.incriminated;
QStringList aSubShapeList;

View File

@ -114,59 +114,59 @@ bool STLPlugin_GUI::importSTL( SUIT_Desktop* parent )
GEOM::GEOM_IOperations_var op = GeometryGUI::GetGeomGen()->GetPluginOperations( dsStudy->StudyId(), "STLPluginEngine" );
STLOpPtr stlOp = GEOM::ISTLOperations::_narrow( op );
if ( stlOp.isNull() ) return false;
QStringList fileNames = app->getOpenFileNames( SUIT_FileDlg::getLastVisitedPath().isEmpty() ? QDir::currentPath() : QString(""),
tr( "STL_FILES" ),
tr( "IMPORT_TITLE" ),
parent );
tr( "STL_FILES" ),
tr( "IMPORT_TITLE" ),
parent );
if ( fileNames.count() > 0 )
{
QStringList entryList;
QStringList errors;
foreach( QString fileName, fileNames )
{
SUIT_OverrideCursor wc;
GEOM_Operation transaction( app, stlOp.get() );
try
{
app->putInfo( tr( "GEOM_PRP_LOADING" ).arg( fileName ) );
transaction.start();
GEOM::ListOfGO_var result = stlOp->ImportSTL( fileName.toUtf8().constData() );
if ( result->length() > 0 && stlOp->IsDone() )
{
GEOM::GEOM_Object_var main = result[0];
QString publishName = GEOMBase::GetDefaultName( SUIT_Tools::file( fileName, true ) );
SALOMEDS::SObject_var so = GeometryGUI::GetGeomGen()->PublishInStudy( dsStudy,
SALOMEDS::SObject::_nil(),
main.in(),
publishName.toUtf8().constData() );
entryList.append( so->GetID() );
transaction.commit();
GEOM_Displayer( study ).Display( main.in() );
app->putInfo( tr( "GEOM_PRP_LOADING" ).arg( fileName ) );
transaction.start();
GEOM::ListOfGO_var result = stlOp->ImportSTL( fileName.toUtf8().constData() );
if ( result->length() > 0 && stlOp->IsDone() )
{
GEOM::GEOM_Object_var main = result[0];
QString publishName = GEOMBase::GetDefaultName( SUIT_Tools::file( fileName, true ) );
SALOMEDS::SObject_var so = GeometryGUI::GetGeomGen()->PublishInStudy( dsStudy,
SALOMEDS::SObject::_nil(),
main.in(),
publishName.toUtf8().constData() );
entryList.append( so->GetID() );
transaction.commit();
GEOM_Displayer( study ).Display( main.in() );
main->UnRegister();
}
else
{
transaction.abort();
errors.append( QString( "%1 : %2" ).arg( fileName ).arg( stlOp->GetErrorCode() ) );
}
}
else
{
transaction.abort();
errors.append( QString( "%1 : %2" ).arg( fileName ).arg( stlOp->GetErrorCode() ) );
}
}
catch( const SALOME::SALOME_Exception& e )
{
transaction.abort();
transaction.abort();
}
}
getGeometryGUI()->updateObjBrowser( true );
app->browseObjects( entryList );
if ( errors.count() > 0 )
{
SUIT_MessageBox::critical( parent,
tr( "GEOM_ERROR" ),
tr( "GEOM_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
tr( "GEOM_ERROR" ),
tr( "GEOM_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
}
}
return fileNames.count() > 0;
@ -207,12 +207,12 @@ bool STLPlugin_GUI::exportSTL( SUIT_Desktop* parent )
double deflection = 0.;
bool isRelative = false;
QString fileName = STLPlugin_ExportDlg::getFileName( io,
tr( "STL_FILES" ),
tr( "EXPORT_TITLE" ),
parent,
isASCII,
deflection,
isRelative );
tr( "STL_FILES" ),
tr( "EXPORT_TITLE" ),
parent,
isASCII,
deflection,
isRelative );
if ( fileName.isEmpty() )
return false;
@ -230,15 +230,15 @@ bool STLPlugin_GUI::exportSTL( SUIT_Desktop* parent )
if ( stlOp->IsDone() )
{
transaction.commit();
transaction.commit();
}
else
{
transaction.abort();
SUIT_MessageBox::critical( parent,
tr( "GEOM_ERROR" ),
tr( "GEOM_PRP_ABORT" ) + "\n" + tr( stlOp->GetErrorCode() ) );
return false;
transaction.abort();
SUIT_MessageBox::critical( parent,
tr( "GEOM_ERROR" ),
tr( "GEOM_PRP_ABORT" ) + "\n" + tr( stlOp->GetErrorCode() ) );
return false;
}
}
catch ( const SALOME::SALOME_Exception& e )
@ -252,8 +252,8 @@ bool STLPlugin_GUI::exportSTL( SUIT_Desktop* parent )
if ( !ok )
{
SUIT_MessageBox::warning( parent,
tr( "WRN_WARNING" ),
tr( "GEOM_WRN_NO_APPROPRIATE_SELECTION" ) );
tr( "WRN_WARNING" ),
tr( "GEOM_WRN_NO_APPROPRIATE_SELECTION" ) );
}
return ok;
}

View File

@ -281,17 +281,17 @@ bool XAOPlugin_ImportDlg::execute()
QStringList anEntryList;
anEntryList << addInStudy(m_mainShape, m_mainShape->GetName());
m_mainShape->UnRegister();
for (int i = 0; i < subShapes->length(); i++)
for (CORBA::ULong i = 0; i < subShapes->length(); i++)
{
addInStudy(subShapes[i].in(), subShapes[i]->GetName());
subShapes[i]->UnRegister();
}
for (int i = 0; i < groups->length(); i++)
for (CORBA::ULong i = 0; i < groups->length(); i++)
{
addInStudy(groups[i].in(), groups[i]->GetName());
groups[i]->UnRegister();
}
for (int i = 0; i < fields->length(); i++)
for (CORBA::ULong i = 0; i < fields->length(); i++)
{
addFieldInStudy(fields[i].in(), m_mainShape);
}
@ -329,7 +329,7 @@ QString XAOPlugin_ImportDlg::addFieldInStudy( GEOM::GEOM_Field_ptr theField, GEO
// add steps
GEOM::ListOfLong_var steps = theField->GetSteps();
for (int i = 0; i < steps->length(); ++i)
for (CORBA::ULong i = 0; i < steps->length(); ++i)
{
GEOM::GEOM_FieldStep_ptr step = theField->GetStep(steps[i]);
QString stepName = (tr("XAOPLUGIN_STEP") + " %1 %2").arg( step->GetID() ).arg( step->GetStamp() );