2004-01-07 20:46:21 +05:00
|
|
|
// GEOM GEOMGUI : GUI for Geometry component
|
|
|
|
//
|
|
|
|
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
|
|
|
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
// version 2.1 of the License.
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
//
|
2006-06-01 17:32:40 +06:00
|
|
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
2004-01-07 20:46:21 +05:00
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// File : GEOMBase_Skeleton.cxx
|
|
|
|
// Author : Damien COQUERET
|
|
|
|
// Module : GEOM
|
2004-12-01 15:39:14 +05:00
|
|
|
// $Header$
|
2004-01-07 20:46:21 +05:00
|
|
|
|
|
|
|
#include "GEOMBase_Skeleton.h"
|
2006-05-06 14:44:32 +06:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
#include "GeometryGUI.h"
|
2005-06-02 13:17:09 +06:00
|
|
|
|
|
|
|
#include "SalomeApp_Application.h"
|
2006-05-06 14:44:32 +06:00
|
|
|
#include "LightApp_Application.h"
|
2005-11-03 13:30:14 +05:00
|
|
|
#include "LightApp_SelectionMgr.h"
|
2006-05-06 14:44:32 +06:00
|
|
|
#include "SUIT_Session.h"
|
|
|
|
#include "SUIT_MessageBox.h"
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
#include <qlabel.h>
|
2004-12-01 15:39:14 +05:00
|
|
|
#include <qpushbutton.h>
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2005-08-11 10:14:22 +06:00
|
|
|
using namespace std;
|
|
|
|
|
2004-01-07 20:46:21 +05:00
|
|
|
//=================================================================================
|
|
|
|
// class : GEOMBase_Skeleton()
|
|
|
|
// purpose : Constructs a GEOMBase_Skeleton which is a child of 'parent', with the
|
|
|
|
// name 'name' and widget flags set to 'f'.
|
|
|
|
// The dialog will by default be modeless, unless you set 'modal' to
|
|
|
|
// TRUE to construct a modal dialog.
|
|
|
|
//=================================================================================
|
2006-05-06 14:44:32 +06:00
|
|
|
GEOMBase_Skeleton::GEOMBase_Skeleton(GeometryGUI* theGeometryGUI, QWidget* parent,
|
|
|
|
const char* name, bool modal, WFlags fl)
|
|
|
|
: DlgRef_Skeleton_QTD( parent, name, modal, WStyle_Customize | WStyle_NormalBorder
|
|
|
|
| WStyle_Title | WStyle_SysMenu | WDestructiveClose ),
|
|
|
|
GEOMBase_Helper( dynamic_cast<SUIT_Desktop*>( parent ) ),
|
|
|
|
myGeomGUI( theGeometryGUI )
|
2004-01-07 20:46:21 +05:00
|
|
|
{
|
|
|
|
if (!name)
|
|
|
|
setName("GEOMBase_Skeleton");
|
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
GroupBoxName->setTitle(tr("GEOM_RESULT_NAME_GRP"));
|
|
|
|
NameLabel->setText(tr("GEOM_RESULT_NAME_LBL"));
|
|
|
|
|
2004-01-07 20:46:21 +05:00
|
|
|
buttonCancel->setText(tr("GEOM_BUT_CLOSE"));
|
|
|
|
buttonOk->setText(tr("GEOM_BUT_OK"));
|
|
|
|
buttonApply->setText(tr("GEOM_BUT_APPLY"));
|
2006-05-06 14:44:32 +06:00
|
|
|
buttonHelp->setText(tr("GEOM_BUT_HELP"));
|
2004-01-07 20:46:21 +05:00
|
|
|
|
|
|
|
resize(0, 0);
|
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
Init();
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ~GEOMBase_Skeleton()
|
|
|
|
// purpose : Destroys the object and frees any allocated resources
|
|
|
|
//=================================================================================
|
|
|
|
GEOMBase_Skeleton::~GEOMBase_Skeleton()
|
|
|
|
{
|
2005-06-02 13:17:09 +06:00
|
|
|
if (myGeomGUI)
|
|
|
|
myGeomGUI->SetActiveDialogBox( 0 );
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : Init()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2005-06-02 13:17:09 +06:00
|
|
|
void GEOMBase_Skeleton::Init()
|
2004-01-07 20:46:21 +05:00
|
|
|
{
|
2005-06-02 13:17:09 +06:00
|
|
|
SalomeApp_Application* app = (SalomeApp_Application*)(SUIT_Session::session()->activeApplication());
|
2006-05-06 14:44:32 +06:00
|
|
|
if (!myGeomGUI && app)
|
2006-03-13 20:11:51 +05:00
|
|
|
myGeomGUI = dynamic_cast<GeometryGUI*>( app->module( "Geometry" ) );
|
2006-05-06 14:44:32 +06:00
|
|
|
|
2004-01-07 20:46:21 +05:00
|
|
|
/* init variables */
|
2004-12-01 15:39:14 +05:00
|
|
|
myGeomGUI->SetActiveDialogBox(this);
|
2006-05-06 14:44:32 +06:00
|
|
|
|
2004-01-07 20:46:21 +05:00
|
|
|
/* signals and slots connections */
|
|
|
|
connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
|
2005-06-02 13:17:09 +06:00
|
|
|
if (myGeomGUI)
|
2006-03-13 20:11:51 +05:00
|
|
|
{
|
|
|
|
connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
|
|
|
|
connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
|
|
|
|
}
|
2006-05-06 14:44:32 +06:00
|
|
|
|
|
|
|
// connect help button on a private slot that displays help information
|
|
|
|
connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( ClickOnHelp() ) );
|
2004-01-07 20:46:21 +05:00
|
|
|
|
|
|
|
/* displays Dialog */
|
|
|
|
RadioButton1->setChecked(TRUE);
|
2004-12-01 15:39:14 +05:00
|
|
|
RadioButton4->hide();
|
2004-01-07 20:46:21 +05:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ClickOnCancel()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void GEOMBase_Skeleton::ClickOnCancel()
|
|
|
|
{
|
2004-12-01 15:39:14 +05:00
|
|
|
close();
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : LineEditReturnPressed()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void GEOMBase_Skeleton::LineEditReturnPressed()
|
|
|
|
{
|
2005-01-20 19:23:35 +05:00
|
|
|
if ( !myEditCurrentArgument )
|
|
|
|
return;
|
|
|
|
|
2004-01-07 20:46:21 +05:00
|
|
|
/* User name of object input management */
|
|
|
|
/* If successfull the selection is changed and signal emitted... */
|
|
|
|
/* so SelectionIntoArgument() is automatically called. */
|
|
|
|
const QString objectUserName = myEditCurrentArgument->text();
|
|
|
|
QWidget* thisWidget = (QWidget*)this;
|
2005-06-02 13:17:09 +06:00
|
|
|
|
|
|
|
if(GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, selectedIO()))
|
|
|
|
myEditCurrentArgument->setText(objectUserName);
|
2004-01-07 20:46:21 +05:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : DeactivateActiveDialog()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void GEOMBase_Skeleton::DeactivateActiveDialog()
|
|
|
|
{
|
|
|
|
this->setEnabled(false);
|
2004-12-01 15:39:14 +05:00
|
|
|
globalSelection();
|
2005-06-02 13:17:09 +06:00
|
|
|
disconnect( ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0);
|
|
|
|
if (myGeomGUI) myGeomGUI->SetActiveDialogBox(0);
|
|
|
|
|
2004-01-07 20:46:21 +05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ActivateThisDialog()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void GEOMBase_Skeleton::ActivateThisDialog()
|
|
|
|
{
|
|
|
|
/* Emit a signal to deactivate the active dialog */
|
2005-06-02 13:17:09 +06:00
|
|
|
if (myGeomGUI) myGeomGUI->EmitSignalDeactivateDialog();
|
2004-01-07 20:46:21 +05:00
|
|
|
this->setEnabled(true);
|
2005-06-02 13:17:09 +06:00
|
|
|
if (myGeomGUI) myGeomGUI->SetActiveDialogBox((QDialog*)this);
|
2004-01-07 20:46:21 +05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : closeEvent()
|
2004-12-01 15:39:14 +05:00
|
|
|
// purpose : same than click on cancel button
|
2004-01-07 20:46:21 +05:00
|
|
|
//=================================================================================
|
|
|
|
void GEOMBase_Skeleton::closeEvent(QCloseEvent* e)
|
|
|
|
{
|
2005-06-30 13:14:30 +06:00
|
|
|
SalomeApp_Application* app = (SalomeApp_Application*)(SUIT_Session::session()->activeApplication());
|
|
|
|
if(app) {
|
|
|
|
disconnect( app->selectionMgr(), 0, this, 0);
|
|
|
|
app->updateActions();
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
QDialog::closeEvent( e );
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : initName()
|
|
|
|
// purpose : initialize the Name field with a string "thePrefix_X" (Vertex_3)
|
|
|
|
//=================================================================================
|
|
|
|
void GEOMBase_Skeleton::initName( const char* thePrefix )
|
|
|
|
{
|
|
|
|
if ( thePrefix )
|
|
|
|
setPrefix( thePrefix );
|
|
|
|
ResultName->setText( GEOMBase::GetDefaultName( getPrefix() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : getNewObjectName()
|
|
|
|
// purpose : returns contents of Name field
|
|
|
|
//=================================================================================
|
|
|
|
const char* GEOMBase_Skeleton::getNewObjectName() const
|
|
|
|
{
|
|
|
|
return ResultName->text();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : getConstructorId()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
int GEOMBase_Skeleton::getConstructorId() const
|
|
|
|
{
|
|
|
|
if ( GroupConstructors != NULL && GroupConstructors->selected() != NULL )
|
|
|
|
return GroupConstructors->id( GroupConstructors->selected() );
|
|
|
|
return -1;
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
2006-05-06 14:44:32 +06:00
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ClickOnHelp()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void GEOMBase_Skeleton::ClickOnHelp()
|
|
|
|
{
|
|
|
|
LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
|
|
|
|
if (app)
|
|
|
|
app->onHelpContextModule(myGeomGUI ? app->moduleName(myGeomGUI->moduleName()) : QString(""), myHelpFileName);
|
|
|
|
else {
|
2008-03-07 12:45:34 +05:00
|
|
|
QString platform;
|
|
|
|
#ifdef WIN32
|
|
|
|
platform = "winapplication";
|
|
|
|
#else
|
|
|
|
platform = "application";
|
|
|
|
#endif
|
2006-05-06 14:44:32 +06:00
|
|
|
SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
|
|
|
|
QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
|
2008-03-07 12:45:34 +05:00
|
|
|
arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
|
2006-05-06 14:44:32 +06:00
|
|
|
QObject::tr("BUT_OK"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//=================================================================================
|
|
|
|
// function : setHelpFileName()
|
|
|
|
// purpose : set name for help file html
|
|
|
|
//=================================================================================
|
|
|
|
|
|
|
|
void GEOMBase_Skeleton::setHelpFileName(const QString& theName)
|
|
|
|
{
|
|
|
|
myHelpFileName = theName;
|
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : keyPressEvent()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void GEOMBase_Skeleton::keyPressEvent( QKeyEvent* e )
|
|
|
|
{
|
|
|
|
QDialog::keyPressEvent( e );
|
|
|
|
if ( e->isAccepted() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ( e->key() == Key_F1 )
|
|
|
|
{
|
|
|
|
e->accept();
|
|
|
|
ClickOnHelp();
|
|
|
|
}
|
|
|
|
}
|