geom/src/GEOMBase/GEOMBase_Skeleton.cxx

198 lines
6.9 KiB
C++
Raw Normal View History

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
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// 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
using namespace std;
#include "GEOMBase_Skeleton.h"
2004-12-01 15:39:14 +05:00
#include "GeometryGUI.h"
#include "SALOME_Selection.h"
#include <qpushbutton.h>
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.
//=================================================================================
GEOMBase_Skeleton::GEOMBase_Skeleton(QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl)
2004-12-01 15:39:14 +05:00
:DlgRef_Skeleton_QTD(parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ), GEOMBase_Helper()
2004-01-07 20:46:21 +05:00
{
if (!name)
setName("GEOMBase_Skeleton");
buttonCancel->setText(tr("GEOM_BUT_CLOSE"));
buttonOk->setText(tr("GEOM_BUT_OK"));
buttonApply->setText(tr("GEOM_BUT_APPLY"));
GroupMedium->close(TRUE);
resize(0, 0);
Init(Sel);
}
//=================================================================================
// function : ~GEOMBase_Skeleton()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
GEOMBase_Skeleton::~GEOMBase_Skeleton()
{
2004-12-01 15:39:14 +05:00
myGeomGUI->SetActiveDialogBox( 0 );
2004-01-07 20:46:21 +05:00
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void GEOMBase_Skeleton::Init(SALOME_Selection* Sel)
{
2004-12-01 15:39:14 +05:00
myGeomGUI = GeometryGUI::GetGeomGUI();
2004-01-07 20:46:21 +05:00
/* init variables */
mySelection = Sel;
2004-12-01 15:39:14 +05:00
myGeomBase = new GEOMBase(); // SAN -- TO BE REMOVED !!!
myGeomGUI->SetActiveDialogBox(this);
2004-01-07 20:46:21 +05:00
/* signals and slots connections */
connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
/* Move widget on the botton right corner of main widget */
// int x, y;
// myGeomBase->DefineDlgPosition( this, x, y );
/* 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()
{
/* 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;
2004-12-01 15:39:14 +05:00
if(GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, mySelection))
2004-01-07 20:46:21 +05:00
myEditCurrentArgument->setText(objectUserName);
return;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void GEOMBase_Skeleton::DeactivateActiveDialog()
{
this->setEnabled(false);
2004-12-01 15:39:14 +05:00
globalSelection();
2004-01-07 20:46:21 +05:00
//myGeomGUI->ResetState();
disconnect(mySelection, 0, this, 0);
2004-12-01 15:39:14 +05:00
GeometryGUI::GetGeomGUI()->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 */
2004-12-01 15:39:14 +05:00
GeometryGUI::GetGeomGUI()->EmitSignalDeactivateDialog();
2004-01-07 20:46:21 +05:00
this->setEnabled(true);
2004-12-01 15:39:14 +05:00
GeometryGUI::GetGeomGUI()->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)
{
2004-12-01 15:39:14 +05:00
disconnect(mySelection, 0, this, 0);
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
}