-// SUIT_ViewWindow* v = vm->getActiveView();
- QString vmType = vm->getType();
- if ( (vmType == SVTK_Viewer::Type()) || (vmType == VTKViewer_Viewer::Type()) ){
- mainFrame()->_vertex_le->setFocus();
- } else if ( vmType == OCCViewer_Viewer::Type() ){
-// lines_lw->setFocus();
-// ConstructorsClicked(0);
- ConstructorsClicked( getConstructorId() );
- }
-}
-
-// ============================================================== _isLineOrListWidget
-/*
- * Return true is the widget is a line or a list
- * false otherwise.
- */
-bool MyBasicGUI_PointDlg::_isLineOrListWidget(QObject *widget)
-{
- if (widget == NULL) return false;
-
- QLineEdit *lineEdit = dynamic_cast<QLineEdit*>(widget);
- QListWidget *listWidget = dynamic_cast<QListWidget*>(widget);
- return (lineEdit != NULL) || (listWidget != NULL);
-
-}//_isLineOrListWidget
-
-
-
-// ============================================================== _highlightWidget
-/*
- * Highlight the given widget with the given color.
- */
-void MyBasicGUI_PointDlg::_highlightWidget(QObject *obj, Qt::GlobalColor clr)
-{
- if (!_isLineOrListWidget(obj)) return;
-
- QWidget *widget = dynamic_cast<QWidget*>(obj); //sure it's not NULL (_isLineOrListWidget(obj))
- QPalette palette1 = widget->palette();
- palette1.setColor(widget->backgroundRole(), clr);
- widget->setPalette(palette1);
-
-}//_highlightWidget
-
-
-bool MyBasicGUI_PointDlg::eventFilter(QObject *obj, QEvent *event)
-{
-
-// if (event->type() == QEvent::FocusOut)
-// _highlightWidget(obj, Qt::white);
-//
-// else
- if ( (event->type() != QEvent::FocusIn)
- or (obj != mainFrame()->_vertex_le) ){
- return MyGEOMBase_Skeleton::eventFilter(obj, event);
- }
-// _highlightWidget(obj, Qt::yellow);
-
- QVariant vxVariant;
- QModelIndex vxIndex;
-
- _currentObj = obj;
-// HEXABLOCKGUI::currentVtkView->raise();
- HEXABLOCKGUI::currentDocGView->setVertexSelection();
-
- vxVariant = mainFrame()->_vertex_le->property("QModelIndex");
- if ( !vxVariant.isValid() ) {
- return MyGEOMBase_Skeleton::eventFilter(obj, event);
- }
- vxIndex = vxVariant.value<QModelIndex>();
- _selectionMutex = true;
- _patternDataSelectionModel->select( vxIndex, QItemSelectionModel::Clear );
- _patternDataSelectionModel->select( vxIndex, QItemSelectionModel::Select );
- _selectionMutex = false;
- return false;
-}
-
-
-void MyBasicGUI_PointDlg::hideEvent ( QHideEvent * event )
-{
- disconnect( _patternDataSelectionModel, SIGNAL( selectionChanged ( const QItemSelection &, const QItemSelection &) ),
- this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
-
- //Disconnection salome selection signals
- if (HEXABLOCKGUI::selectionMgr() != NULL)
- disconnect( HEXABLOCKGUI::selectionMgr() , SIGNAL(currentSelectionChanged()),
- this, SLOT(onCurrentSelectionChanged()) );
-
- //Disconnect vtk window activation signals
- if (HEXABLOCKGUI::currentDocGView->getViewWindow() != NULL)
- disconnect( HEXABLOCKGUI::currentDocGView->getViewWindow()->getViewManager(),
- SIGNAL( activated(SUIT_ViewManager*) ),
- this, SLOT( onWindowActivated(SUIT_ViewManager*) ) );
-
- //Disconnect occ window activation signals
- if (HEXABLOCKGUI::currentOccGView->getViewWindow() != NULL)
- disconnect( HEXABLOCKGUI::currentOccGView->getViewWindow()->getViewManager(),
- SIGNAL( activated(SUIT_ViewManager*) ),
- this, SLOT( onWindowActivated(SUIT_ViewManager*) ) );
-
- _documentModel->allowEdition();
- DeactivateActiveDialog();
- MyGEOMBase_Skeleton::hideEvent( event );
-}
-
-void MyBasicGUI_PointDlg::showEvent( QShowEvent * event )
-{
- _documentModel->disallowEdition();
- // _patternDataSelectionModel->clearSelection();
- connect( _patternDataSelectionModel, SIGNAL( selectionChanged ( const QItemSelection &, const QItemSelection &) ),
- this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
-
- //Connect to salome selection signals
- if (HEXABLOCKGUI::selectionMgr() != NULL)
- {
- connect( HEXABLOCKGUI::selectionMgr(), SIGNAL(currentSelectionChanged()),
- this, SLOT(onCurrentSelectionChanged()), Qt::UniqueConnection );
- }
-
- //Connect to vtk window activation signals
- if (HEXABLOCKGUI::currentDocGView->getViewWindow() != NULL)
- {
- connect( HEXABLOCKGUI::currentDocGView->getViewWindow()->getViewManager(), SIGNAL( activated(SUIT_ViewManager*) ),
- this, SLOT( onWindowActivated(SUIT_ViewManager*) ), Qt::UniqueConnection );
- }
-
- //connect to occ window activation signals
- if (HEXABLOCKGUI::currentOccGView->getViewWindow() != NULL)
- {
- connect( HEXABLOCKGUI::currentOccGView->getViewWindow()->getViewManager(),
- SIGNAL( activated(SUIT_ViewManager*) ),
- this, SLOT( onWindowActivated(SUIT_ViewManager*) ), Qt::UniqueConnection );
- }
-
-// connect( _mgr, SIGNAL(currentSelectionChanged()), this, SLOT(onCurrentSelectionChanged()) );
-// connect( _vtkVm, SIGNAL( activated(SUIT_ViewManager*) ), this, SLOT( onWindowActivated(SUIT_ViewManager*) ) );
-// connect( _occVm, SIGNAL( activated(SUIT_ViewManager*) ), this, SLOT( onWindowActivated(SUIT_ViewManager*) ) );
-
-
- SalomeApp_Application* app = (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() );
-
- if ( !myGeomGUI && app )
- myGeomGUI = dynamic_cast<GeometryGUI*>( app->module( "Geometry" ) );
-
-
- ActivateThisDialog();
- MyGEOMBase_Skeleton::showEvent ( event );
-}
-
-
-
-
-bool MyBasicGUI_PointDlg::onAccept( const bool publish, const bool useTransaction )
-{
-
- GEOM::GEOM_Object_ptr newVertex;
- QString newVertexEntry;
- QString newVertexName;
- QString newVertexBrep;
- gp_Pnt aPnt;
-
-
-
- SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
- if ( !appStudy ) return false;
- _PTR(Study) aStudy = appStudy->studyDS();
-
- bool aLocked = (_PTR(AttributeStudyProperties) (aStudy->GetProperties()))->IsLocked();
- if ( aLocked ) {
- SUIT_MessageBox::warning ( (QWidget*)SUIT_Session::session()->activeApplication()->desktop(),
- QObject::tr("WRN_WARNING"),
- QObject::tr("WRN_STUDY_LOCKED"),
- QObject::tr("BUT_OK") );
- return false;
- }
-
- QString msg;
- if ( !isValid( msg ) ) {
- showError( msg );
- return false;
- }
-
- erasePreview( false );
-
- bool result = false;
-
- try {
- if ( ( !publish && !useTransaction ) || openCommand() ) {
- SUIT_OverrideCursor wc;
- SUIT_Session::session()->activeApplication()->putInfo( "" );
- ObjectList objects;
- if ( !execute( objects ) || !getOperation()->IsDone() ) {
- wc.suspend();
- abortCommand();
- showError();
- }
- else {
- addSubshapesToStudy(); // add Subshapes if local selection
- const int nbObjs = objects.size();
- QStringList anEntryList;
- int aNumber = 1;
- for ( ObjectList::iterator it = objects.begin(); it != objects.end(); ++it ) {
- GEOM::GEOM_Object_var obj=*it;
- if ( publish ) {
- QString aName = getNewObjectName();
- if ( nbObjs > 1 ) {
- if (aName.isEmpty())
- aName = getPrefix(obj);
- if (nbObjs <= 30) {
- // Try to find a unique name
- aName = GEOMBase::GetDefaultName(aName, extractPrefix());
- } else {
- // Don't check name uniqueness in case of numerous objects
- aName = aName + "_" + QString::number(aNumber++);
- }
- } else {
- // PAL6521: use a prefix, if some dialog box doesn't reimplement getNewObjectName()
- if ( aName.isEmpty() )
- aName = GEOMBase::GetDefaultName( getPrefix( obj ) );
- }
- anEntryList << addInStudy( obj, aName.toLatin1().constData() );
-
- newVertex = obj;
- newVertexEntry = anEntryList[0];
- TopoDS_Shape aShape;
- GEOMBase::GetShape( newVertex, aShape );
- if ( !aShape.IsNull() ){
- newVertexName = GEOMBase::GetName( newVertex );
- newVertexBrep = HEXABLOCK::GUI::shape2string( aShape ).c_str();
- aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
- }
-
- // updateView=false
- display( obj, false );
-#ifdef WITHGENERICOBJ
- // obj has been published in study. Its refcount has been incremented.
- // It is safe to decrement its refcount
- // so that it will be destroyed when the entry in study will be removed
- obj->UnRegister();
-#endif
- }
- else {
- // asv : fix of PAL6454. If publish==false, then the original shape
- // was modified, and need to be re-cached in GEOM_Client before redisplay
-// clearShapeBuffer( obj );
- // withChildren=true, updateView=false
- redisplay( obj, true, false );
- }
- }
-
- if ( nbObjs ) {
- commitCommand();
- updateObjBrowser();
- if( SUIT_Application* anApp = SUIT_Session::session()->activeApplication() ) {
- if( LightApp_Application* aLightApp = dynamic_cast<LightApp_Application*>( anApp ) ){
- aLightApp->browseObjects( anEntryList, isApplyAndClose(), isOptimizedBrowsing() );
- }
- anApp->putInfo( QObject::tr("GEOM_PRP_DONE") );
- }
- result = true;
- }
- else
- abortCommand();
- }
- }
- }
- catch( const SALOME::SALOME_Exception& e ) {
- SalomeApp_Tools::QtCatchCorbaException( e );
- abortCommand();
- }
-
- updateViewer();
-
- if (result){
- SUIT_OverrideCursor wc;
- if ( !_documentModel ) return false;
- if ( !_patternDataSelectionModel ) return false;
- const HEXABLOCK::GUI::PatternDataModel* patternDataModel = dynamic_cast<const HEXABLOCK::GUI::PatternDataModel*>( _patternDataSelectionModel->model() );
- if ( !patternDataModel ) return false;
- _currentObj = NULL;
-
- QVariant v = mainFrame()->_vertex_le->property("QModelIndex");
- if ( !v.isValid() ) return false;
- QModelIndex iVertex = patternDataModel->mapToSource( v.value<QModelIndex>() );
-
- if ( iVertex.isValid() ){
- HEXABLOCK::GUI::DocumentModel::GeomObj aPoint;
- aPoint.shapeName = newVertexName;
- aPoint.subid = QString::number(-1);
- aPoint.brep = newVertexBrep;
- _documentModel->setGeomObjName(newVertexEntry, newVertexName);
- _documentModel->setGeomObjEntry(newVertexName, newVertexEntry);
-// _documentModel->addAssociation( iVertex, aPoint );
- _documentModel->setVertexAssociation(iVertex, aPnt.X(), aPnt.Y(), aPnt.Z());
- // to select/highlight result
-// _patternDataSelectionModel->clearSelection();
-// mainFrame()->_vertex_le->setFocus();
-
-// globalSelection(HEXABLOCKGUI::currentOccGView->getViewWindow());
-// localSelection(HEXABLOCKGUI::currentOccGView->getViewWindow(), TopAbs_VERTEX);
- _patternDataSelectionModel->select( patternDataModel->mapFromSource(iVertex), QItemSelectionModel::Clear );
- _patternDataSelectionModel->select( patternDataModel->mapFromSource(iVertex), QItemSelectionModel::Select );
- _currentObj = NULL;
- result = true;
- } else {
- SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT MAKE VERTEX ASSOCIATION" ) );
- return false;