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 : MeasureGUI_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 "MeasureGUI_Skeleton.h"
|
2004-12-01 15:39:14 +05:00
|
|
|
#include "GEOMBase.h"
|
|
|
|
#include "GEOM_Displayer.h"
|
|
|
|
#include "GeometryGUI.h"
|
2005-06-02 13:17:09 +06:00
|
|
|
|
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 "SalomeApp_Application.h"
|
2005-06-02 13:17:09 +06:00
|
|
|
#include "SalomeApp_Tools.h"
|
2006-05-06 14:44:32 +06:00
|
|
|
#include "SUIT_MessageBox.h"
|
2005-06-02 13:17:09 +06:00
|
|
|
#include "SUIT_Session.h"
|
2005-06-10 18:43:15 +06:00
|
|
|
#include "SUIT_OverrideCursor.h"
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
#include <qlineedit.h>
|
|
|
|
#include <qlayout.h>
|
|
|
|
#include <qpushbutton.h>
|
|
|
|
#include <qradiobutton.h>
|
|
|
|
#include <qbuttongroup.h>
|
2005-06-02 13:17:09 +06:00
|
|
|
#include <qapplication.h>
|
2004-01-07 20:46:21 +05:00
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// class : MeasureGUI_Skeleton()
|
|
|
|
// purpose : Constructs a MeasureGUI_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.
|
|
|
|
//=================================================================================
|
2005-06-02 13:17:09 +06:00
|
|
|
MeasureGUI_Skeleton::MeasureGUI_Skeleton( GeometryGUI* GUI,
|
|
|
|
QWidget* parent,
|
|
|
|
const char* name )
|
2004-12-01 15:39:14 +05:00
|
|
|
: MeasureGUI_Skeleton_QTD( parent, name, false,
|
2005-06-02 13:17:09 +06:00
|
|
|
WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ),
|
2005-08-02 18:45:47 +06:00
|
|
|
GEOMBase_Helper( dynamic_cast<SUIT_Desktop*>( parent ) ),
|
2005-06-02 13:17:09 +06:00
|
|
|
myGeomGUI( GUI )
|
2004-01-07 20:46:21 +05:00
|
|
|
{
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
mySelBtn = 0;
|
|
|
|
mySelEdit = 0;
|
|
|
|
myDisplayer = 0;
|
2006-05-06 14:44:32 +06:00
|
|
|
myHelpFileName = "";
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
if ( !name )
|
|
|
|
setName( "MeasureGUI_Skeleton" );
|
|
|
|
|
|
|
|
buttonClose->setText( tr( "GEOM_BUT_CLOSE" ) );
|
2006-05-06 14:44:32 +06:00
|
|
|
buttonHelp->setText(tr("GEOM_BUT_HELP"));
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
buttonClose->setAutoDefault( false );
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
GroupMedium->close( TRUE );
|
|
|
|
resize( 350, 0 );
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ~MeasureGUI_Skeleton()
|
|
|
|
// purpose : Destroys the object and frees any allocated resources
|
|
|
|
//=================================================================================
|
|
|
|
MeasureGUI_Skeleton::~MeasureGUI_Skeleton()
|
|
|
|
{
|
2004-12-01 15:39:14 +05:00
|
|
|
myGeomGUI->SetActiveDialogBox( 0 );
|
|
|
|
delete myDisplayer;
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : Init()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2005-06-02 13:17:09 +06:00
|
|
|
void MeasureGUI_Skeleton::Init()
|
2004-01-07 20:46:21 +05:00
|
|
|
{
|
|
|
|
/* init variables */
|
|
|
|
myGeomGUI->SetActiveDialogBox((QDialog*)this);
|
|
|
|
|
|
|
|
/* signals and slots connections */
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
connect( buttonClose, SIGNAL( clicked() ),
|
|
|
|
this, SLOT( ClickOnCancel() ) );
|
2006-05-06 14:44:32 +06:00
|
|
|
|
|
|
|
connect( buttonHelp, SIGNAL( clicked() ),
|
|
|
|
this, SLOT( ClickOnHelp() ) );
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ),
|
|
|
|
this, SLOT ( DeactivateActiveDialog() ) );
|
|
|
|
|
|
|
|
connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ),
|
|
|
|
this, SLOT ( ClickOnCancel() ) );
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
connect( mySelEdit, SIGNAL( returnPressed() ),
|
|
|
|
this, SLOT( LineEditReturnPressed() ) );
|
|
|
|
|
|
|
|
connect( mySelBtn, SIGNAL( clicked() ),
|
|
|
|
this, SLOT ( SetEditCurrentArgument() ) );
|
|
|
|
|
2005-11-03 13:30:14 +05:00
|
|
|
LightApp_SelectionMgr* aSel = ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr();
|
2005-06-02 13:17:09 +06:00
|
|
|
if ( aSel )
|
|
|
|
connect( aSel, SIGNAL( currentSelectionChanged() ),
|
|
|
|
this, SLOT ( SelectionIntoArgument() ) ) ;
|
2004-01-07 20:46:21 +05:00
|
|
|
|
|
|
|
/* displays Dialog */
|
2004-12-01 15:39:14 +05:00
|
|
|
RadioButton1->setChecked( TRUE );
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
activateSelection();
|
|
|
|
SelectionIntoArgument();
|
|
|
|
show();
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ClickOnCancel()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void MeasureGUI_Skeleton::ClickOnCancel()
|
|
|
|
{
|
2004-12-01 15:39:14 +05:00
|
|
|
close();
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
|
2006-05-06 14:44:32 +06:00
|
|
|
//=================================================================================
|
|
|
|
// function : ClickOnHelp()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void MeasureGUI_Skeleton::ClickOnHelp()
|
|
|
|
{
|
|
|
|
LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
|
|
|
|
if (app)
|
|
|
|
app->onHelpContextModule(myGeomGUI ? app->moduleName(myGeomGUI->moduleName()) : QString(""), myHelpFileName);
|
|
|
|
else {
|
|
|
|
SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
|
|
|
|
QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
|
|
|
|
arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(myHelpFileName),
|
|
|
|
QObject::tr("BUT_OK"));
|
|
|
|
}
|
|
|
|
}
|
2004-01-07 20:46:21 +05:00
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : LineEditReturnPressed()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void MeasureGUI_Skeleton::LineEditReturnPressed()
|
|
|
|
{
|
|
|
|
/* User name of object input management */
|
|
|
|
/* If successfull the selection is changed and signal emitted... */
|
|
|
|
/* so SelectionIntoArgument() is automatically called. */
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
const QString objectUserName = mySelEdit->text();
|
|
|
|
QWidget* thisWidget = ( QWidget* )this;
|
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
if ( GEOMBase::SelectionByNameInDialogs( thisWidget, objectUserName, selectedIO() ) )
|
2004-12-01 15:39:14 +05:00
|
|
|
mySelEdit->setText( objectUserName );
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : DeactivateActiveDialog()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void MeasureGUI_Skeleton::DeactivateActiveDialog()
|
|
|
|
{
|
2004-12-01 15:39:14 +05:00
|
|
|
setEnabled( false );
|
|
|
|
|
2005-11-03 13:30:14 +05:00
|
|
|
LightApp_SelectionMgr* aSel = ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr();
|
2005-06-02 13:17:09 +06:00
|
|
|
if ( aSel )
|
|
|
|
disconnect( aSel, 0, this, 0 );
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
myGeomGUI->SetActiveDialogBox( 0 );
|
|
|
|
|
|
|
|
globalSelection();
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ActivateThisDialog()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void MeasureGUI_Skeleton::ActivateThisDialog()
|
|
|
|
{
|
|
|
|
myGeomGUI->EmitSignalDeactivateDialog();
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
setEnabled( true );
|
|
|
|
|
|
|
|
myGeomGUI->SetActiveDialogBox( ( QDialog* )this );
|
|
|
|
|
2005-11-03 13:30:14 +05:00
|
|
|
LightApp_SelectionMgr* aSel = ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr();
|
2005-06-02 13:17:09 +06:00
|
|
|
if ( aSel )
|
|
|
|
connect( aSel, SIGNAL( currentSelectionChanged() ),
|
|
|
|
this, SLOT ( SelectionIntoArgument() ) ) ;
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
redisplayPreview();
|
|
|
|
activateSelection();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : SetEditCurrentArgument
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void MeasureGUI_Skeleton::SetEditCurrentArgument()
|
|
|
|
{
|
|
|
|
mySelEdit->setFocus();
|
|
|
|
SelectionIntoArgument();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : SelectionIntoArgument
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void MeasureGUI_Skeleton::SelectionIntoArgument()
|
|
|
|
{
|
|
|
|
myObj = GEOM::GEOM_Object::_nil();
|
|
|
|
|
|
|
|
Standard_Boolean testResult = Standard_False;
|
|
|
|
GEOM::GEOM_Object_var aSelectedObject =
|
2005-06-02 13:17:09 +06:00
|
|
|
GEOMBase::ConvertIOinGEOMObject( firstIObject(), testResult );
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
if( !testResult || aSelectedObject->_is_nil() )
|
|
|
|
{
|
|
|
|
mySelEdit->setText( "" );
|
|
|
|
processObject();
|
|
|
|
erasePreview();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
myObj = aSelectedObject;
|
|
|
|
mySelEdit->setText( GEOMBase::GetName( myObj ) );
|
|
|
|
processObject();
|
|
|
|
redisplayPreview();
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
//=================================================================================
|
|
|
|
// function : processObject
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void MeasureGUI_Skeleton::processObject()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : closeEvent
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void MeasureGUI_Skeleton::closeEvent( QCloseEvent* e )
|
|
|
|
{
|
2005-11-03 13:30:14 +05:00
|
|
|
LightApp_SelectionMgr* aSel = ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr();
|
2005-06-02 13:17:09 +06:00
|
|
|
if ( aSel )
|
|
|
|
disconnect( aSel, 0, this, 0 );
|
2004-12-01 15:39:14 +05:00
|
|
|
QDialog::closeEvent( e );
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : enterEvent()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void MeasureGUI_Skeleton::enterEvent(QEvent* e)
|
|
|
|
{
|
|
|
|
if ( GroupConstructors->isEnabled() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
ActivateThisDialog();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : buildPrs
|
|
|
|
// purpose : Build presentation for "preview"
|
|
|
|
//=================================================================================
|
|
|
|
SALOME_Prs* MeasureGUI_Skeleton::buildPrs()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2004-01-07 20:46:21 +05:00
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : closeEvent()
|
2004-12-01 15:39:14 +05:00
|
|
|
// purpose : Build presentation for "preview"
|
|
|
|
//=================================================================================
|
|
|
|
void MeasureGUI_Skeleton::redisplayPreview()
|
|
|
|
{
|
|
|
|
QString aMess;
|
|
|
|
if ( !isValid( aMess ) )
|
|
|
|
{
|
|
|
|
erasePreview( true );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
erasePreview( false );
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2005-06-10 18:43:15 +06:00
|
|
|
SUIT_OverrideCursor();
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
getDisplayer()->SetColor( Quantity_NOC_VIOLET );
|
|
|
|
getDisplayer()->SetToActivate( false );
|
|
|
|
|
|
|
|
if ( SALOME_Prs* aPrs = buildPrs() )
|
|
|
|
displayPreview( aPrs );
|
|
|
|
}
|
|
|
|
catch( const SALOME::SALOME_Exception& e )
|
|
|
|
{
|
2005-06-02 13:17:09 +06:00
|
|
|
SalomeApp_Tools::QtCatchCorbaException( e );
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : activateSelection
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void MeasureGUI_Skeleton::activateSelection()
|
|
|
|
{
|
|
|
|
globalSelection( GEOM_ALLSHAPES );
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : isValid
|
2004-01-07 20:46:21 +05:00
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
bool MeasureGUI_Skeleton::isValid( QString& )
|
2004-01-07 20:46:21 +05:00
|
|
|
{
|
2004-12-01 15:39:14 +05:00
|
|
|
return !myObj->_is_nil();
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
//================================================================
|
|
|
|
// Function : getDisplayer
|
|
|
|
// Purpose :
|
|
|
|
//================================================================
|
|
|
|
GEOM_Displayer* MeasureGUI_Skeleton::getDisplayer()
|
|
|
|
{
|
|
|
|
if ( !myDisplayer )
|
2005-06-02 13:17:09 +06:00
|
|
|
myDisplayer = new GEOM_Displayer( getStudy() );
|
2004-12-01 15:39:14 +05:00
|
|
|
return myDisplayer;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : createOperation
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
GEOM::GEOM_IOperations_ptr MeasureGUI_Skeleton::createOperation()
|
|
|
|
{
|
|
|
|
return getGeomEngine()->GetIMeasureOperations( getStudyId() );
|
|
|
|
}
|
|
|
|
|