2015-02-10 14:25:19 +05:00
|
|
|
// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
|
2004-12-01 15:39:14 +05:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
|
|
|
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
2004-12-01 15:39:14 +05:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
2014-02-18 12:44:41 +06:00
|
|
|
// version 2.1 of the License, or (at your option) any later version.
|
2004-12-01 15:39:14 +05:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
2009-02-13 17:16:39 +05:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2009-02-13 17:16:39 +05:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
2014-02-18 12:44:41 +06:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
|
|
|
|
// GEOM GEOMGUI : GUI for Geometry component
|
|
|
|
// File : GroupGUI_GroupDlg.cxx
|
|
|
|
// Author : Sergey ANIKIN, Open CASCADE S.A.S. (sergey.anikin@opencascade.com)
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
#include "GroupGUI_GroupDlg.h"
|
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
#include <DlgRef.h>
|
|
|
|
#include <GEOMBase.h>
|
|
|
|
#include <GeometryGUI.h>
|
|
|
|
#include <GEOM_Displayer.h>
|
2014-11-12 21:40:11 +05:00
|
|
|
#include <GEOMUtils.hxx>
|
2015-06-11 18:03:47 +05:00
|
|
|
#ifndef DISABLE_PLOT2DVIEWER
|
2015-04-23 13:42:06 +05:00
|
|
|
#include <MeasureGUI_ShapeStatisticsDlg.h>
|
2015-06-11 18:03:47 +05:00
|
|
|
#endif
|
2012-08-09 13:58:02 +06:00
|
|
|
|
|
|
|
#include <SalomeApp_Application.h>
|
|
|
|
#include <SalomeApp_Study.h>
|
2013-02-12 17:35:16 +06:00
|
|
|
#include <SalomeApp_Tools.h>
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
#include <LightApp_SelectionMgr.h>
|
2015-02-09 21:50:36 +05:00
|
|
|
#include "utilities.h"
|
2012-08-09 13:58:02 +06:00
|
|
|
|
|
|
|
#include <OCCViewer_ViewModel.h>
|
|
|
|
#include <OCCViewer_ViewManager.h>
|
|
|
|
#include <SVTK_ViewModel.h>
|
|
|
|
#include <SALOME_Prs.h>
|
2014-10-21 19:45:02 +06:00
|
|
|
#include <SALOME_ListIO.hxx>
|
2014-11-19 20:45:44 +05:00
|
|
|
#include "utilities.h"
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
#include <SUIT_Desktop.h>
|
2013-06-10 14:13:27 +06:00
|
|
|
#include <SUIT_MessageBox.h>
|
2009-02-13 17:16:39 +05:00
|
|
|
#include <SUIT_OverrideCursor.h>
|
2013-06-10 14:13:27 +06:00
|
|
|
#include <SUIT_ResourceMgr.h>
|
2009-02-13 17:16:39 +05:00
|
|
|
#include <SUIT_Session.h>
|
2012-08-09 13:58:02 +06:00
|
|
|
#include <SUIT_ViewWindow.h>
|
|
|
|
#include <SUIT_ViewManager.h>
|
2009-02-13 17:16:39 +05:00
|
|
|
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QListWidget>
|
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QMap>
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
#include <AIS_ListOfInteractive.hxx>
|
|
|
|
#include <AIS_ListIteratorOfListOfInteractive.hxx>
|
|
|
|
|
|
|
|
#include <TopExp.hxx>
|
|
|
|
#include <TopExp_Explorer.hxx>
|
|
|
|
#include <TopTools_IndexedMapOfShape.hxx>
|
2004-12-01 15:39:14 +05:00
|
|
|
#include <TColStd_IndexedMapOfInteger.hxx>
|
|
|
|
#include <TColStd_MapOfInteger.hxx>
|
2009-02-13 17:16:39 +05:00
|
|
|
#include <TColStd_DataMapIteratorOfDataMapOfIntegerInteger.hxx>
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
#include <GEOMImpl_Types.hxx>
|
|
|
|
|
2013-02-12 17:35:16 +06:00
|
|
|
#define GROUP_IDLST_COLOR Qt::blue // Specific color for the IDs of subShapes in the dialog box
|
|
|
|
#define GROUP_NEWIDLST_COLOR Qt::red // Specific color for the new IDs of subShapes in the dialog box
|
|
|
|
|
2014-11-12 21:40:11 +05:00
|
|
|
namespace {
|
|
|
|
enum { ALL_SUBSHAPES = 0, GET_IN_PLACE, SUBSHAPES_OF_SHAPE2, SUBSHAPES_OF_INVISIBLE_SHAPE2 };
|
|
|
|
enum { Filter_LT, Filter_LE, Filter_GT, Filter_GE };
|
|
|
|
}
|
2005-06-02 13:17:09 +06:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
GroupGUI_GroupDlg::GroupGUI_GroupDlg (Mode mode, GeometryGUI* theGeometryGUI, QWidget* parent)
|
|
|
|
: GEOMBase_Skeleton(theGeometryGUI, parent, false),
|
|
|
|
myMode(mode),
|
|
|
|
myBusy(false),
|
|
|
|
myIsShapeType(false),
|
2014-04-29 12:59:48 +06:00
|
|
|
myIsHiddenMain(false),
|
2015-11-06 15:15:49 +05:00
|
|
|
myWasHiddenMain(true),
|
|
|
|
myIsAccept(false)
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
2006-02-07 20:58:35 +05:00
|
|
|
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
|
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
QPixmap image0 (resMgr->loadPixmap("GEOM", tr("ICON_OBJBROWSER_VERTEX")));
|
|
|
|
QPixmap image1 (resMgr->loadPixmap("GEOM", tr("ICON_OBJBROWSER_EDGE")));
|
|
|
|
QPixmap image2 (resMgr->loadPixmap("GEOM", tr("ICON_OBJBROWSER_FACE")));
|
|
|
|
QPixmap image3 (resMgr->loadPixmap("GEOM", tr("ICON_OBJBROWSER_SOLID")));
|
|
|
|
QPixmap iconSelect (resMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
setWindowTitle(myMode == CreateGroup ? tr("CREATE_GROUP_TITLE") : tr("EDIT_GROUP_TITLE"));
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
// Shape type button group
|
2012-08-09 13:58:02 +06:00
|
|
|
mainFrame()->GroupConstructors->setEnabled(myMode == CreateGroup);
|
|
|
|
mainFrame()->GroupConstructors->setTitle(tr("SHAPE_TYPE"));
|
|
|
|
mainFrame()->RadioButton1->setIcon(image0);
|
|
|
|
mainFrame()->RadioButton2->setIcon(image1);
|
|
|
|
mainFrame()->RadioButton3->setIcon(image2);
|
|
|
|
mainFrame()->RadioButton4->setIcon(image3);
|
2009-02-13 17:16:39 +05:00
|
|
|
mainFrame()->RadioButton4->show();
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
// Group name
|
2012-08-09 13:58:02 +06:00
|
|
|
mainFrame()->GroupBoxName->setTitle(tr("GROUP_NAME"));
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
// Main shape and sub-shapes
|
2012-08-09 13:58:02 +06:00
|
|
|
QGroupBox* GroupMedium = new QGroupBox(tr("MAIN_SUB_SHAPES"), centralWidget());
|
|
|
|
QGridLayout* aMedLayout = new QGridLayout(GroupMedium);
|
|
|
|
aMedLayout->setMargin(9);
|
|
|
|
aMedLayout->setSpacing(6);
|
|
|
|
|
|
|
|
QLabel* aMainLabel = new QLabel(tr("MAIN_SHAPE"), GroupMedium);
|
|
|
|
|
|
|
|
mySelBtn = new QPushButton(GroupMedium);
|
|
|
|
mySelBtn->setIcon(iconSelect);
|
|
|
|
mySelBtn->setEnabled(myMode == CreateGroup);
|
|
|
|
|
|
|
|
myMainName = new QLineEdit(GroupMedium);
|
|
|
|
myMainName->setReadOnly(true);
|
|
|
|
myMainName->setEnabled(myMode == CreateGroup);
|
|
|
|
|
|
|
|
myRestrictGroupBox = new QGroupBox(tr("SHAPE_SEL_RESTR"), GroupMedium);
|
|
|
|
myRestrictGroup = new QButtonGroup(myRestrictGroupBox);
|
|
|
|
QRadioButton* allSubs = new QRadioButton(tr("NO_RESTR") , myRestrictGroupBox);
|
|
|
|
QRadioButton* inPlaceSubs = new QRadioButton(tr("GEOM_PARTS_OF_SHAPE2"), myRestrictGroupBox);
|
|
|
|
QRadioButton* shape2Subs = new QRadioButton(tr("SUBSHAPES_OF_SHAPE2") , myRestrictGroupBox);
|
|
|
|
QGridLayout* aRestrictLayout = new QGridLayout(myRestrictGroupBox);
|
|
|
|
|
|
|
|
QLabel* aSecondLabel = new QLabel(tr("SECOND_SHAPE"), myRestrictGroupBox);
|
|
|
|
mySelBtn2 = new QPushButton(myRestrictGroupBox);
|
|
|
|
mySelBtn2->setIcon(iconSelect);
|
|
|
|
mySelBtn2->setEnabled(false);
|
|
|
|
myShape2Name = new QLineEdit(myRestrictGroupBox);
|
|
|
|
myShape2Name->setReadOnly(true);
|
|
|
|
myShape2Name->setEnabled(false);
|
|
|
|
|
|
|
|
aRestrictLayout->setMargin(9);
|
|
|
|
aRestrictLayout->setSpacing(6);
|
|
|
|
aRestrictLayout->addWidget(allSubs, 0, 0, 1, 3);
|
|
|
|
aRestrictLayout->addWidget(inPlaceSubs, 1, 0, 1, 3);
|
|
|
|
aRestrictLayout->addWidget(shape2Subs, 2, 0, 1, 3);
|
|
|
|
aRestrictLayout->addWidget(aSecondLabel, 3, 0);
|
|
|
|
aRestrictLayout->addWidget(mySelBtn2, 3, 1);
|
|
|
|
aRestrictLayout->addWidget(myShape2Name, 3, 2);
|
|
|
|
myRestrictGroup->addButton(allSubs, ALL_SUBSHAPES);
|
|
|
|
myRestrictGroup->addButton(inPlaceSubs, GET_IN_PLACE);
|
|
|
|
myRestrictGroup->addButton(shape2Subs, SUBSHAPES_OF_SHAPE2);
|
|
|
|
myRestrictGroupBox->setEnabled(!CORBA::is_nil(myMainObj));
|
|
|
|
allSubs->setChecked(true);
|
|
|
|
|
|
|
|
myShowOnlyBtn = new QPushButton(tr("SHOW_ONLY_SELECTED"), GroupMedium);
|
|
|
|
myHideSelBtn = new QPushButton(tr("HIDE_SELECTED"), GroupMedium);
|
|
|
|
myShowAllBtn = new QPushButton(tr("SHOW_ALL_SUB_SHAPES"), GroupMedium);
|
|
|
|
|
|
|
|
mySelAllBtn = new QPushButton(tr("SELECT_ALL"), GroupMedium);
|
|
|
|
myAddBtn = new QPushButton(tr("ADD"), GroupMedium);
|
|
|
|
myRemBtn = new QPushButton(tr("REMOVE"), GroupMedium);
|
|
|
|
|
|
|
|
myIdList = new QListWidget(GroupMedium);
|
|
|
|
|
|
|
|
myIdList->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
|
|
|
myIdList->setFlow(QListView::TopToBottom);
|
|
|
|
myIdList->setWrapping(true);
|
|
|
|
|
|
|
|
aMedLayout->addWidget(aMainLabel, 0, 0);
|
|
|
|
aMedLayout->addWidget(mySelBtn, 0, 1);
|
|
|
|
aMedLayout->addWidget(myMainName, 0, 2, 1, 2);
|
|
|
|
aMedLayout->addWidget(myRestrictGroupBox, 1, 0, 4, 3);
|
|
|
|
|
|
|
|
aMedLayout->addWidget(myShowOnlyBtn, 1, 3);
|
|
|
|
aMedLayout->addWidget(myHideSelBtn, 2, 3);
|
|
|
|
aMedLayout->addWidget(myShowAllBtn, 3, 3);
|
|
|
|
|
|
|
|
aMedLayout->addWidget(myIdList, 5, 0, 4, 3);
|
|
|
|
aMedLayout->addWidget(mySelAllBtn, 5, 3);
|
|
|
|
aMedLayout->addWidget(myAddBtn, 6, 3);
|
|
|
|
aMedLayout->addWidget(myRemBtn, 7, 3);
|
|
|
|
|
|
|
|
aMedLayout->setColumnStretch(2, 5);
|
|
|
|
aMedLayout->setRowStretch(5, 5);
|
|
|
|
aMedLayout->setRowStretch(8, 5);
|
|
|
|
|
2014-11-12 21:40:11 +05:00
|
|
|
//filter group
|
|
|
|
|
|
|
|
myFilterGrp = new QGroupBox(tr("GEOM_FILTER"), centralWidget());
|
|
|
|
myLessFilterCheck = new QCheckBox(myFilterGrp);
|
|
|
|
myLessFilterCombo = new QComboBox(myFilterGrp);
|
|
|
|
myLessFilterCombo->addItem( tr("GEOM_LESS_THAN"), Filter_LT );
|
|
|
|
myLessFilterCombo->addItem( tr("GEOM_LESSOREQUAL_THAN"), Filter_LE );
|
|
|
|
myGreaterFilterCheck = new QCheckBox(myFilterGrp);
|
|
|
|
myGreaterFilterCombo = new QComboBox(myFilterGrp);
|
|
|
|
myGreaterFilterCombo->addItem( tr("GEOM_GREAT_THAN"), Filter_GT );
|
|
|
|
myGreaterFilterCombo->addItem( tr("GEOM_GREATOREQUAL_THAN"), Filter_GE );
|
|
|
|
myLessFilterSpin = new SalomeApp_DoubleSpinBox(myFilterGrp);
|
|
|
|
myGreaterFilterSpin = new SalomeApp_DoubleSpinBox(myFilterGrp);
|
|
|
|
myApplyFilterButton = new QPushButton(tr("GEOM_BUT_APPLY"), myFilterGrp);
|
2015-06-11 18:03:47 +05:00
|
|
|
#ifndef DISABLE_PLOT2DVIEWER
|
2015-04-23 13:42:06 +05:00
|
|
|
myPlotDistributionButton = new QPushButton(tr("GEOM_PLOT_DISTRIBUTION"), myFilterGrp);
|
2015-06-11 18:03:47 +05:00
|
|
|
#endif
|
2014-11-12 21:40:11 +05:00
|
|
|
|
|
|
|
QGridLayout* filterLayout = new QGridLayout(myFilterGrp);
|
|
|
|
filterLayout->addWidget(myLessFilterCheck, 0, 0);
|
|
|
|
filterLayout->addWidget(myLessFilterCombo, 0, 1);
|
|
|
|
filterLayout->addWidget(myLessFilterSpin, 0, 2);
|
|
|
|
filterLayout->addWidget(myGreaterFilterCheck, 1, 0);
|
|
|
|
filterLayout->addWidget(myGreaterFilterCombo, 1, 1);
|
|
|
|
filterLayout->addWidget(myGreaterFilterSpin, 1, 2);
|
|
|
|
filterLayout->addWidget(myApplyFilterButton, 0, 3);
|
2015-06-11 18:03:47 +05:00
|
|
|
#ifndef DISABLE_PLOT2DVIEWER
|
2015-04-23 13:42:06 +05:00
|
|
|
filterLayout->addWidget(myPlotDistributionButton, 1, 3);
|
2015-06-11 18:03:47 +05:00
|
|
|
#endif
|
2014-11-12 21:40:11 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
QVBoxLayout* layout = new QVBoxLayout(centralWidget());
|
|
|
|
layout->setMargin(0); layout->setSpacing(6);
|
|
|
|
layout->addWidget(GroupMedium);
|
2014-11-12 21:40:11 +05:00
|
|
|
layout->addWidget(myFilterGrp);
|
2012-08-09 13:58:02 +06:00
|
|
|
|
|
|
|
setHelpFileName("work_with_groups_page.html");
|
2006-05-06 14:44:32 +06:00
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
Init();
|
2012-08-09 13:58:02 +06:00
|
|
|
updateState();
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
GroupGUI_GroupDlg::~GroupGUI_GroupDlg()
|
|
|
|
{
|
2013-02-12 17:35:16 +06:00
|
|
|
GEOM_Displayer* aDisplayer = getDisplayer();
|
2015-03-04 18:05:30 +05:00
|
|
|
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
|
|
|
|
bool isHideObjects = resMgr->booleanValue( "Geometry", "hide_input_object", true);
|
2015-11-06 15:15:49 +05:00
|
|
|
if (myWasHiddenMain || ( isHideObjects && myIsAccept ) ) {
|
2014-04-29 12:59:48 +06:00
|
|
|
myIsHiddenMain = true;
|
2015-03-04 18:05:30 +05:00
|
|
|
}
|
2015-11-06 15:15:49 +05:00
|
|
|
else {
|
2012-08-09 13:58:02 +06:00
|
|
|
aDisplayer->Display(myMainObj);
|
|
|
|
myIsHiddenMain = false;
|
|
|
|
}
|
2013-02-12 17:35:16 +06:00
|
|
|
aDisplayer->Display(myGroup);
|
|
|
|
myDmMode = -1;
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : Init()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2005-06-02 13:17:09 +06:00
|
|
|
void GroupGUI_GroupDlg::Init()
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
2014-11-12 21:40:11 +05:00
|
|
|
// Get setting of step value from file configuration
|
|
|
|
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
|
|
|
|
double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
|
|
|
|
|
|
|
|
// min, max, step and decimals for spin boxes
|
|
|
|
initSpinBox(myLessFilterSpin, 0., COORD_MAX, step, "length_precision" );
|
|
|
|
initSpinBox(myGreaterFilterSpin, 0., COORD_MAX, step, "length_precision" );
|
|
|
|
myLessFilterSpin->setValue( 0. );
|
|
|
|
myGreaterFilterSpin->setValue( 0. );
|
|
|
|
|
2013-02-12 17:35:16 +06:00
|
|
|
myDmMode = -1;
|
2009-02-13 17:16:39 +05:00
|
|
|
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
|
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
//unset shape type to avoid preparation of selection before exact user shape type selection
|
|
|
|
unsetConstructorId();
|
|
|
|
myIsShapeType = false;
|
|
|
|
|
|
|
|
if (myMode == CreateGroup) {
|
|
|
|
initName(tr("GROUP_PREFIX"));
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
// Get ready for main shape selection
|
|
|
|
myEditCurrentArgument = myMainName;
|
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
|
|
|
|
connect(mySelBtn, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
|
|
|
|
connect(mySelBtn2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
2009-02-13 17:16:39 +05:00
|
|
|
else if (myMode == EditGroup) {
|
|
|
|
SALOME_ListIO aSelList;
|
|
|
|
aSelMgr->selectedObjects(aSelList);
|
2006-02-07 20:58:35 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
if (aSelList.Extent()) {
|
|
|
|
GEOM::GEOM_Object_var anObj =
|
2012-08-09 13:58:02 +06:00
|
|
|
GEOMBase::ConvertIOinGEOMObject(aSelList.First());
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
if (!CORBA::is_nil(anObj) && anObj->GetType() == GEOM_GROUP) {
|
2009-02-13 17:16:39 +05:00
|
|
|
myGroup = anObj;
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
mainFrame()->ResultName->setText(GEOMBase::GetName(myGroup));
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
GEOM::GEOM_IGroupOperations_var anOper = GEOM::GEOM_IGroupOperations::_narrow(getOperation());
|
|
|
|
myMainObj = anOper->GetMainShape(myGroup);
|
2014-04-29 12:59:48 +06:00
|
|
|
if (!CORBA::is_nil(myMainObj)) {
|
2012-08-09 13:58:02 +06:00
|
|
|
myMainName->setText(GEOMBase::GetName(myMainObj));
|
2014-04-29 12:59:48 +06:00
|
|
|
SALOME_View* view = GEOM_Displayer::GetActiveView();
|
|
|
|
if (view) {
|
|
|
|
CORBA::String_var aMainEntry = myMainObj->GetStudyEntry();
|
|
|
|
Handle(SALOME_InteractiveObject) io =
|
|
|
|
new SALOME_InteractiveObject (aMainEntry.in(), "GEOM", "TEMP_IO");
|
|
|
|
if (view->isVisible(io)) myWasHiddenMain = false;
|
|
|
|
}
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
setShapeType((TopAbs_ShapeEnum)anOper->GetType(myGroup));
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
GEOM::ListOfLong_var aCurrList = anOper->GetObjects(myGroup);
|
2013-02-12 17:35:16 +06:00
|
|
|
for (int i = 0, n = aCurrList->length(); i < n; i++) {
|
|
|
|
QListWidgetItem* itm = new QListWidgetItem( QString( "%1" ).arg( aCurrList[ i ] ) );
|
|
|
|
myGroupIdList.append( aCurrList[ i ] );
|
|
|
|
itm->setTextColor( QColor( GROUP_IDLST_COLOR ) );
|
|
|
|
myIdList->addItem( itm );
|
|
|
|
}
|
2009-02-13 17:16:39 +05:00
|
|
|
myEditCurrentArgument = 0;
|
|
|
|
}
|
2012-08-09 13:58:02 +06:00
|
|
|
connect(mySelBtn2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
connect(aSelMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
|
2006-02-07 20:58:35 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
|
|
|
|
connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
|
2006-02-07 20:58:35 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
connect(myRestrictGroup, SIGNAL(buttonClicked(int)), this, SLOT(SetEditCurrentArgument()));
|
|
|
|
connect(mySelAllBtn, SIGNAL(clicked()), this, SLOT(selectAllSubShapes()));
|
|
|
|
connect(myAddBtn, SIGNAL(clicked()), this, SLOT(add()));
|
|
|
|
connect(myRemBtn, SIGNAL(clicked()), this, SLOT(remove()));
|
|
|
|
connect(myShowOnlyBtn, SIGNAL(clicked()), this, SLOT(showOnlySelected()));
|
|
|
|
connect(myHideSelBtn, SIGNAL(clicked()), this, SLOT(showOnlySelected()));
|
|
|
|
connect(myShowAllBtn, SIGNAL(clicked()), this, SLOT(showOnlySelected()));
|
|
|
|
connect(myIdList, SIGNAL(itemSelectionChanged()), this, SLOT(selectionChanged()));
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2014-11-12 21:40:11 +05:00
|
|
|
connect(myApplyFilterButton, SIGNAL(clicked()), this, SLOT(ClickOnOkFilter()));
|
2015-06-11 18:03:47 +05:00
|
|
|
#ifndef DISABLE_PLOT2DVIEWER
|
2015-04-23 13:42:06 +05:00
|
|
|
connect(myPlotDistributionButton, SIGNAL(clicked()), this, SLOT(ClickOnPlot()));
|
2015-06-11 18:03:47 +05:00
|
|
|
#endif
|
2014-11-12 21:40:11 +05:00
|
|
|
connect(myLessFilterCheck, SIGNAL(stateChanged(int)), this, SLOT(MeasureToggled()));
|
|
|
|
connect(myGreaterFilterCheck, SIGNAL(stateChanged(int)), this, SLOT(MeasureToggled()));
|
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
setInPlaceObj(GEOM::GEOM_Object::_nil());
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
myBusy = true; // just activate but do not select in the list
|
2004-12-01 15:39:14 +05:00
|
|
|
activateSelection();
|
2009-02-13 17:16:39 +05:00
|
|
|
myBusy = false;
|
2014-11-12 21:40:11 +05:00
|
|
|
MeasureToggled();
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : enterEvent()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2012-08-09 13:58:02 +06:00
|
|
|
void GroupGUI_GroupDlg::enterEvent(QEvent* e)
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
2012-08-09 13:58:02 +06:00
|
|
|
if (!buttonCancel()->isEnabled())
|
2009-02-13 17:16:39 +05:00
|
|
|
ActivateThisDialog();
|
|
|
|
}
|
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
//=================================================================================
|
2009-02-13 17:16:39 +05:00
|
|
|
//function : closeEvent
|
|
|
|
//purpose : remove temporary geom object
|
2012-08-09 13:58:02 +06:00
|
|
|
//=================================================================================
|
|
|
|
void GroupGUI_GroupDlg::closeEvent(QCloseEvent* e)
|
2009-02-13 17:16:39 +05:00
|
|
|
{
|
2012-08-09 13:58:02 +06:00
|
|
|
setInPlaceObj(GEOM::GEOM_Object::_nil());
|
|
|
|
erasePreview(true);
|
2009-02-13 17:16:39 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
GEOMBase_Skeleton::closeEvent(e);
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ClickOnOk()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void GroupGUI_GroupDlg::ClickOnOk()
|
|
|
|
{
|
2012-08-09 13:58:02 +06:00
|
|
|
setIsApplyAndClose(true);
|
|
|
|
if (ClickOnApply())
|
2004-12-01 15:39:14 +05:00
|
|
|
ClickOnCancel();
|
2012-08-09 13:58:02 +06:00
|
|
|
setIsApplyAndClose(false);
|
2014-04-25 18:29:15 +06:00
|
|
|
getDisplayer()->UnsetDisplayMode();
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ClickOnApply()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
bool GroupGUI_GroupDlg::ClickOnApply()
|
|
|
|
{
|
2013-02-12 17:35:16 +06:00
|
|
|
if(!isApplyAndClose()) {
|
2012-08-09 13:58:02 +06:00
|
|
|
setIsDisableBrowsing( true );
|
2013-02-12 17:35:16 +06:00
|
|
|
setIsDisplayResult( false );
|
|
|
|
}
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2015-11-06 15:15:49 +05:00
|
|
|
myIsAccept = onAccept(myMode == CreateGroup, true, isApplyAndClose());
|
|
|
|
if (!myIsAccept)
|
2004-12-01 15:39:14 +05:00
|
|
|
return false;
|
|
|
|
|
2013-02-12 17:35:16 +06:00
|
|
|
if(!isApplyAndClose()) {
|
2012-08-09 13:58:02 +06:00
|
|
|
setIsDisableBrowsing( false );
|
2013-02-12 17:35:16 +06:00
|
|
|
setIsDisplayResult( true );
|
|
|
|
}
|
2012-08-09 13:58:02 +06:00
|
|
|
|
|
|
|
if (myMode == CreateGroup)
|
|
|
|
{
|
|
|
|
initName();
|
|
|
|
myIdList->clear();
|
|
|
|
ConstructorsClicked(getConstructorId());
|
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
else
|
2013-02-12 17:35:16 +06:00
|
|
|
{
|
|
|
|
int n = myIdList->count();
|
|
|
|
myGroupIdList.clear();
|
|
|
|
if (n > 0)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
|
|
QListWidgetItem* anItem = myIdList->item( i );
|
|
|
|
myGroupIdList.append( anItem->text().toInt() );
|
|
|
|
anItem->setTextColor( GROUP_IDLST_COLOR );
|
|
|
|
}
|
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
activateSelection();
|
2013-02-12 17:35:16 +06:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ActivateThisDialog()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void GroupGUI_GroupDlg::ActivateThisDialog()
|
|
|
|
{
|
|
|
|
GEOMBase_Skeleton::ActivateThisDialog();
|
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
|
|
|
|
this, SLOT(SelectionIntoArgument()));
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
activateSelection();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : SetEditCurrentArgument()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void GroupGUI_GroupDlg::SetEditCurrentArgument()
|
|
|
|
{
|
2015-10-07 12:31:33 +05:00
|
|
|
QPushButton* send = qobject_cast<QPushButton*>( sender() );
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
if (send == mySelBtn) {
|
2004-12-01 15:39:14 +05:00
|
|
|
myEditCurrentArgument = myMainName;
|
2012-08-09 13:58:02 +06:00
|
|
|
myShape2Name->setText("");
|
2015-04-29 18:44:24 +05:00
|
|
|
mySelBtn->setDown(true);
|
|
|
|
mySelBtn2->setDown(false);
|
2009-02-13 17:16:39 +05:00
|
|
|
}
|
2012-08-09 13:58:02 +06:00
|
|
|
else if (send == mySelBtn2 || sender() == myRestrictGroup) {
|
|
|
|
setInPlaceObj(GEOM::GEOM_Object::_nil());
|
|
|
|
myShape2Name->setText("");
|
2015-04-29 18:44:24 +05:00
|
|
|
if ( send == mySelBtn2 ) {
|
|
|
|
mySelBtn2->setDown(true);
|
|
|
|
mySelBtn->setDown(false);
|
|
|
|
}
|
|
|
|
if (subSelectionWay() != ALL_SUBSHAPES) {
|
2009-02-13 17:16:39 +05:00
|
|
|
myEditCurrentArgument = myShape2Name;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
myEditCurrentArgument = 0;
|
|
|
|
}
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2015-04-29 18:44:24 +05:00
|
|
|
// activateSelection();
|
|
|
|
if(myEditCurrentArgument) {
|
|
|
|
myEditCurrentArgument->setFocus();
|
2015-10-07 12:31:33 +05:00
|
|
|
if ( send )
|
|
|
|
send->setDown(true);
|
2015-04-29 18:44:24 +05:00
|
|
|
}
|
2006-02-07 20:58:35 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
updateState();
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
//=================================================================================
|
|
|
|
// function : onGetInPlace()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void GroupGUI_GroupDlg::onGetInPlace()
|
|
|
|
{
|
2012-08-09 13:58:02 +06:00
|
|
|
setInPlaceObj(GEOM::GEOM_Object::_nil());
|
|
|
|
myEditCurrentArgument->setText("");
|
2009-02-13 17:16:39 +05:00
|
|
|
|
|
|
|
bool isBlocked = myIdList->signalsBlocked();
|
2012-08-09 13:58:02 +06:00
|
|
|
myIdList->blockSignals(true);
|
2009-02-13 17:16:39 +05:00
|
|
|
myIdList->clearSelection();
|
2012-08-09 13:58:02 +06:00
|
|
|
myIdList->blockSignals(isBlocked);
|
2009-02-13 17:16:39 +05:00
|
|
|
|
|
|
|
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
|
|
|
|
SALOME_ListIO aSelList;
|
|
|
|
aSelMgr->selectedObjects(aSelList);
|
|
|
|
|
|
|
|
if (aSelList.Extent() != 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
GEOM::GEOM_Object_var anObj =
|
2012-08-09 13:58:02 +06:00
|
|
|
GEOMBase::ConvertIOinGEOMObject(aSelList.First());
|
|
|
|
if (GEOMBase::IsShape(anObj)) {
|
2009-02-13 17:16:39 +05:00
|
|
|
if (!anObj->_is_equivalent(myMainObj) && !anObj->_is_equivalent(myGroup)) {
|
|
|
|
SUIT_OverrideCursor wc;
|
|
|
|
myEditCurrentArgument->setText(GEOMBase::GetName(anObj));
|
|
|
|
GEOM::GEOM_IShapesOperations_var aShapesOp =
|
|
|
|
getGeomEngine()->GetIShapesOperations(getStudyId());
|
2012-08-09 13:58:02 +06:00
|
|
|
if (subSelectionWay() == GET_IN_PLACE) {
|
2009-02-13 17:16:39 +05:00
|
|
|
GEOM::GEOM_Object_var aGetInPlaceObj = aShapesOp->GetInPlace(myMainObj, anObj);
|
2012-08-09 13:58:02 +06:00
|
|
|
setInPlaceObj(aGetInPlaceObj);
|
2009-02-13 17:16:39 +05:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
bool isVisible = true;
|
2012-08-09 13:58:02 +06:00
|
|
|
if (SALOME_View* view = GEOM_Displayer::GetActiveView())
|
|
|
|
isVisible = view->isVisible(aSelList.First());
|
|
|
|
setInPlaceObj(anObj, isVisible);
|
2009-02-13 17:16:39 +05:00
|
|
|
}
|
|
|
|
myEditCurrentArgument = 0;
|
|
|
|
//myBusy = true; // just activate but do not select in the list
|
|
|
|
activateSelection();
|
|
|
|
//myBusy = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
//=================================================================================
|
2009-02-13 17:16:39 +05:00
|
|
|
//function : setInPlaceObj
|
|
|
|
//purpose : temporarily add an object to study and remove old InPlaceObj
|
2012-08-09 13:58:02 +06:00
|
|
|
//=================================================================================
|
|
|
|
void GroupGUI_GroupDlg::setInPlaceObj(GEOM::GEOM_Object_var theObj, const bool isVisible)
|
2009-02-13 17:16:39 +05:00
|
|
|
{
|
2012-08-09 13:58:02 +06:00
|
|
|
if (!myInPlaceObj->_is_equivalent(theObj))
|
2009-02-13 17:16:39 +05:00
|
|
|
{
|
|
|
|
myInPlaceObj = theObj;
|
|
|
|
}
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
// build map of indices
|
|
|
|
myMain2InPlaceIndices.Clear();
|
2012-08-09 13:58:02 +06:00
|
|
|
if (!myInPlaceObj->_is_nil()) {
|
|
|
|
GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId());
|
|
|
|
GEOM::GEOM_ILocalOperations_var aLocOp = getGeomEngine()->GetILocalOperations(getStudyId());
|
2009-02-13 17:16:39 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
GEOM::ListOfGO_var aSubObjects = aShapesOp->MakeExplode(myInPlaceObj, getShapeType(), false);
|
|
|
|
for ( int i = 0; i < aSubObjects->length(); i++ )
|
2009-02-13 17:16:39 +05:00
|
|
|
{
|
2012-08-09 13:58:02 +06:00
|
|
|
GEOM::ListOfLong_var aCurrList = aShapesOp->GetSameIDs( myMainObj, aSubObjects[i] );
|
|
|
|
if( aCurrList->length() > 1 ) {
|
|
|
|
//rnv : To Fix the 21561: EDF 2184 GEOM: Group with second shape restriction.
|
|
|
|
// In case if GetSameIDs(...) method return more then one ID use
|
|
|
|
// GetSharedShapes(...) method to get sub-shapes of the second shape.
|
|
|
|
GEOM::ListOfGO_var aSubObjects2 = aShapesOp->GetSharedShapes( myMainObj, aSubObjects[i], getShapeType() );
|
|
|
|
for( int j = 0; j < aSubObjects2->length(); j++ ) {
|
|
|
|
CORBA::Long aMainIndex = aLocOp->GetSubShapeIndex( myMainObj, aSubObjects2[j] );
|
|
|
|
CORBA::Long aPlaceIndex = aLocOp->GetSubShapeIndex( myInPlaceObj, aSubObjects[i]);
|
|
|
|
if ( aMainIndex >= 0 && aPlaceIndex > 0 ) {
|
|
|
|
myMain2InPlaceIndices.Bind( aMainIndex, aPlaceIndex );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if(aCurrList->length() > 0 ) {
|
|
|
|
CORBA::Long aMainIndex = aCurrList[0];
|
|
|
|
CORBA::Long aPlaceIndex = aLocOp->GetSubShapeIndex( myInPlaceObj, aSubObjects[i] );
|
|
|
|
if ( aMainIndex >= 0 && aPlaceIndex > 0) {
|
|
|
|
myMain2InPlaceIndices.Bind( aMainIndex, aPlaceIndex );
|
|
|
|
}
|
|
|
|
}
|
2009-02-13 17:16:39 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
myInPlaceObjSelectState = subSelectionWay();
|
2012-08-09 13:58:02 +06:00
|
|
|
if (myInPlaceObjSelectState == SUBSHAPES_OF_SHAPE2 && !isVisible)
|
2009-02-13 17:16:39 +05:00
|
|
|
myInPlaceObjSelectState = SUBSHAPES_OF_INVISIBLE_SHAPE2;
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : SelectionIntoArgument()
|
|
|
|
// purpose : Called when selection has changed
|
|
|
|
//=================================================================================
|
|
|
|
void GroupGUI_GroupDlg::SelectionIntoArgument()
|
|
|
|
{
|
2009-02-13 17:16:39 +05:00
|
|
|
if (subSelectionWay() != ALL_SUBSHAPES && myEditCurrentArgument == myShape2Name) {
|
|
|
|
onGetInPlace();
|
2015-04-29 18:44:24 +05:00
|
|
|
if( !myInPlaceObj->_is_nil() ) {
|
|
|
|
mySelBtn2->setDown(false);
|
|
|
|
}
|
2009-02-13 17:16:39 +05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (myEditCurrentArgument == myMainName) { // Selection of a main shape is active
|
|
|
|
myEditCurrentArgument->setText("");
|
2006-02-07 20:58:35 +05:00
|
|
|
myIdList->clear();
|
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
|
|
|
|
SALOME_ListIO aSelList;
|
|
|
|
aSelMgr->selectedObjects(aSelList);
|
|
|
|
int nbSel = aSelList.Extent();
|
|
|
|
|
|
|
|
if (nbSel == 1) {
|
2004-12-01 15:39:14 +05:00
|
|
|
GEOM::GEOM_Object_var anObj =
|
2012-08-09 13:58:02 +06:00
|
|
|
GEOMBase::ConvertIOinGEOMObject(aSelList.First());
|
|
|
|
|
|
|
|
if (GEOMBase::IsShape(anObj)) {
|
|
|
|
if (myIsHiddenMain) {
|
|
|
|
GEOM_Displayer* aDisplayer = getDisplayer();
|
|
|
|
aDisplayer->Display(myMainObj);
|
|
|
|
myIsHiddenMain = false;
|
|
|
|
}
|
|
|
|
myMainObj = anObj;
|
2014-04-29 12:59:48 +06:00
|
|
|
if (!CORBA::is_nil(myMainObj)) {
|
2015-04-29 18:44:24 +05:00
|
|
|
mySelBtn->setDown(false);
|
2014-04-29 12:59:48 +06:00
|
|
|
SALOME_View* view = GEOM_Displayer::GetActiveView();
|
|
|
|
if (view) {
|
|
|
|
CORBA::String_var aMainEntry = myMainObj->GetStudyEntry();
|
|
|
|
Handle(SALOME_InteractiveObject) io =
|
|
|
|
new SALOME_InteractiveObject (aMainEntry.in(), "GEOM", "TEMP_IO");
|
|
|
|
if (view->isVisible(io)) myWasHiddenMain = false;
|
|
|
|
}
|
|
|
|
}
|
2012-08-09 13:58:02 +06:00
|
|
|
myEditCurrentArgument->setText(GEOMBase::GetName(anObj));
|
|
|
|
// activate sub-shapes selection by default
|
|
|
|
myEditCurrentArgument = 0;
|
|
|
|
activateSelection();
|
|
|
|
updateState();
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
}
|
2012-08-09 13:58:02 +06:00
|
|
|
else {
|
|
|
|
if (myIsHiddenMain) {
|
|
|
|
GEOM_Displayer* aDisplayer = getDisplayer();
|
|
|
|
aDisplayer->Display(myMainObj);
|
|
|
|
myIsHiddenMain = false;
|
|
|
|
}
|
|
|
|
myMainObj = GEOM::GEOM_Object::_nil();
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
2006-02-07 20:58:35 +05:00
|
|
|
else { // an attempt to synchronize list box selection with 3d viewer
|
2012-08-09 13:58:02 +06:00
|
|
|
if (myBusy || myMainObj->_is_nil()) {
|
2004-12-01 15:39:14 +05:00
|
|
|
return;
|
2009-02-13 17:16:39 +05:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
bool isBlocked = myIdList->signalsBlocked();
|
2012-08-09 13:58:02 +06:00
|
|
|
myIdList->blockSignals(true);
|
2004-12-01 15:39:14 +05:00
|
|
|
myIdList->clearSelection();
|
|
|
|
|
2005-12-22 18:29:32 +05:00
|
|
|
TColStd_IndexedMapOfInteger aMapIndex;
|
2012-08-09 13:58:02 +06:00
|
|
|
int nbSel = getSelectedSubshapes(aMapIndex);
|
2005-12-22 18:29:32 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
if (nbSel) {
|
|
|
|
QMap<int, int> aMap;
|
|
|
|
for (int i = 0, n = myIdList->count(); i < n; i++)
|
|
|
|
aMap.insert(myIdList->item(i)->text().toInt(), i);
|
|
|
|
|
|
|
|
bool highlight = false;
|
|
|
|
for (int ii = 1, nn = aMapIndex.Extent(); ii <= nn; ii++) {
|
|
|
|
if (aMap.contains(aMapIndex(ii))) {
|
|
|
|
myIdList->item(aMap[aMapIndex(ii)])->setSelected(true);
|
|
|
|
highlight = true;
|
2006-02-07 20:58:35 +05:00
|
|
|
}
|
2005-12-22 18:29:32 +05:00
|
|
|
}
|
2012-08-09 13:58:02 +06:00
|
|
|
if (highlight)
|
|
|
|
highlightSubShapes();
|
2006-02-07 20:58:35 +05:00
|
|
|
}
|
2012-08-09 13:58:02 +06:00
|
|
|
myIdList->blockSignals(isBlocked);
|
2006-02-07 20:58:35 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
updateState(nbSel);
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ConstructorsClicked()
|
|
|
|
// purpose : Radio button management
|
|
|
|
//=================================================================================
|
2012-08-09 13:58:02 +06:00
|
|
|
void GroupGUI_GroupDlg::ConstructorsClicked(int constructorId)
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
2012-08-09 13:58:02 +06:00
|
|
|
if (getConstructorId() != constructorId)
|
|
|
|
setConstructorId(constructorId);
|
|
|
|
|
|
|
|
myIsShapeType = true;
|
2004-12-01 15:39:14 +05:00
|
|
|
myIdList->clear();
|
2012-08-09 13:58:02 +06:00
|
|
|
myEditCurrentArgument = 0;
|
|
|
|
|
|
|
|
setInPlaceObj(myInPlaceObj); // to rebuild myMain2InPlaceIndices
|
2004-12-01 15:39:14 +05:00
|
|
|
activateSelection();
|
|
|
|
updateState();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : selectAllSubShapes
|
2012-08-09 13:58:02 +06:00
|
|
|
// purpose :
|
2004-12-01 15:39:14 +05:00
|
|
|
//=================================================================================
|
|
|
|
void GroupGUI_GroupDlg::selectAllSubShapes()
|
|
|
|
{
|
2012-08-09 13:58:02 +06:00
|
|
|
if (CORBA::is_nil(myMainObj) || !myIsShapeType)
|
2004-12-01 15:39:14 +05:00
|
|
|
return;
|
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
GEOM::ListOfLong_var aSubShapes;
|
2012-08-09 13:58:02 +06:00
|
|
|
GEOM::GEOM_IShapesOperations_var aShOp = getGeomEngine()->GetIShapesOperations(getStudyId());
|
|
|
|
aSubShapes = aShOp->SubShapeAllIDs(myMainObj, getShapeType(), false);
|
|
|
|
if (aSubShapes->length() > 0) {
|
|
|
|
if (subSelectionWay() == ALL_SUBSHAPES)
|
|
|
|
{
|
2013-02-12 17:35:16 +06:00
|
|
|
// myIdList->clear(); // for sorted final list?
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
if (!aShOp->IsDone())
|
|
|
|
return;
|
2009-02-13 17:16:39 +05:00
|
|
|
}
|
2012-08-09 13:58:02 +06:00
|
|
|
else
|
|
|
|
{
|
|
|
|
aSubShapes = new GEOM::ListOfLong();
|
|
|
|
aSubShapes->length(myMain2InPlaceIndices.Extent());
|
|
|
|
TColStd_DataMapIteratorOfDataMapOfIntegerInteger m2ip (myMain2InPlaceIndices);
|
|
|
|
for (int i = 0; m2ip.More(); i++, m2ip.Next())
|
|
|
|
aSubShapes[i] = m2ip.Key();
|
2009-02-13 17:16:39 +05:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
bool isBlocked = myIdList->signalsBlocked();
|
|
|
|
myIdList->blockSignals(true);
|
|
|
|
|
|
|
|
for (int i = 0, n = aSubShapes->length(); i < n; i++) {
|
|
|
|
CORBA::Long anIndex = aSubShapes[i];
|
|
|
|
if (anIndex < 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
QListWidgetItem* anItem = 0;
|
|
|
|
QString text = QString("%1").arg(anIndex);
|
2013-02-12 17:35:16 +06:00
|
|
|
// if (!myInPlaceObj->_is_nil()) {
|
2012-08-09 13:58:02 +06:00
|
|
|
QList<QListWidgetItem*> found = myIdList->findItems(text, Qt::MatchExactly);
|
|
|
|
if (found.count()) anItem = found[0];
|
2013-02-12 17:35:16 +06:00
|
|
|
// }
|
2012-08-09 13:58:02 +06:00
|
|
|
if (!anItem) {
|
|
|
|
anItem = new QListWidgetItem(text);
|
2013-02-12 17:35:16 +06:00
|
|
|
anItem->setTextColor( myGroupIdList.contains(anIndex) ? QColor( GROUP_IDLST_COLOR ) : QColor( GROUP_NEWIDLST_COLOR ) );
|
2012-08-09 13:58:02 +06:00
|
|
|
myIdList->addItem(anItem);
|
|
|
|
}
|
|
|
|
anItem->setSelected(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
myIdList->blockSignals(isBlocked);
|
|
|
|
highlightSubShapes();
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
2012-08-09 13:58:02 +06:00
|
|
|
// function : showOnlySelected
|
|
|
|
// purpose :
|
2004-12-01 15:39:14 +05:00
|
|
|
//=================================================================================
|
2012-08-09 13:58:02 +06:00
|
|
|
void GroupGUI_GroupDlg::showOnlySelected()
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
2012-08-09 13:58:02 +06:00
|
|
|
if (CORBA::is_nil(myMainObj) || !myIsShapeType)
|
|
|
|
return;
|
2006-02-07 20:58:35 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
QPushButton* send = (QPushButton*)sender();
|
|
|
|
if (send == myShowAllBtn) {
|
|
|
|
activateSelection();
|
|
|
|
return;
|
|
|
|
}
|
2006-02-07 20:58:35 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
|
|
|
|
SALOME_ListIO aSelList;
|
|
|
|
aSelMgr->selectedObjects(aSelList);
|
|
|
|
|
|
|
|
GEOM_Displayer* aDisplayer = getDisplayer();
|
|
|
|
|
|
|
|
if (send == myHideSelBtn) {
|
|
|
|
aDisplayer->Erase(aSelList, /*forced=*/false, /*updateViewer=*/true);
|
2005-12-22 18:29:32 +05:00
|
|
|
}
|
2012-08-09 13:58:02 +06:00
|
|
|
else {
|
|
|
|
// Mantis issue 0021421: do not hide main shape, if explode on VERTEX
|
|
|
|
SALOME_View* view = GEOM_Displayer::GetActiveView();
|
|
|
|
if (view) {
|
|
|
|
CORBA::String_var aMainEntry = myMainObj->GetStudyEntry();
|
|
|
|
Handle(SALOME_InteractiveObject) io =
|
|
|
|
new SALOME_InteractiveObject (aMainEntry.in(), "GEOM", "TEMP_IO");
|
|
|
|
if (view->isVisible(io)) myIsHiddenMain = true;
|
2013-12-18 20:23:59 +06:00
|
|
|
|
|
|
|
//keep the selected entry and IO in the map for checking
|
|
|
|
std::map<QString, Handle(SALOME_InteractiveObject)> aSelEntriesMap;
|
|
|
|
SALOME_ListIteratorOfListIO aSelIt(aSelList);
|
|
|
|
for ( ; aSelIt.More(); aSelIt.Next() ) {
|
|
|
|
Handle(SALOME_InteractiveObject) anSelIO = aSelIt.Value();
|
|
|
|
aSelEntriesMap[anSelIO->getEntry()] = anSelIO;
|
|
|
|
}
|
|
|
|
//get the displayed sub-shapes
|
|
|
|
SALOME_ListIO displayed;
|
|
|
|
view->GetVisible(displayed);
|
|
|
|
// Erase all, except the selected sub-shapes
|
|
|
|
std::map<QString, Handle(SALOME_InteractiveObject)>::iterator
|
|
|
|
aSelDispIter = aSelEntriesMap.end();
|
|
|
|
SALOME_ListIteratorOfListIO aDispIt( displayed );
|
|
|
|
for ( ; aDispIt.More(); aDispIt.Next() ) {
|
|
|
|
Handle(SALOME_InteractiveObject) anIO = aDispIt.Value();
|
|
|
|
aSelDispIter = aSelEntriesMap.find( anIO->getEntry() );
|
|
|
|
if ( aSelDispIter != aSelEntriesMap.end() ) {
|
|
|
|
//sub-shape is selected, so erase it's record from map to keep in it not displayed, but selected sub-shapes only
|
|
|
|
aSelEntriesMap.erase(aSelDispIter);
|
|
|
|
} else {
|
|
|
|
//sub-shape is not in the map of selected, then erase it from view
|
|
|
|
aDisplayer->Erase( anIO, /*forced = */false, /*updateViewer = */false );
|
|
|
|
}
|
|
|
|
}
|
2006-02-07 20:58:35 +05:00
|
|
|
|
2013-12-18 20:23:59 +06:00
|
|
|
if ( !aSelEntriesMap.empty() ) {
|
|
|
|
// Build a presentation of the selected, but not displayed sub-shapes
|
|
|
|
TopoDS_Shape aMainShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), myMainObj);
|
|
|
|
TopTools_IndexedMapOfShape aSubShapesMap;
|
|
|
|
TopExp::MapShapes(aMainShape, aSubShapesMap);
|
|
|
|
QString anEntryBase = aMainEntry.in();
|
|
|
|
|
|
|
|
TopExp_Explorer anExp (aMainShape, getShapeType());
|
|
|
|
for (; anExp.More(); anExp.Next()) {
|
|
|
|
TopoDS_Shape aSubShape = anExp.Current();
|
|
|
|
int index = aSubShapesMap.FindIndex(aSubShape);
|
|
|
|
QString anEntry = QString( "TEMP_" ) + anEntryBase + QString("_%1").arg(index);
|
|
|
|
if ( aSelEntriesMap.find( anEntry ) == aSelEntriesMap.end() ) {
|
|
|
|
//skip not selected sub-shapes
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
SALOME_Prs* aPrs = aDisplayer->buildSubshapePresentation(aSubShape, anEntry, view);
|
|
|
|
if (aPrs) {
|
|
|
|
displayPreview(aPrs, true, false); // append, do not update
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aDisplayer->UpdateViewer();
|
|
|
|
}
|
2009-02-13 17:16:39 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
// Mantis issue 0021421: do not hide main shape, if explode on VERTEX
|
|
|
|
if (getShapeType() == TopAbs_VERTEX && myIsHiddenMain) {
|
|
|
|
aDisplayer->Display(myMainObj);
|
|
|
|
}
|
|
|
|
|
|
|
|
// for the case when selected ids were not displayed in the viewer: Mantis issue 0021367
|
|
|
|
highlightSubShapes();
|
2009-02-13 17:16:39 +05:00
|
|
|
}
|
2012-08-09 13:58:02 +06:00
|
|
|
}
|
2009-02-13 17:16:39 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
//=================================================================================
|
|
|
|
// function : getSelectedSubshapes
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
int GroupGUI_GroupDlg::getSelectedSubshapes (TColStd_IndexedMapOfInteger& theMapIndex)
|
|
|
|
{
|
|
|
|
theMapIndex.Clear();
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
SalomeApp_Application* app = myGeomGUI->getApp();
|
|
|
|
if (!app || myMainObj->_is_nil())
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
|
|
|
|
SALOME_ListIO aSelList;
|
|
|
|
aSelMgr->selectedObjects(aSelList);
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
// try to find out and process the global selection
|
|
|
|
// (of not published objects and of published sub-shapes)
|
|
|
|
{
|
|
|
|
SALOME_ListIteratorOfListIO anIter (aSelList);
|
|
|
|
for (int i = 0; anIter.More(); anIter.Next(), i++)
|
2008-03-07 12:45:34 +05:00
|
|
|
{
|
2012-08-09 13:58:02 +06:00
|
|
|
Handle(SALOME_InteractiveObject) anIObj = anIter.Value();
|
|
|
|
QString anEntry = anIObj->getEntry();
|
|
|
|
QString str = "_";
|
|
|
|
int index = anEntry.lastIndexOf(str);
|
|
|
|
if (index > 0) // selection among special preview
|
2008-03-07 12:45:34 +05:00
|
|
|
{
|
2012-08-09 13:58:02 +06:00
|
|
|
anEntry.remove(0, index+1);
|
|
|
|
int anIndex = anEntry.toInt();
|
|
|
|
if (anIndex)
|
2013-06-10 14:13:27 +06:00
|
|
|
theMapIndex.Add(anIndex);
|
2008-03-07 12:45:34 +05:00
|
|
|
}
|
2012-08-09 13:58:02 +06:00
|
|
|
else // selection among published shapes
|
2008-03-07 12:45:34 +05:00
|
|
|
{
|
2012-08-09 13:58:02 +06:00
|
|
|
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
|
|
|
|
if (!appStudy) return 0;
|
|
|
|
_PTR(Study) aStudy = appStudy->studyDS();
|
|
|
|
|
|
|
|
_PTR(SObject) aSObj (aStudy->FindObjectID(anEntry.toLatin1().constData()));
|
|
|
|
GEOM::GEOM_Object_var aGeomObj =
|
|
|
|
GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aSObj));
|
2008-03-07 12:45:34 +05:00
|
|
|
TopoDS_Shape aShape;
|
2012-08-09 13:58:02 +06:00
|
|
|
if (GEOMBase::GetShape(aGeomObj, aShape)) {
|
|
|
|
if (aGeomObj->GetType() == GEOM_GROUP || aShape.ShapeType() == getShapeType()) {
|
|
|
|
TopTools_IndexedMapOfShape aMainMap;
|
|
|
|
TopoDS_Shape aMainShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), myMainObj);
|
|
|
|
TopExp::MapShapes(aMainShape, aMainMap);
|
|
|
|
|
|
|
|
TopExp_Explorer anExp (aShape, getShapeType());
|
2014-03-05 14:55:14 +06:00
|
|
|
bool isShowWarning = true;
|
2012-08-09 13:58:02 +06:00
|
|
|
for (; anExp.More(); anExp.Next()) {
|
|
|
|
TopoDS_Shape aSubShape = anExp.Current();
|
|
|
|
int anIndex = aMainMap.FindIndex(aSubShape);
|
2013-06-10 14:13:27 +06:00
|
|
|
if (anIndex == 0) {
|
2014-03-05 14:55:14 +06:00
|
|
|
if (isShowWarning) {
|
|
|
|
SUIT_MessageBox::warning(app->desktop(), QObject::tr("WRN_WARNING"),
|
2013-06-10 14:13:27 +06:00
|
|
|
tr("WRN_NOT_SUBSHAPE"));
|
2014-03-05 14:55:14 +06:00
|
|
|
isShowWarning = false;
|
|
|
|
}
|
2013-06-10 14:13:27 +06:00
|
|
|
}
|
|
|
|
else {
|
2012-08-09 13:58:02 +06:00
|
|
|
if (subSelectionWay() != ALL_SUBSHAPES &&
|
|
|
|
!myMain2InPlaceIndices.IsBound(anIndex))
|
|
|
|
continue;
|
|
|
|
theMapIndex.Add(anIndex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
}
|
2006-02-07 20:58:35 +05:00
|
|
|
}
|
2012-08-09 13:58:02 +06:00
|
|
|
} // for aSelList
|
2006-02-07 20:58:35 +05:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
return theMapIndex.Extent();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : add
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void GroupGUI_GroupDlg::add()
|
|
|
|
{
|
|
|
|
TColStd_IndexedMapOfInteger aMapIndex;
|
|
|
|
int nbSel = getSelectedSubshapes(aMapIndex);
|
|
|
|
|
|
|
|
TColStd_MapOfInteger aMap;
|
|
|
|
for (int i = 0, n = myIdList->count(); i < n; i++)
|
|
|
|
aMap.Add(myIdList->item(i)->text().toInt());
|
|
|
|
|
|
|
|
if (nbSel > 0) {
|
2006-02-07 20:58:35 +05:00
|
|
|
bool isBlocked = myIdList->signalsBlocked();
|
2012-08-09 13:58:02 +06:00
|
|
|
myIdList->blockSignals(true);
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
for (int i = 1, n = aMapIndex.Extent(); i <= n; i++) {
|
|
|
|
if (aMap.Contains(aMapIndex(i)))
|
2006-02-07 20:58:35 +05:00
|
|
|
continue;
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
QListWidgetItem* anItem = new QListWidgetItem(QString("%1").arg(aMapIndex(i)));
|
2013-02-12 17:35:16 +06:00
|
|
|
anItem->setTextColor( myGroupIdList.contains( aMapIndex( i ) ) ? QColor( GROUP_IDLST_COLOR ) : QColor( GROUP_NEWIDLST_COLOR ) );
|
2012-08-09 13:58:02 +06:00
|
|
|
myIdList->addItem(anItem);
|
|
|
|
anItem->setSelected(true);
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
2006-02-07 20:58:35 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
myIdList->blockSignals(isBlocked);
|
2006-02-07 20:58:35 +05:00
|
|
|
}
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
updateState();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : remove
|
2012-08-09 13:58:02 +06:00
|
|
|
// purpose :
|
2004-12-01 15:39:14 +05:00
|
|
|
//=================================================================================
|
|
|
|
void GroupGUI_GroupDlg::remove()
|
|
|
|
{
|
2008-03-07 12:45:34 +05:00
|
|
|
bool isBlocked = myIdList->signalsBlocked();
|
2012-08-09 13:58:02 +06:00
|
|
|
myIdList->blockSignals(true);
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
QListIterator<QListWidgetItem*> it (myIdList->selectedItems());
|
|
|
|
while (it.hasNext())
|
2009-02-13 17:16:39 +05:00
|
|
|
delete it.next();
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
myIdList->blockSignals(isBlocked);
|
2008-03-07 12:45:34 +05:00
|
|
|
|
|
|
|
highlightSubShapes();
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
//=================================================================================
|
2009-02-13 17:16:39 +05:00
|
|
|
//function : subSelectionWay
|
2012-08-09 13:58:02 +06:00
|
|
|
//purpose :
|
|
|
|
//=================================================================================
|
2009-02-13 17:16:39 +05:00
|
|
|
int GroupGUI_GroupDlg::subSelectionWay() const
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
2012-08-09 13:58:02 +06:00
|
|
|
return myRestrictGroup->checkedId();
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : getShapeType()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
TopAbs_ShapeEnum GroupGUI_GroupDlg::getShapeType() const
|
|
|
|
{
|
2012-08-09 13:58:02 +06:00
|
|
|
switch (getConstructorId()) {
|
2004-12-01 15:39:14 +05:00
|
|
|
case 0: return TopAbs_VERTEX;
|
|
|
|
case 1: return TopAbs_EDGE;
|
|
|
|
case 2: return TopAbs_FACE;
|
|
|
|
case 3: return TopAbs_SOLID;
|
|
|
|
default: return TopAbs_SHAPE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : setShapeType()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2012-08-09 13:58:02 +06:00
|
|
|
void GroupGUI_GroupDlg::setShapeType(const TopAbs_ShapeEnum theType)
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
|
|
|
int anId = 0;
|
2012-08-09 13:58:02 +06:00
|
|
|
switch (theType) {
|
2004-12-01 15:39:14 +05:00
|
|
|
case TopAbs_VERTEX: anId = 0; break;
|
|
|
|
case TopAbs_EDGE: anId = 1; break;
|
|
|
|
case TopAbs_FACE: anId = 2; break;
|
|
|
|
case TopAbs_SOLID: anId = 3; break;
|
2006-02-07 20:58:35 +05:00
|
|
|
}
|
2012-08-09 13:58:02 +06:00
|
|
|
setConstructorId(anId);
|
|
|
|
if (!myIsShapeType)
|
|
|
|
{
|
|
|
|
myIsShapeType = true;
|
|
|
|
// workaround to avoid set checked button 0
|
|
|
|
setConstructorId(anId);
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : activateSelection
|
|
|
|
// purpose : Activate selection in accordance with myEditCurrentArgument
|
|
|
|
//=================================================================================
|
|
|
|
void GroupGUI_GroupDlg::activateSelection()
|
|
|
|
{
|
2012-08-09 13:58:02 +06:00
|
|
|
bool isApply = ((QPushButton*)sender() == buttonApply());
|
2013-02-12 17:35:16 +06:00
|
|
|
if(!isApplyAndClose())
|
2012-08-09 13:58:02 +06:00
|
|
|
erasePreview(false);
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
// local selection
|
2012-08-09 13:58:02 +06:00
|
|
|
if (!myMainObj->_is_nil() &&
|
|
|
|
!myEditCurrentArgument &&
|
|
|
|
myIsShapeType) // check if shape type is already choosen by user
|
|
|
|
{
|
|
|
|
GEOM_Displayer* aDisplayer = getDisplayer();
|
2014-01-17 15:46:36 +06:00
|
|
|
|
2013-02-12 17:35:16 +06:00
|
|
|
//display mode for main shape
|
|
|
|
if ( myDmMode == -1 ) {
|
|
|
|
SALOME_View* view = GEOM_Displayer::GetActiveView();
|
2012-08-09 13:58:02 +06:00
|
|
|
if (view) {
|
|
|
|
CORBA::String_var aMainEntry = myMainObj->GetStudyEntry();
|
|
|
|
Handle(SALOME_InteractiveObject) io =
|
|
|
|
new SALOME_InteractiveObject (aMainEntry.in(), "GEOM", "TEMP_IO");
|
2013-02-12 17:35:16 +06:00
|
|
|
if ( view->isVisible( io ) ) {
|
|
|
|
Handle(GEOM_AISShape) aSh = GEOMBase::ConvertIOinGEOMAISShape( io, true );
|
|
|
|
if(!aSh.IsNull()) {
|
|
|
|
myDmMode = aSh->isTopLevel() ? aSh->prevDisplayMode() : aSh->DisplayMode();
|
|
|
|
}
|
2012-08-09 13:58:02 +06:00
|
|
|
}
|
2013-02-12 17:35:16 +06:00
|
|
|
else
|
|
|
|
myDmMode = SUIT_Session::session()->resourceMgr()->integerValue( "Geometry", "display_mode" );
|
2012-08-09 13:58:02 +06:00
|
|
|
}
|
|
|
|
}
|
2013-02-12 17:35:16 +06:00
|
|
|
aDisplayer->SetDisplayMode(myDmMode);
|
|
|
|
|
|
|
|
// Mantis issue 0021421: do not hide main shape, if explode on VERTEX
|
2014-01-17 15:46:36 +06:00
|
|
|
if(getShapeType() != TopAbs_VERTEX) {
|
|
|
|
aDisplayer->Erase(myMainObj, false, false);
|
|
|
|
myIsHiddenMain = true;
|
2013-02-12 17:35:16 +06:00
|
|
|
}
|
2014-01-17 15:46:36 +06:00
|
|
|
else
|
|
|
|
aDisplayer->Display(myMainObj);
|
|
|
|
|
2013-02-12 17:35:16 +06:00
|
|
|
aDisplayer->Erase(myGroup, false, false);
|
|
|
|
|
|
|
|
QColor aColor = SUIT_Session::session()->resourceMgr()->colorValue( "Geometry", "editgroup_color" );
|
|
|
|
Quantity_NameOfColor aCol = SalomeApp_Tools::color( aColor ).Name();
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-12 17:35:16 +06:00
|
|
|
if(!isApplyAndClose()) {
|
2012-08-09 13:58:02 +06:00
|
|
|
SUIT_ViewWindow* aViewWindow = 0;
|
|
|
|
SUIT_Study* activeStudy = SUIT_Session::session()->activeApplication()->activeStudy();
|
|
|
|
if (activeStudy)
|
|
|
|
aViewWindow = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
|
|
|
|
if (aViewWindow == 0) return;
|
|
|
|
|
|
|
|
SUIT_ViewManager* aViewManager = aViewWindow->getViewManager();
|
|
|
|
if (aViewManager->getType() != OCCViewer_Viewer::Type() &&
|
|
|
|
aViewManager->getType() != SVTK_Viewer::Type())
|
|
|
|
return;
|
|
|
|
|
|
|
|
SUIT_ViewModel* aViewModel = aViewManager->getViewModel();
|
|
|
|
SALOME_View* aView = dynamic_cast<SALOME_View*>(aViewModel);
|
|
|
|
if (aView == 0) return;
|
|
|
|
|
|
|
|
TopoDS_Shape aMainShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), myMainObj);
|
|
|
|
TopoDS_Shape aRestrictionShape;
|
|
|
|
|
|
|
|
if (subSelectionWay() == ALL_SUBSHAPES) {
|
|
|
|
aRestrictionShape = aMainShape;
|
|
|
|
|
|
|
|
TopTools_IndexedMapOfShape aSubShapesMap;
|
|
|
|
TopExp::MapShapes(aMainShape, aSubShapesMap);
|
|
|
|
CORBA::String_var aMainEntry = myMainObj->GetStudyEntry();
|
|
|
|
QString anEntryBase = aMainEntry.in();
|
|
|
|
|
|
|
|
TopExp_Explorer anExp (aRestrictionShape, getShapeType());
|
|
|
|
for (; anExp.More(); anExp.Next()) {
|
|
|
|
TopoDS_Shape aSubShape = anExp.Current();
|
|
|
|
int index = aSubShapesMap.FindIndex(aSubShape);
|
2013-02-12 17:35:16 +06:00
|
|
|
QString anEntry = QString( "TEMP_" ) + anEntryBase + QString("_%1").arg(index);
|
|
|
|
Handle(SALOME_InteractiveObject) io =
|
|
|
|
new SALOME_InteractiveObject(anEntry.toAscii(), "GEOM", "TEMP_IO");
|
|
|
|
if ( myGroupIdList.contains( index ) ) {
|
|
|
|
aDisplayer->SetColor( aCol );
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aDisplayer->UnsetColor();
|
|
|
|
}
|
2012-08-09 13:58:02 +06:00
|
|
|
SALOME_Prs* aPrs = aDisplayer->buildSubshapePresentation(aSubShape, anEntry, aView);
|
|
|
|
if (aPrs) {
|
|
|
|
displayPreview(aPrs, true, false); // append, do not update
|
|
|
|
// TODO: map or delete Prs
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!myInPlaceObj->_is_nil()) {
|
|
|
|
TopTools_IndexedMapOfShape aSubShapesMap;
|
|
|
|
TopExp::MapShapes(aMainShape, aSubShapesMap);
|
|
|
|
CORBA::String_var aMainEntry = myMainObj->GetStudyEntry();
|
|
|
|
QString anEntryBase = aMainEntry.in();
|
|
|
|
|
|
|
|
TColStd_DataMapIteratorOfDataMapOfIntegerInteger aM2IPit (myMain2InPlaceIndices);
|
|
|
|
for (; aM2IPit.More(); aM2IPit.Next()) {
|
|
|
|
int index = aM2IPit.Key();
|
|
|
|
TopoDS_Shape aSubShape = aSubShapesMap.FindKey(index);
|
2013-02-12 17:35:16 +06:00
|
|
|
QString anEntry = QString( "TEMP_" ) + anEntryBase + QString("_%1").arg(index);
|
|
|
|
|
|
|
|
if ( myGroupIdList.contains( index ) ) {
|
|
|
|
aDisplayer->SetColor( aCol );
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aDisplayer->UnsetColor();
|
|
|
|
}
|
2012-08-09 13:58:02 +06:00
|
|
|
|
|
|
|
SALOME_Prs* aPrs = aDisplayer->buildSubshapePresentation(aSubShape, anEntry, aView);
|
|
|
|
if (aPrs) {
|
|
|
|
displayPreview(aPrs, true, false); // append, do not update
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else ;
|
2013-02-12 17:35:16 +06:00
|
|
|
aDisplayer->UnsetDisplayMode();
|
|
|
|
aDisplayer->UnsetColor();
|
2012-08-09 13:58:02 +06:00
|
|
|
aDisplayer->UpdateViewer();
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
globalSelection(GEOM_ALLSHAPES);
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
SelectionIntoArgument();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : updateState
|
2012-08-09 13:58:02 +06:00
|
|
|
// purpose :
|
2004-12-01 15:39:14 +05:00
|
|
|
//=================================================================================
|
2012-08-09 13:58:02 +06:00
|
|
|
void GroupGUI_GroupDlg::updateState (bool isAdd)
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
2012-08-09 13:58:02 +06:00
|
|
|
myAddBtn->setEnabled(!myEditCurrentArgument && !CORBA::is_nil(myMainObj) && isAdd);
|
|
|
|
//myShowOnlyBtn->setEnabled(!myEditCurrentArgument && !CORBA::is_nil(myMainObj) && isAdd);
|
2006-02-07 20:58:35 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
bool hasSel = myIdList->selectedItems().count() > 0;
|
2006-02-07 20:58:35 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
myRemBtn->setEnabled(hasSel);
|
|
|
|
myRestrictGroupBox->setEnabled(!CORBA::is_nil(myMainObj));
|
|
|
|
mySelAllBtn->setEnabled(!CORBA::is_nil(myMainObj));
|
2014-11-12 21:40:11 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
mySelBtn2->setEnabled(subSelectionWay() != ALL_SUBSHAPES);
|
|
|
|
myShape2Name->setEnabled(subSelectionWay() != ALL_SUBSHAPES);
|
2014-11-12 21:40:11 +05:00
|
|
|
myFilterGrp->setEnabled(!CORBA::is_nil(myMainObj) &&
|
|
|
|
subSelectionWay() == ALL_SUBSHAPES &&
|
|
|
|
myIsShapeType &&
|
|
|
|
getShapeType() != TopAbs_VERTEX);
|
2015-04-23 13:42:06 +05:00
|
|
|
// manage of 'Plot' button access
|
|
|
|
GEOM::GEOM_IShapesOperations_var aShOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
|
|
|
|
GEOM::ListOfLong_var aSubShapes = aShOp->SubShapeAllIDs( myMainObj, getShapeType(), false );
|
|
|
|
bool hasCurrentEntities = aSubShapes->length() > 0;
|
2015-06-11 18:03:47 +05:00
|
|
|
#ifndef DISABLE_PLOT2DVIEWER
|
2015-04-23 13:42:06 +05:00
|
|
|
myPlotDistributionButton->setEnabled( myFilterGrp->isEnabled() &&
|
|
|
|
myIsShapeType &&
|
|
|
|
( getShapeType() == TopAbs_EDGE ||
|
|
|
|
getShapeType() == TopAbs_FACE ||
|
|
|
|
getShapeType() == TopAbs_SOLID ) &&
|
|
|
|
hasCurrentEntities );
|
2015-06-11 18:03:47 +05:00
|
|
|
#endif
|
2012-08-09 13:58:02 +06:00
|
|
|
if (subSelectionWay() == ALL_SUBSHAPES)
|
|
|
|
setInPlaceObj(GEOM::GEOM_Object::_nil());
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : selectionChanged
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void GroupGUI_GroupDlg::selectionChanged()
|
|
|
|
{
|
|
|
|
highlightSubShapes();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : highlightSubShapes
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void GroupGUI_GroupDlg::highlightSubShapes()
|
|
|
|
{
|
2012-08-09 13:58:02 +06:00
|
|
|
if (CORBA::is_nil(myMainObj))
|
2004-12-01 15:39:14 +05:00
|
|
|
return;
|
|
|
|
|
|
|
|
TColStd_MapOfInteger anIds;
|
|
|
|
|
|
|
|
myBusy = true;
|
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
int ii = 0, nn = myIdList->count();
|
2012-08-09 13:58:02 +06:00
|
|
|
for (; ii < nn; ii++)
|
2009-02-13 17:16:39 +05:00
|
|
|
{
|
2012-08-09 13:58:02 +06:00
|
|
|
if (myIdList->item(ii)->isSelected()) {
|
|
|
|
int id = myIdList->item(ii)->text().toInt();
|
|
|
|
if (subSelectionWay() != ALL_SUBSHAPES &&
|
|
|
|
!myMain2InPlaceIndices.IsBound(id)) {
|
|
|
|
//myIdList->item(ii)->setSelected(false);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
anIds.Add(id);
|
2009-02-13 17:16:39 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
SalomeApp_Application* app = myGeomGUI->getApp();
|
|
|
|
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
|
2005-06-02 13:17:09 +06:00
|
|
|
aSelMgr->clearSelected();
|
2009-02-13 17:16:39 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
SUIT_ViewWindow* aViewWindow = 0;
|
|
|
|
SUIT_Study* activeStudy = app->activeStudy();
|
|
|
|
if (activeStudy)
|
|
|
|
aViewWindow = app->desktop()->activeWindow();
|
|
|
|
if (aViewWindow == 0) return;
|
|
|
|
|
|
|
|
SUIT_ViewManager* aViewManager = aViewWindow->getViewManager();
|
|
|
|
if (aViewManager->getType() != OCCViewer_Viewer::Type() &&
|
|
|
|
aViewManager->getType() != SVTK_Viewer::Type())
|
|
|
|
return;
|
|
|
|
|
|
|
|
SUIT_ViewModel* aViewModel = aViewManager->getViewModel();
|
|
|
|
SALOME_View* aView = dynamic_cast<SALOME_View*>(aViewModel);
|
|
|
|
if (aView == 0) return;
|
|
|
|
|
|
|
|
// TODO??: use here GEOMBase_Helper::myPreview instead of ic->DisplayedObjects()
|
|
|
|
|
|
|
|
OCCViewer_Viewer* v3d = ((OCCViewer_ViewManager*)aViewManager)->getOCCViewer();
|
|
|
|
Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
|
|
|
|
AIS_ListOfInteractive List;
|
|
|
|
//ic->DisplayedObjects(List);
|
|
|
|
ic->ObjectsInside(List); // Mantis issue 0021367
|
|
|
|
|
|
|
|
SALOME_ListIO aSelList;
|
|
|
|
|
|
|
|
// To highlight the selected sub-shape in Object Browser, if it's already published under the main shape
|
|
|
|
GEOM::GEOM_ILocalOperations_var aLocOp = getGeomEngine()->GetILocalOperations(getStudyId());
|
|
|
|
QMap<int, QString> childsMap;
|
|
|
|
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
|
|
|
|
if (appStudy) {
|
|
|
|
_PTR(Study) aStudy = appStudy->studyDS();
|
|
|
|
CORBA::String_var aMainEntry = myMainObj->GetStudyEntry();
|
|
|
|
QString anEntry = aMainEntry.in();
|
|
|
|
_PTR(SObject) aSObj (aStudy->FindObjectID(anEntry.toLatin1().constData()));
|
|
|
|
_PTR(ChildIterator) anIt (aStudy->NewChildIterator(aSObj));
|
|
|
|
for (anIt->InitEx(true); anIt->More(); anIt->Next()) {
|
|
|
|
GEOM::GEOM_Object_var aChild = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(anIt->Value()));
|
|
|
|
if (!CORBA::is_nil(aChild)) {
|
|
|
|
int index = aLocOp->GetSubShapeIndex(myMainObj, aChild);
|
|
|
|
CORBA::String_var aChildEntry = aChild->GetStudyEntry();
|
|
|
|
QString anEntry = aChildEntry.in();
|
|
|
|
childsMap.insert(index, anEntry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
AIS_ListIteratorOfListOfInteractive ite (List);
|
|
|
|
for (; ite.More(); ite.Next()) {
|
|
|
|
if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
|
|
|
|
Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
|
|
|
|
if (aSh->hasIO()) {
|
|
|
|
Handle(SALOME_InteractiveObject) anIO = aSh->getIO();
|
|
|
|
QString anEntry = anIO->getEntry();
|
|
|
|
int index = anEntry.lastIndexOf("_");
|
|
|
|
anEntry.remove(0, index+1);
|
|
|
|
int anIndex = anEntry.toInt();
|
|
|
|
if (anIds.Contains(anIndex)) {
|
|
|
|
aSelList.Append(anIO);
|
|
|
|
if (childsMap.contains (anIndex)) {
|
|
|
|
Handle(SALOME_InteractiveObject) tmpIO = new SALOME_InteractiveObject(childsMap.value(anIndex).toLatin1().constData(), "GEOM", "TEMP_IO");
|
|
|
|
aSelList.Append(tmpIO);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aSelMgr->setSelectedObjects(aSelList);
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
myBusy = false;
|
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
if (nn < 3000)
|
2012-08-09 13:58:02 +06:00
|
|
|
updateState(aSelList.Extent() > 0);
|
2008-03-07 12:45:34 +05:00
|
|
|
else {
|
2012-08-09 13:58:02 +06:00
|
|
|
myAddBtn->setEnabled(true);
|
|
|
|
myAddBtn->setEnabled(true);
|
|
|
|
myRemBtn->setEnabled(true);
|
2008-03-07 12:45:34 +05:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : createOperation
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
GEOM::GEOM_IOperations_ptr GroupGUI_GroupDlg::createOperation()
|
|
|
|
{
|
2012-08-09 13:58:02 +06:00
|
|
|
return getGeomEngine()->GetIGroupOperations(getStudyId());
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
#define RETURN_WITH_MSG(a, b) \
|
2012-08-09 13:58:02 +06:00
|
|
|
if (!(a)) { \
|
2004-12-01 15:39:14 +05:00
|
|
|
theMessage += (b); \
|
|
|
|
return false; \
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : isValid()
|
|
|
|
// purpose : Verify validity of input data
|
|
|
|
//=================================================================================
|
2012-08-09 13:58:02 +06:00
|
|
|
bool GroupGUI_GroupDlg::isValid(QString& theMessage)
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
2005-06-02 13:17:09 +06:00
|
|
|
SalomeApp_Study* study = getStudy();
|
2004-12-01 15:39:14 +05:00
|
|
|
ASSERT(study);
|
2012-08-09 13:58:02 +06:00
|
|
|
RETURN_WITH_MSG (!study->studyDS()->GetProperties()->IsLocked(), tr("GEOM_STUDY_LOCKED"))
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
if (myMode == CreateGroup) {
|
|
|
|
RETURN_WITH_MSG(!CORBA::is_nil(myMainObj), tr("NO_MAIN_OBJ"))
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
else {
|
2012-08-09 13:58:02 +06:00
|
|
|
RETURN_WITH_MSG(!CORBA::is_nil(myMainObj), tr("NO_GROUP"))
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
2006-03-13 20:11:51 +05:00
|
|
|
QString aName (getNewObjectName());
|
2012-08-09 13:58:02 +06:00
|
|
|
RETURN_WITH_MSG (!aName.trimmed().isEmpty(), tr("EMPTY_NAME"))
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
RETURN_WITH_MSG (myIdList->count(), tr("EMPTY_LIST"))
|
2004-12-01 15:39:14 +05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : execute
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2012-08-09 13:58:02 +06:00
|
|
|
bool GroupGUI_GroupDlg::execute(ObjectList& objects)
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
2012-08-09 13:58:02 +06:00
|
|
|
GEOM::GEOM_IGroupOperations_var anOper = GEOM::GEOM_IGroupOperations::_narrow(getOperation());
|
2006-02-07 20:58:35 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
GEOM::GEOM_Object_var aGroup;
|
2008-03-07 12:45:34 +05:00
|
|
|
if (myMode == CreateGroup)
|
2012-08-09 13:58:02 +06:00
|
|
|
aGroup = anOper->CreateGroup(myMainObj, getShapeType());
|
2008-03-07 12:45:34 +05:00
|
|
|
else if (myMode == EditGroup)
|
2004-12-01 15:39:14 +05:00
|
|
|
aGroup = myGroup;
|
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
if (CORBA::is_nil(aGroup) || (myMode == CreateGroup && !anOper->IsDone()))
|
2004-12-01 15:39:14 +05:00
|
|
|
return false;
|
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
GEOM::ListOfLong_var aCurrList = anOper->GetObjects(aGroup);
|
|
|
|
if (!anOper->IsDone())
|
2004-12-01 15:39:14 +05:00
|
|
|
return false;
|
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
if (aCurrList->length() > 0)
|
|
|
|
{
|
2012-08-09 13:58:02 +06:00
|
|
|
anOper->DifferenceIDs(aGroup, aCurrList);
|
|
|
|
if (!anOper->IsDone())
|
2004-12-01 15:39:14 +05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
int ii, nn = myIdList->count();
|
|
|
|
if (nn > 0)
|
|
|
|
{
|
|
|
|
GEOM::ListOfLong_var aNewList = new GEOM::ListOfLong;
|
|
|
|
aNewList->length(nn);
|
|
|
|
for (ii = 0; ii < nn; ii++) {
|
|
|
|
aNewList[ii] = myIdList->item(ii)->text().toInt();
|
|
|
|
}
|
2012-08-09 13:58:02 +06:00
|
|
|
anOper->UnionIDs(aGroup, aNewList);
|
|
|
|
if (!anOper->IsDone())
|
2004-12-01 15:39:14 +05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
SalomeApp_Study* study = getStudy();
|
2012-08-09 13:58:02 +06:00
|
|
|
if (study) {
|
|
|
|
QString objIOR = GEOMBase::GetIORFromObject(aGroup);
|
|
|
|
if (objIOR != "") {
|
|
|
|
_PTR(SObject) SO (study->studyDS()->FindObjectIOR(objIOR.toLatin1().constData()));
|
|
|
|
if (SO) {
|
2006-02-07 20:58:35 +05:00
|
|
|
_PTR(StudyBuilder) aBuilder (study->studyDS()->NewBuilder());
|
2012-08-09 13:58:02 +06:00
|
|
|
aBuilder->SetName(SO, getNewObjectName().toLatin1().constData());
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
objects.push_back(aGroup._retn());
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//================================================================
|
|
|
|
// Function : getFather
|
|
|
|
// Purpose : Get father object for object to be added in study
|
2012-08-09 13:58:02 +06:00
|
|
|
// (called with addInStudy method)
|
2004-12-01 15:39:14 +05:00
|
|
|
//================================================================
|
2012-08-09 13:58:02 +06:00
|
|
|
GEOM::GEOM_Object_ptr GroupGUI_GroupDlg::getFather(GEOM::GEOM_Object_ptr theObj)
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
|
|
|
GEOM::GEOM_Object_var aFatherObj;
|
2012-08-09 13:58:02 +06:00
|
|
|
if (theObj->GetType() == GEOM_GROUP) {
|
|
|
|
GEOM::GEOM_IGroupOperations_var anOper = GEOM::GEOM_IGroupOperations::_narrow(getOperation());
|
|
|
|
aFatherObj = anOper->GetMainShape(theObj);
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
return aFatherObj._retn();
|
|
|
|
}
|
2014-11-12 21:40:11 +05:00
|
|
|
|
|
|
|
void GroupGUI_GroupDlg::ClickOnOkFilter()
|
|
|
|
{
|
|
|
|
if (CORBA::is_nil(myMainObj) || subSelectionWay() != ALL_SUBSHAPES || !myIsShapeType || getShapeType() == TopAbs_VERTEX)
|
|
|
|
return;
|
|
|
|
|
|
|
|
TopoDS_Shape aMainShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), myMainObj);
|
|
|
|
TopTools_IndexedMapOfShape aSubShapesMap;
|
|
|
|
TopExp::MapShapes(aMainShape, aSubShapesMap);
|
|
|
|
SALOME_View* view = GEOM_Displayer::GetActiveView();
|
|
|
|
getDisplayer()->Erase(myMainObj, false, false);
|
|
|
|
CORBA::String_var aMainEntry = myMainObj->GetStudyEntry();
|
|
|
|
QString anEntryBase = aMainEntry.in();
|
|
|
|
|
|
|
|
SALOME_ListIO toSelect;
|
|
|
|
|
|
|
|
TopExp_Explorer anExp (aMainShape, (TopAbs_ShapeEnum)getShapeType());
|
|
|
|
for (; anExp.More(); anExp.Next())
|
|
|
|
{
|
|
|
|
TopoDS_Shape aSubShape = anExp.Current();
|
|
|
|
int index = aSubShapesMap.FindIndex(aSubShape);
|
|
|
|
QString anEntry = QString( "TEMP_" ) + anEntryBase + QString("_%1").arg(index);
|
|
|
|
if ( !getDisplayer()->IsDisplayed( anEntry ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
double factor = GEOMUtils::ShapeToDouble(aSubShape).second;
|
|
|
|
double v1 = myLessFilterSpin->value();
|
|
|
|
double v2 = myGreaterFilterSpin->value();
|
|
|
|
bool isLess = myLessFilterCombo->itemData(myLessFilterCombo->currentIndex()).toInt() == Filter_LT ? factor < v1 : factor <= v1;
|
|
|
|
bool isGreater = myGreaterFilterCombo->itemData(myGreaterFilterCombo->currentIndex()).toInt() == Filter_GT ? factor > v2 : factor >= v2;
|
|
|
|
if ( ( myLessFilterCheck->isChecked() && myGreaterFilterCheck->isChecked() && isLess && isGreater ) ||
|
|
|
|
( myLessFilterCheck->isChecked() && !myGreaterFilterCheck->isChecked() && isLess ) ||
|
|
|
|
( myGreaterFilterCheck->isChecked() && !myLessFilterCheck->isChecked() && isGreater ) ) {
|
|
|
|
Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject();
|
|
|
|
io->setEntry( anEntry.toLatin1().constData() );
|
|
|
|
toSelect.Append(io);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( toSelect.Extent() > 0 ) {
|
|
|
|
myGeomGUI->getApp()->selectionMgr()->setSelectedObjects(toSelect);
|
|
|
|
SUIT_MessageBox::information( this,
|
|
|
|
tr( "INF_INFO" ),
|
|
|
|
tr( "GEOM_SOME_SHAPES_SELECTED").arg( toSelect.Extent() ),
|
|
|
|
tr( "BUT_OK" ) );
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
SUIT_MessageBox::information( this,
|
|
|
|
tr( "INF_INFO" ),
|
|
|
|
tr( "GEOM_NO_SHAPES_SELECTED" ),
|
|
|
|
tr( "BUT_OK" ) );
|
|
|
|
}
|
|
|
|
updateState(true);
|
|
|
|
}
|
|
|
|
|
2015-06-11 18:03:47 +05:00
|
|
|
#ifndef DISABLE_PLOT2DVIEWER
|
2015-04-23 13:42:06 +05:00
|
|
|
//=================================================================================
|
|
|
|
// function : ClickOnPlot()
|
|
|
|
// purpose : opens "Shape Statistics" dialog box in order to plot sub-shapes distribution.
|
|
|
|
//=================================================================================
|
|
|
|
void GroupGUI_GroupDlg::ClickOnPlot()
|
|
|
|
{
|
|
|
|
TopoDS_Shape aMainShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), myMainObj);
|
|
|
|
QDialog* dlg = new MeasureGUI_ShapeStatisticsDlg( this, aMainShape, getShapeType() );
|
|
|
|
if ( dlg ) {
|
|
|
|
dlg->show();
|
|
|
|
}
|
|
|
|
}
|
2015-06-11 18:03:47 +05:00
|
|
|
#endif
|
2015-04-23 13:42:06 +05:00
|
|
|
|
2014-11-12 21:40:11 +05:00
|
|
|
void GroupGUI_GroupDlg::MeasureToggled()
|
|
|
|
{
|
|
|
|
myLessFilterSpin->setEnabled(myLessFilterCheck->isChecked());
|
|
|
|
myLessFilterCombo->setEnabled(myLessFilterCheck->isChecked());
|
|
|
|
myGreaterFilterSpin->setEnabled(myGreaterFilterCheck->isChecked());
|
|
|
|
myGreaterFilterCombo->setEnabled(myGreaterFilterCheck->isChecked());
|
|
|
|
myApplyFilterButton->setEnabled(myLessFilterCheck->isChecked() || myGreaterFilterCheck->isChecked());
|
|
|
|
}
|
2015-03-04 18:05:30 +05:00
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : getSourceObjects
|
|
|
|
// purpose : virtual method to get source objects
|
|
|
|
//=================================================================================
|
|
|
|
QList<GEOM::GeomObjPtr> GroupGUI_GroupDlg::getSourceObjects()
|
|
|
|
{
|
|
|
|
QList<GEOM::GeomObjPtr> res;
|
|
|
|
GEOM::GeomObjPtr aGeomObjPtr1(myMainObj), aGeomObjPtr2(myInPlaceObj);
|
|
|
|
res << aGeomObjPtr1 << aGeomObjPtr2;
|
|
|
|
return res;
|
|
|
|
}
|