From: mpa Date: Wed, 17 Dec 2014 14:29:10 +0000 (+0300) Subject: 0022768: [EDF] Model inspector: added documentation X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=41d989fa62050272944cfd6fbc3115a5a200bde0;p=modules%2Fgeom.git 0022768: [EDF] Model inspector: added documentation --- diff --git a/doc/salome/gui/GEOM/images/inspect_object.png b/doc/salome/gui/GEOM/images/inspect_object.png new file mode 100644 index 000000000..09d90d069 Binary files /dev/null and b/doc/salome/gui/GEOM/images/inspect_object.png differ diff --git a/doc/salome/gui/GEOM/input/inspect_object_operation.doc b/doc/salome/gui/GEOM/input/inspect_object_operation.doc new file mode 100755 index 000000000..80fa31544 --- /dev/null +++ b/doc/salome/gui/GEOM/input/inspect_object_operation.doc @@ -0,0 +1,24 @@ +/*! + +\page inspect_object_operation_page Inspect Object + +This operation browses the contents of the selected shape. + +To Inspect Object in the Main Menu select Repair - > Inspect Object. + +\image html inspect_object.png + +In this dialog: +- Click on the "Arrow" button and select in the Object Browser or in the viewer a shape (compound or single solid); +- Show/hide sub-shape in the 3D viewer, by pressing “eye” icon in the first column of the tree view; +- Show all/hide all sub-shapes in the 3D viewer, by pressing “eye” icon in the first column of the tree header; +- Specify name for selected item by double-clicking on the item; + +- Show all selected items in the 3D viewer, by pressing Show Selected button; +- Show selected items in the 3D viewer and erase all currently shown objects, by pressing Show Only Selected button; +- Hide selected items from the 3D viewer, by pressing Hide Selected button; +- Publish selected shapes in the study, by pressing Publish Selected button; +- Close dialog box, by pressing Close button; +- Open context help page on this dialog box in the Help browser, by pressing Help button. + +*/ diff --git a/doc/salome/gui/GEOM/input/repairing_operations.doc b/doc/salome/gui/GEOM/input/repairing_operations.doc index b53ed10d0..6b3fd3486 100644 --- a/doc/salome/gui/GEOM/input/repairing_operations.doc +++ b/doc/salome/gui/GEOM/input/repairing_operations.doc @@ -35,6 +35,8 @@ removes selected vertices from a given wire in case if adjacent edges are C1 continuous.
  • \subpage union_faces_operation_page "Union faces" - unites on a given shape all faces sharing the same surface.
  • +
  • \subpage inspect_object_operation_page "Inspect Object" - +browses the contents of the selected shape.
  • */ diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index 0909447d0..ce75a2e66 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -7023,14 +7023,6 @@ Do you want to create new material? GEOM_INSPECT_OBJECT_NAME Name - - RENAME_COMPONENT - Change component name - - - COMPONENT_NAME - Name: - GEOMGUI_CreationInfoWdg diff --git a/src/GEOMGUI/GEOM_msg_fr.ts b/src/GEOMGUI/GEOM_msg_fr.ts index 024c2dd32..b52ab0590 100644 --- a/src/GEOMGUI/GEOM_msg_fr.ts +++ b/src/GEOMGUI/GEOM_msg_fr.ts @@ -6987,14 +6987,6 @@ Voulez-vous en créer un nouveau ? GEOM_INSPECT_OBJECT_NAME Name - - RENAME_COMPONENT - Changer le nom de la composante - - - COMPONENT_NAME - Nom: - GEOMGUI_CreationInfoWdg diff --git a/src/GEOMGUI/GEOM_msg_ja.ts b/src/GEOMGUI/GEOM_msg_ja.ts index 13c65de93..a2c2a9905 100644 --- a/src/GEOMGUI/GEOM_msg_ja.ts +++ b/src/GEOMGUI/GEOM_msg_ja.ts @@ -6964,14 +6964,6 @@ GEOM_INSPECT_OBJECT_NAME Name - - RENAME_COMPONENT - コンポーネントの名前変更 - - - COMPONENT_NAME - コンポーネント名 - GEOMGUI_CreationInfoWdg diff --git a/src/RepairGUI/RepairGUI_InspectObjectDlg.cxx b/src/RepairGUI/RepairGUI_InspectObjectDlg.cxx index 77b3588bb..0d8300bb5 100644 --- a/src/RepairGUI/RepairGUI_InspectObjectDlg.cxx +++ b/src/RepairGUI/RepairGUI_InspectObjectDlg.cxx @@ -23,6 +23,7 @@ // GEOM includes #include #include +#include // GUI includes #include @@ -46,10 +47,10 @@ #include #include #include -#include +#include //================================================================================= -// class : RepairGUI_InspectObjectDlg +// class : RepairGUI_InspectObjectDlg::TreeWidgetItem // purpose : class for "Inspect Object" tree item creation //================================================================================= class RepairGUI_InspectObjectDlg::TreeWidgetItem : public QTreeWidgetItem @@ -88,6 +89,7 @@ RepairGUI_InspectObjectDlg::TreeWidgetItem::TreeWidgetItem( QTreeWidgetItem* par myShape( shape ) { myIO = new SALOME_InteractiveObject( entry.toAscii(), "GEOM", "TEMP_IO" ); + setFlags( flags() | Qt::ItemIsEditable ); } RepairGUI_InspectObjectDlg::TreeWidgetItem::~TreeWidgetItem() @@ -115,6 +117,46 @@ Handle(SALOME_InteractiveObject) RepairGUI_InspectObjectDlg::TreeWidgetItem::get return myIO; } +//================================================================================= +// class : RepairGUI_InspectObjectDlg::Delegate +// purpose : class for "Inspect Object" tree item editing +//================================================================================= +class RepairGUI_InspectObjectDlg::Delegate : public QItemDelegate +{ +public: + Delegate( QObject* = 0 ); + ~Delegate(); + + void setEditorData( QWidget*, const QModelIndex& ) const; + void setModelData( QWidget*, QAbstractItemModel*, const QModelIndex& ) const; +}; + +RepairGUI_InspectObjectDlg::Delegate::Delegate( QObject* parent ) +: QItemDelegate( parent ) +{ +} + +RepairGUI_InspectObjectDlg::Delegate::~Delegate() +{ +} + +void RepairGUI_InspectObjectDlg::Delegate::setEditorData( QWidget* editor, + const QModelIndex& index ) const +{ + QItemDelegate::setEditorData( editor, index ); + editor->setProperty( "___name___", editor->property( "text" ) ); +} + +void RepairGUI_InspectObjectDlg::Delegate::setModelData( QWidget* editor, + QAbstractItemModel* model, + const QModelIndex& index ) const +{ + QString aNewName = editor->property( "text" ).toString(); + if( aNewName.trimmed().isEmpty() ) + editor->setProperty( "text", editor->property( "___name___" ) ); + QItemDelegate::setModelData( editor, model, index ); +} + //================================================================================= // class : RepairGUI_InspectObjectDlg() // purpose : Constructs a RepairGUI_InspectObjectDlg which is a child of 'parent'. @@ -180,6 +222,9 @@ RepairGUI_InspectObjectDlg::RepairGUI_InspectObjectDlg( SUIT_Desktop* parent ) myTreeObjects->header()->setMovable( false ); myTreeObjects->header()->setResizeMode( 1, QHeaderView::ResizeToContents ); myTreeObjects->setSelectionMode( QAbstractItemView::ExtendedSelection ); + myTreeObjects->setEditTriggers( QAbstractItemView::DoubleClicked | QAbstractItemView::EditKeyPressed ); + // set custom item delegate + myTreeObjects->setItemDelegate( new Delegate( myTreeObjects ) ); /********************** Buttons **********************/ @@ -217,8 +262,8 @@ RepairGUI_InspectObjectDlg::RepairGUI_InspectObjectDlg( SUIT_Desktop* parent ) connect( myTreeObjects, SIGNAL( itemClicked( QTreeWidgetItem*, int ) ), this, SLOT( onItemClicked( QTreeWidgetItem*, int ) ) ); - connect( myTreeObjects, SIGNAL( itemDoubleClicked( QTreeWidgetItem*, int ) ), - this, SLOT( onItemDoubleClicked( QTreeWidgetItem*, int ) ) ); + connect( myTreeObjects, SIGNAL( itemChanged( QTreeWidgetItem*, int ) ), + this, SLOT( onItemChanged( QTreeWidgetItem*, int ) ) ); connect( myTreeObjects, SIGNAL( itemExpanded ( QTreeWidgetItem* ) ), this, SLOT( onItemExpanded( QTreeWidgetItem* ) ) ); connect( myTreeObjects, SIGNAL( itemSelectionChanged() ), @@ -446,20 +491,22 @@ void RepairGUI_InspectObjectDlg::onItemClicked( QTreeWidgetItem* theItem, int th } //================================================================================= -// function : onItemDoubleClicked() -// purpose : called when tree item was double clicked +// function : onItemChanged() +// purpose : called when tree item was changed //================================================================================= -void RepairGUI_InspectObjectDlg::onItemDoubleClicked( QTreeWidgetItem* theItem, int theColumn ) +void RepairGUI_InspectObjectDlg::onItemChanged( QTreeWidgetItem* theItem, int theColumn ) { - if( theColumn!= 0 || !( theItem->flags() & Qt::ItemIsSelectable ) ) + if( theColumn!= 0 || !( theItem->flags() & Qt::ItemIsEditable ) ) return; - bool bOk; - QString label = QInputDialog::getText( this, RepairGUI_InspectObjectDlg::tr( "RENAME_COMPONENT" ), - RepairGUI_InspectObjectDlg::tr ( "COMPONENT_NAME" ), QLineEdit::Normal, - theItem->text(0), &bOk ); - if ( bOk && !label.isEmpty() ) - theItem->setText( 0, label ); + // rename the same items in the tree + QTreeWidgetItemIterator it( myTreeObjects ); + while(*it) { + TreeWidgetItem* anItem = dynamic_cast(*it); + if( anItem->getShape().IsSame( dynamic_cast( theItem )->getShape() ) ) + anItem->setText( 0, theItem->text(0) ); + ++it; + } } //================================================================================= @@ -616,6 +663,39 @@ void RepairGUI_InspectObjectDlg::clickOnHide() //================================================================================= void RepairGUI_InspectObjectDlg::clickOnPublish() { + _PTR(Study) studyDS = dynamic_cast( myApp->activeStudy() )->studyDS(); + + // find main object + TreeWidgetItem* aMainItem = dynamic_cast( myTreeObjects->topLevelItem(0) ); + GEOM::GEOM_Object_var aMainObject = GEOMBase::ConvertIOinGEOMObject( aMainItem->getIO() ); + + // find unique indices of selected objects + QList selectedItems = myTreeObjects->selectedItems(); + QMap< int, QString > anIndices; + GEOM::ListOfLong_var anArray = new GEOM::ListOfLong; + anArray->length( selectedItems.size() ); + int j = 0; + for( int i = 0; i < selectedItems.size(); i++ ) { + TreeWidgetItem* anItem = dynamic_cast( selectedItems.at(i) ); + int anIndex = GEOMBase::GetIndex( anItem->getShape(), aMainItem->getShape() ); + if( anIndices.find( anIndex ) == anIndices.end() && + anItem != aMainItem ) { + anIndices[ anIndex ] = anItem->text(0); + anArray[j++] = anIndex; + } + } + anArray->length(j); + + // get selected sub-shapes + GEOM::GEOM_IShapesOperations_var anOper = getGeomEngine()->GetIShapesOperations( getStudyId() ); + GEOM::ListOfGO_var aList = anOper->MakeSubShapes( aMainObject, anArray ); + + // publish sub-shapes + for( int i = 0; i < aList->length(); i++ ) + GeometryGUI::GetGeomGen()->AddInStudy( GeometryGUI::ClientStudyToStudy( studyDS ), aList[i], + anIndices.values().at(i).toStdString().c_str(), aMainObject ); + + updateObjBrowser(); } //================================================================================= @@ -624,5 +704,5 @@ void RepairGUI_InspectObjectDlg::clickOnPublish() //================================================================================= void RepairGUI_InspectObjectDlg::clickOnHelp() { - myApp->onHelpContextModule( "GEOM", "inspect_object_page.html" ); + myApp->onHelpContextModule( "GEOM", "inspect_object_operation_page.html" ); } diff --git a/src/RepairGUI/RepairGUI_InspectObjectDlg.h b/src/RepairGUI/RepairGUI_InspectObjectDlg.h index bf5280105..43cb69c61 100644 --- a/src/RepairGUI/RepairGUI_InspectObjectDlg.h +++ b/src/RepairGUI/RepairGUI_InspectObjectDlg.h @@ -27,12 +27,14 @@ #include #include #include +#include class RepairGUI_InspectObjectDlg : public QDialog, public GEOMBase_Helper { Q_OBJECT class TreeWidgetItem; + class Delegate; public: RepairGUI_InspectObjectDlg( SUIT_Desktop* ); @@ -42,6 +44,7 @@ private slots: void onEditMainShape(); void onItemClicked( QTreeWidgetItem*, int ); + void onItemChanged( QTreeWidgetItem*, int ); void onItemSelectionChanged(); void onItemExpanded( QTreeWidgetItem* ); void onHeaderClicked( int );