+/*!
+ \brief SLOT called when "Ok" button pressed performs operation and closes dialog box
+*/
+void SMESHGUI_GroupOpDlg::onOk()
+{
+ SUIT_OverrideCursor oc;
+ setIsApplyAndClose( true );
+ if ( onApply() )
+ reject();
+ setIsApplyAndClose( false );
+}
+
+/*!
+ \brief SLOT called when dialog is closed
+*/
+void SMESHGUI_GroupOpDlg::reject()
+{
+ if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+ aViewWindow->SetSelectionMode(ActorSelection);
+ disconnect( mySelectionMgr, 0, this, 0 );
+ disconnect( mySMESHGUI, 0, this, 0 );
+ mySMESHGUI->ResetState();
+ mySelectionMgr->clearFilters();
+ reset();
+ QDialog::reject();
+}
+
+//=================================================================================
+// function : onOpenView()
+// purpose :
+//=================================================================================
+void SMESHGUI_GroupOpDlg::onOpenView()
+{
+ if ( mySelector ) {
+ SMESH::SetPointRepresentation(false);
+ }
+ else {
+ mySelector = SMESH::GetViewWindow( mySMESHGUI )->GetSelector();
+ mySMESHGUI->EmitSignalDeactivateDialog();
+ setEnabled(true);
+ }
+}
+
+//=================================================================================
+// function : onCloseView()
+// purpose :
+//=================================================================================
+void SMESHGUI_GroupOpDlg::onCloseView()
+{
+ onDeactivate();
+ mySelector = 0;
+}
+
+/*!
+ \brief SLOT called when "Help" button pressed shows "Help" page
+*/
+void SMESHGUI_GroupOpDlg::onHelp()
+{
+ LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
+ if (app)
+ app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
+ else {
+ QString platform;
+#ifdef WIN32
+ platform = "winapplication";
+#else
+ platform = "application";
+#endif
+ SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
+ tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
+ arg(app->resourceMgr()->stringValue("ExternalBrowser",
+ platform)).
+ arg(myHelpFileName));
+ }
+}
+
+/*!
+ \brief Gets list of currently selected groups from selection manager
+ \param theOutList out list of groups
+ \param theOutNames out list of group of group names
+ \return TRUE if operation theOutList is not empty, FALSE otherwise
+*/
+bool SMESHGUI_GroupOpDlg::getSelectedGroups( QList<SMESH::SMESH_GroupBase_var>& theOutList,
+ QStringList& theOutNames )
+{
+ theOutList.clear();
+
+ theOutList.clear();
+ theOutNames.clear();
+
+ SALOME_ListIO aListIO;
+ mySelectionMgr->selectedObjects( aListIO );
+ SALOME_ListIteratorOfListIO anIter ( aListIO );
+ for ( ; anIter.More(); anIter.Next())
+ {
+ SMESH::SMESH_GroupBase_var aGroup =
+ SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(anIter.Value());
+ if ( !aGroup->_is_nil())
+ {
+ theOutList.append( aGroup );
+ theOutNames.append( aGroup->GetName() );
+ }
+ }
+
+ return theOutList.count() > 0;
+}
+
+/*!
+ \brief Converts QT-list of group to the list acceptable by IDL interface
+ \param theIn input list
+ \return list acceptable by IDL interface
+*/
+SMESH::ListOfGroups* SMESHGUI_GroupOpDlg::convert(
+ const QList<SMESH::SMESH_GroupBase_var>& theIn )
+{
+ SMESH::ListOfGroups_var aList = new SMESH::ListOfGroups();
+ aList->length( theIn.count() );
+
+ QList<SMESH::SMESH_GroupBase_var>::const_iterator anIter = theIn.begin();
+ for ( int i = 0; anIter != theIn.end(); ++anIter, ++i )
+ aList[ i ] = *anIter;
+
+ return aList._retn();
+}
+
+/*!
+ \brief Get color to be assigned to group
+ \return color to be assigned to group
+*/
+SALOMEDS::Color SMESHGUI_GroupOpDlg::getColor() const
+{
+ QColor aQColor = myColorBtn->color();
+
+ SALOMEDS::Color aColor;
+ aColor.R = (float)aQColor.red() / 255.0;
+ aColor.G = (float)aQColor.green() / 255.0;
+ aColor.B = (float)aQColor.blue() / 255.0;
+
+ return aColor;
+}
+
+/*!
+ \brief Set default color for group
+*/
+void SMESHGUI_GroupOpDlg::setDefaultGroupColor()
+{
+ myColorBtn->setColor( SMESH::GetColor( "SMESH", "default_grp_color", QColor( 255, 170, 0 ) ) );
+}
+
+/*!
+ \brief SLOT, called when selection is changed. Current implementation does
+ nothing. The method should be redefined in derived classes to update
+ corresponding GUI controls
+*/
+void SMESHGUI_GroupOpDlg::onSelectionDone()
+{
+}
+
+/*!
+ \brief Calls onSelectionDone() and setVisible() method of base class
+ \param visible the visible state of the dialog
+*/
+void SMESHGUI_GroupOpDlg::setVisible( bool visible )
+{
+ if ( visible )
+ {
+ onSelectionDone();
+ resize( minimumSizeHint().width(), sizeHint().height() );
+ }
+ QDialog::setVisible( visible );
+}
+
+/*!
+ \brief SLOT called when dialog must be deactivated
+*/
+void SMESHGUI_GroupOpDlg::onDeactivate()
+{
+ setEnabled(false);
+ mySelectionMgr->clearFilters();
+}
+
+/*!
+ \brief Event filter updates selection mode and selection filter. This virtual method
+ is redefined from the base class it is called when dialog obtains input focus
+*/
+void SMESHGUI_GroupOpDlg::enterEvent(QEvent*)
+{
+ mySMESHGUI->EmitSignalDeactivateDialog();
+ setEnabled(true);
+ SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
+ if ( aViewWindow ) {
+ aViewWindow->SetSelectionMode(ActorSelection);
+ if (!mySelector)
+ mySelector = aViewWindow->GetSelector();
+ }
+ mySelectionMgr->installFilter(new SMESH_TypeFilter (SMESH::GROUP));
+}
+
+/*!
+ \brief Resets state of the dialog, initializes its fields with default value, etc.
+ Usually called by onApply() slot to reinitialize dialog fields. This virtual method
+ should be redefined in derived class to update its own fileds
+*/
+void SMESHGUI_GroupOpDlg::reset()
+{
+ myNameEdit->setText("");
+ myNameEdit->setFocus();
+ setDefaultGroupColor();
+}
+
+/*!
+ \brief Gets name of group to be created
+ \return name of group to be created
+ \sa setName()
+*/
+QString SMESHGUI_GroupOpDlg::getName() const
+{
+ return myNameEdit->text();
+}
+
+/*!
+ \brief Sets name of group to be created
+ \param theName name of group to be created
+ \sa getName()
+*/
+void SMESHGUI_GroupOpDlg::setName( const QString& theName )
+{
+ myNameEdit->setText( theName );
+}
+
+/*!
+ \brief Provides reaction on �F1� button pressing
+ \param e key press event
+*/
+void SMESHGUI_GroupOpDlg::keyPressEvent( QKeyEvent* e )
+{
+ QDialog::keyPressEvent( e );
+ if ( e->isAccepted() )
+ return;
+
+ if ( e->key() == Qt::Key_F1 ) {
+ e->accept();
+ onHelp();
+ }
+}
+
+/*!
+ \brief This virtual slot does nothing and should be redefined in derived classes
+ \return return false;
+*/