// Module : GEOM
// $Header:
-using namespace std;
#include "BuildGUI_ShellDlg.h"
+#include "GEOMImpl_Types.hxx"
-#include "BuildGUI.h"
-#include "QAD_Desktop.h"
+#include "SUIT_Session.h"
+#include "SalomeApp_Application.h"
+#include "SalomeApp_SelectionMgr.h"
+
+#include "TColStd_MapOfInteger.hxx"
+
+#include <qlabel.h>
//=================================================================================
// class : BuildGUI_ShellDlg()
// The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog.
//=================================================================================
-BuildGUI_ShellDlg::BuildGUI_ShellDlg(QWidget* parent, const char* name, BuildGUI* theBuildGUI, SALOME_Selection* Sel, bool modal, WFlags fl)
- :GEOMBase_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
+BuildGUI_ShellDlg::BuildGUI_ShellDlg(QWidget* parent, const char* name, bool modal, WFlags fl)
+ :GEOMBase_Skeleton(parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
{
- QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM", tr("ICON_DLG_BUILD_SHELL")));
- QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM", tr("ICON_SELECT")));
+ QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_BUILD_SHELL")));
+ QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
setCaption(tr("GEOM_SHELL_TITLE"));
GroupShell->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
GroupShell->TextLabel1->setText(tr("GEOM_OBJECTS"));
GroupShell->PushButton1->setPixmap(image1);
+ GroupShell->LineEdit1->setReadOnly( true );
- Layout1->addWidget(GroupShell, 1, 0);
+ Layout1->addWidget(GroupShell, 2, 0);
/***************************************************************/
/* Initialisations */
- myBuildGUI = theBuildGUI;
Init();
}
{
/* init variables */
myEditCurrentArgument = GroupShell->LineEdit1;
- myOkListShapes = false;
-
- myFaceFilter = new GEOM_FaceFilter(StdSelect_Plane, myGeom);
- /* Filter for the next selection */
- mySelection->AddFilter(myFaceFilter) ;
+ GroupShell->LineEdit1->setReadOnly( true );
+
+ myOkFacesAndShells = false;
+
+ TColStd_MapOfInteger aMap;
+ aMap.Add(GEOM_SHELL);
+ aMap.Add(GEOM_FACE);
+ globalSelection( aMap );
/* signals and slots connections */
connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect(GroupShell->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
- connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+ connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
+ SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
- /* displays Dialog */
- GroupShell->show();
- this->show();
-
- return;
+ initName(tr("GEOM_SHELL"));
}
//=================================================================================
void BuildGUI_ShellDlg::ClickOnOk()
{
- this->ClickOnApply();
- ClickOnCancel();
- return ;
+ if ( ClickOnApply() )
+ ClickOnCancel();
}
// function : ClickOnApply()
// purpose :
//=================================================================================
-void BuildGUI_ShellDlg::ClickOnApply()
+bool BuildGUI_ShellDlg::ClickOnApply()
{
- QAD_Application::getDesktop()->putInfo(tr(""));
+ if ( !onAccept() )
+ return false;
- if(myOkListShapes)
- myBuildGUI->MakeShellAndDisplay(myListShapes);
- return;
+ initName();
+ return true;
}
//=================================================================================
void BuildGUI_ShellDlg::SelectionIntoArgument()
{
- myEditCurrentArgument->setText("");
- QString aString = "";
+ myEditCurrentArgument->setText( "" );
+ QString aString;
- myOkListShapes = false;
- int nbSel = mySelection->IObjectCount();
- if(nbSel == 0)
+ myOkFacesAndShells = false;
+ int nbSel = GEOMBase::GetNameOfSelectedIObjects( selectedIO(), aString, true );
+ if ( nbSel == 0 )
return;
+ if ( nbSel != 1 )
+ aString = QString( "%1_objects ").arg( nbSel );
- aString = tr("%1_objects").arg(nbSel);
-
- myGeomBase->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListShapes);
- myEditCurrentArgument->setText(aString);
- myOkListShapes = true;
+ GEOMBase::ConvertListOfIOInListOfGO( selectedIO(), myFacesAndShells, true );
+ if ( !myFacesAndShells.length() )
+ return;
- return;
+ myEditCurrentArgument->setText( aString );
+ myOkFacesAndShells = true;
}
void BuildGUI_ShellDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
- mySelection->ClearFilters() ;
- GroupShell->LineEdit1->setFocus();
+ if (send != GroupShell->PushButton1)
+ return;
+
+ TColStd_MapOfInteger aMap;
+ aMap.Add(GEOM_SHELL);
+ aMap.Add(GEOM_FACE);
+ globalSelection( aMap );
myEditCurrentArgument = GroupShell->LineEdit1;
- mySelection->AddFilter(myFaceFilter);
- this->SelectionIntoArgument();
- return;
+
+ myEditCurrentArgument->setFocus();
+ SelectionIntoArgument();
}
void BuildGUI_ShellDlg::ActivateThisDialog()
{
GEOMBase_Skeleton::ActivateThisDialog();
- connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
- mySelection->AddFilter(myFaceFilter);
- return;
+ connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
+ SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
+ TColStd_MapOfInteger aMap;
+ aMap.Add(GEOM_SHELL);
+ aMap.Add(GEOM_FACE);
+ globalSelection( aMap );
}
//=================================================================================
void BuildGUI_ShellDlg::enterEvent(QEvent* e)
{
- if(GroupConstructors->isEnabled())
- return;
- this->ActivateThisDialog();
- return;
+ if ( !GroupConstructors->isEnabled() )
+ ActivateThisDialog();
+}
+
+//=================================================================================
+// function : createOperation
+// purpose :
+//=================================================================================
+GEOM::GEOM_IOperations_ptr BuildGUI_ShellDlg::createOperation()
+{
+ return getGeomEngine()->GetIShapesOperations( getStudyId() );
}
+
+//=================================================================================
+// function : isValid
+// purpose :
+//=================================================================================
+bool BuildGUI_ShellDlg::isValid( QString& )
+{
+ return myOkFacesAndShells;
+}
+
+//=================================================================================
+// function : execute
+// purpose :
+//=================================================================================
+bool BuildGUI_ShellDlg::execute( ObjectList& objects )
+{
+ GEOM::GEOM_Object_var anObj;
+
+ anObj = GEOM::GEOM_IShapesOperations::_narrow(
+ getOperation() )->MakeShell( myFacesAndShells );
+
+ if ( !anObj->_is_nil() )
+ objects.push_back( anObj._retn() );
+
+ return true;
+}
+