geom/src/MeasureGUI/MeasureGUI_DistanceDlg.cxx

604 lines
20 KiB
C++
Raw Normal View History

2013-04-01 18:25:01 +06:00
// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
2004-01-07 20:46:21 +05:00
//
2012-08-09 13:58:02 +06:00
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
2004-12-01 15:39:14 +05:00
//
2012-08-09 13:58:02 +06:00
// 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.
2004-12-01 15:39:14 +05:00
//
2012-08-09 13:58:02 +06:00
// 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.
2004-12-01 15:39:14 +05:00
//
2012-08-09 13:58:02 +06:00
// 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
2004-12-01 15:39:14 +05:00
//
2012-08-09 13:58:02 +06:00
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
2013-04-01 18:25:01 +06:00
//
2012-08-09 13:58:02 +06:00
2009-02-13 17:16:39 +05:00
// GEOM GEOMGUI : GUI for Geometry component
// File : MeasureGUI_DistanceDlg.cxx
// Author : Nicolas REJNERI, Open CASCADE S.A.S.
2013-02-12 17:35:16 +06:00
2004-01-07 20:46:21 +05:00
#include "MeasureGUI_DistanceDlg.h"
2009-02-13 17:16:39 +05:00
#include "MeasureGUI_Widgets.h"
#include <DlgRef.h>
#include <GEOMBase.h>
#include <GeometryGUI.h>
#include <SUIT_Session.h>
#include <SUIT_Desktop.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_ViewWindow.h>
#include <SUIT_ViewManager.h>
2013-02-12 17:35:16 +06:00
#include <SUIT_OverrideCursor.h>
2013-02-28 20:00:05 +06:00
#include <SUIT_MessageBox.h>
2009-02-13 17:16:39 +05:00
#include <SOCC_Prs.h>
#include <SOCC_ViewModel.h>
#include <SalomeApp_Tools.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
// OCCT Includes
2004-01-07 20:46:21 +05:00
#include <Geom_Plane.hxx>
#include <AIS_LengthDimension.hxx>
2012-08-09 13:58:02 +06:00
#include <AIS_Drawer.hxx>
#include <Prs3d_LineAspect.hxx>
2004-01-07 20:46:21 +05:00
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <gce_MakePln.hxx>
#include <Precision.hxx>
//=================================================================================
// class : MeasureGUI_DistanceDlg()
2004-12-01 15:39:14 +05:00
// purpose : Constructs a MeasureGUI_DistanceDlg which is a child of 'parent', with the
2004-01-07 20:46:21 +05:00
// name 'name' and widget flags set to 'f'.
// The dialog will by default be modeless, unless you set 'modal' to
2009-02-13 17:16:39 +05:00
// true to construct a modal dialog.
2004-01-07 20:46:21 +05:00
//=================================================================================
2009-02-13 17:16:39 +05:00
MeasureGUI_DistanceDlg::MeasureGUI_DistanceDlg (GeometryGUI* GUI, QWidget* parent)
2013-02-12 17:35:16 +06:00
: GEOMBase_Skeleton(GUI, parent)
2004-01-07 20:46:21 +05:00
{
2009-02-13 17:16:39 +05:00
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_MINDIST")));
QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
2004-01-07 20:46:21 +05:00
2009-02-13 17:16:39 +05:00
setWindowTitle(tr("GEOM_MINDIST_TITLE"));
2004-01-07 20:46:21 +05:00
/***************************************************************/
2009-02-13 17:16:39 +05:00
mainFrame()->GroupConstructors->setTitle(tr("GEOM_DISTANCE"));
mainFrame()->RadioButton1->setIcon(image0);
2013-02-12 17:35:16 +06:00
mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton2->close();
mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton3->close();
2009-02-13 17:16:39 +05:00
2013-02-12 17:35:16 +06:00
mainFrame()->GroupBoxName->hide();
myGrp = new MeasureGUI_DistanceGroup (centralWidget());
2009-02-13 17:16:39 +05:00
myGrp->GroupBox1->setTitle(tr("GEOM_MINDIST_OBJ"));
2013-02-12 17:35:16 +06:00
// Arguments
2009-02-13 17:16:39 +05:00
myGrp->TextLabel1->setText(tr("GEOM_OBJECT_I").arg("1"));
myGrp->TextLabel2->setText(tr("GEOM_OBJECT_I").arg("2"));
2013-02-12 17:35:16 +06:00
myGrp->PushButton1->setIcon(image1);
myGrp->PushButton2->setIcon(image1);
myGrp->LineEdit1->setReadOnly(true);
myGrp->LineEdit2->setReadOnly(true);
// Solutions combobox
myGrp->TextLabel7->setText(tr("GEOM_SOLUTION"));
// Distance, dx, dy and dz
2009-02-13 17:16:39 +05:00
myGrp->TextLabel3->setText(tr("GEOM_LENGTH"));
myGrp->TextLabel4->setText(tr("GEOM_DX"));
myGrp->TextLabel5->setText(tr("GEOM_DY"));
myGrp->TextLabel6->setText(tr("GEOM_DZ"));
myGrp->LineEdit3->setReadOnly(true);
myGrp->LineEdit4->setReadOnly(true);
myGrp->LineEdit5->setReadOnly(true);
myGrp->LineEdit6->setReadOnly(true);
2004-01-07 20:46:21 +05:00
/***************************************************************/
2013-02-12 17:35:16 +06:00
myHelpFileName = "min_distance_page.html";
2009-02-13 17:16:39 +05:00
// Initialisation
Init();
2004-01-07 20:46:21 +05:00
}
//=================================================================================
// function : ~MeasureGUI_DistanceDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
MeasureGUI_DistanceDlg::~MeasureGUI_DistanceDlg()
2004-12-01 15:39:14 +05:00
{
2004-01-07 20:46:21 +05:00
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void MeasureGUI_DistanceDlg::Init()
2004-01-07 20:46:21 +05:00
{
2009-02-13 17:16:39 +05:00
myEditCurrentArgument = myGrp->LineEdit1;
2013-02-12 17:35:16 +06:00
myDbls = new GEOM::ListOfDouble();
2004-01-07 20:46:21 +05:00
2009-02-13 17:16:39 +05:00
// signals and slots connections
2013-02-12 17:35:16 +06:00
connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
connect(myGrp->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
2009-02-13 17:16:39 +05:00
connect(myGrp->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
2004-01-07 20:46:21 +05:00
2013-02-12 17:35:16 +06:00
connect(myGrp->ComboBox1, SIGNAL(currentIndexChanged(int)), this, SLOT(SolutionSelected(int)));
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
globalSelection();
SelectionIntoArgument();
2004-12-01 15:39:14 +05:00
}
2004-01-07 20:46:21 +05:00
2004-12-01 15:39:14 +05:00
//=================================================================================
2013-02-12 17:35:16 +06:00
// function : ClickOnOk()
// purpose :
2004-12-01 15:39:14 +05:00
//=================================================================================
2013-02-12 17:35:16 +06:00
void MeasureGUI_DistanceDlg::ClickOnOk()
2004-12-01 15:39:14 +05:00
{
2013-02-12 17:35:16 +06:00
if (ClickOnApply())
ClickOnCancel();
}
2009-02-13 17:16:39 +05:00
2013-02-12 17:35:16 +06:00
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
bool MeasureGUI_DistanceDlg::ClickOnApply()
{
if (!onAccept())
return false;
2004-01-07 20:46:21 +05:00
2013-02-12 17:35:16 +06:00
initName();
return true;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void MeasureGUI_DistanceDlg::ActivateThisDialog()
{
GEOMBase_Skeleton::ActivateThisDialog();
2009-02-13 17:16:39 +05:00
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
2004-01-07 20:46:21 +05:00
2013-02-12 17:35:16 +06:00
globalSelection();
redisplayPreview();
2004-12-01 15:39:14 +05:00
}
2004-01-07 20:46:21 +05:00
//=================================================================================
2013-02-12 17:35:16 +06:00
// function : enterEvent()
// purpose :
2004-01-07 20:46:21 +05:00
//=================================================================================
2013-02-12 17:35:16 +06:00
void MeasureGUI_DistanceDlg::enterEvent(QEvent*)
2004-01-07 20:46:21 +05:00
{
2013-02-12 17:35:16 +06:00
if (!mainFrame()->GroupConstructors->isEnabled())
ActivateThisDialog();
}
2013-02-12 17:35:16 +06:00
//=================================================================================
// function : SolutionSelected()
// purpose : Called when ComboBox selection has changed
//=================================================================================
void MeasureGUI_DistanceDlg::SolutionSelected (int i)
{
if (i < 0 || myDbls->length() < (i+1)*6) {
2009-02-13 17:16:39 +05:00
myGrp->LineEdit3->setText("");
myGrp->LineEdit4->setText("");
myGrp->LineEdit5->setText("");
myGrp->LineEdit6->setText("");
2004-12-01 15:39:14 +05:00
erasePreview();
2013-02-12 17:35:16 +06:00
return;
2004-12-01 15:39:14 +05:00
}
2013-02-12 17:35:16 +06:00
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
gp_Pnt p1 (myDbls[i*6 + 0], myDbls[i*6 + 1], myDbls[i*6 + 2]);
gp_Pnt p2 (myDbls[i*6 + 3], myDbls[i*6 + 4], myDbls[i*6 + 5]);
double aDist = p1.Distance(p2);
myGrp->LineEdit3->setText(DlgRef::PrintDoubleValue(aDist, aPrecision));
gp_XYZ aVec = p2.XYZ() - p1.XYZ();
myGrp->LineEdit4->setText(DlgRef::PrintDoubleValue(aVec.X(), aPrecision));
myGrp->LineEdit5->setText(DlgRef::PrintDoubleValue(aVec.Y(), aPrecision));
myGrp->LineEdit6->setText(DlgRef::PrintDoubleValue(aVec.Z(), aPrecision));
redisplayPreview();
2004-01-07 20:46:21 +05:00
}
//=================================================================================
2013-02-12 17:35:16 +06:00
// function : SelectionIntoArgument()
// purpose : Called when selection has changed
2004-01-07 20:46:21 +05:00
//=================================================================================
2013-02-12 17:35:16 +06:00
void MeasureGUI_DistanceDlg::SelectionIntoArgument()
2004-01-07 20:46:21 +05:00
{
2013-02-12 17:35:16 +06:00
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
2012-08-09 13:58:02 +06:00
2013-02-12 17:35:16 +06:00
GEOM::GEOM_Object_var aSelectedObject = GEOM::GEOM_Object::_nil();
2004-12-01 15:39:14 +05:00
2013-02-12 17:35:16 +06:00
if (aSelList.Extent() > 0) {
aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First());
}
2004-01-07 20:46:21 +05:00
2013-02-12 17:35:16 +06:00
// clear selection
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
myGeomGUI->getApp()->selectionMgr()->clearSelected();
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
if (myEditCurrentArgument == myGrp->LineEdit1) {
myObj1 = aSelectedObject;
if (!myObj1->_is_nil() && myObj2->_is_nil())
myGrp->PushButton2->click();
}
else {
myObj2 = aSelectedObject;
if (!myObj2->_is_nil() && myObj1->_is_nil())
myGrp->PushButton1->click();
2004-01-07 20:46:21 +05:00
}
2013-02-12 17:35:16 +06:00
processObject();
2009-02-13 17:16:39 +05:00
}
2004-01-07 20:46:21 +05:00
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void MeasureGUI_DistanceDlg::SetEditCurrentArgument()
{
2009-02-13 17:16:39 +05:00
QPushButton* send = (QPushButton*)sender();
2004-01-07 20:46:21 +05:00
2009-02-13 17:16:39 +05:00
if (send == myGrp->PushButton1) {
myEditCurrentArgument = myGrp->LineEdit1;
myGrp->PushButton2->setDown(false);
myGrp->LineEdit2->setEnabled(false);
2004-01-07 20:46:21 +05:00
}
2009-02-13 17:16:39 +05:00
else {
myEditCurrentArgument = myGrp->LineEdit2;
myGrp->PushButton1->setDown(false);
myGrp->LineEdit1->setEnabled(false);
2004-01-07 20:46:21 +05:00
}
2009-02-13 17:16:39 +05:00
// enable line edit
myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus();
// after setFocus(), because it will be setDown(false) when loses focus
send->setDown(true);
2004-01-07 20:46:21 +05:00
2009-02-13 17:16:39 +05:00
// seems we need it only to avoid preview disappearing, caused by selection mode change
redisplayPreview();
}
2004-01-07 20:46:21 +05:00
//=================================================================================
2013-02-12 17:35:16 +06:00
// function : processObject()
// purpose : Fill dialogs fields in accordance with myObj1 and myObj2
2004-01-07 20:46:21 +05:00
//=================================================================================
2013-02-12 17:35:16 +06:00
void MeasureGUI_DistanceDlg::processObject()
2004-01-07 20:46:21 +05:00
{
2013-02-12 17:35:16 +06:00
myGrp->LineEdit1->setText(!myObj1->_is_nil() ? GEOMBase::GetName(myObj1) : "");
myGrp->LineEdit2->setText(!myObj2->_is_nil() ? GEOMBase::GetName(myObj2) : "");
myGrp->ComboBox1->clear();
myDbls->length(0);
erasePreview();
2004-12-01 15:39:14 +05:00
2013-02-12 17:35:16 +06:00
int nbSols = 0;
QString msg;
if (!isValid(msg)) return;
2004-01-07 20:46:21 +05:00
2013-02-12 17:35:16 +06:00
GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow(getOperation());
try {
nbSols = anOper->ClosestPoints(myObj1, myObj2, myDbls);
}
catch (const SALOME::SALOME_Exception& e) {
SalomeApp_Tools::QtCatchCorbaException(e);
return;
}
2004-01-07 20:46:21 +05:00
2013-02-12 17:35:16 +06:00
if (!anOper->IsDone())
myGrp->ComboBox1->addItem(tr(anOper->GetErrorCode()));
else if (nbSols <= 0)
myGrp->ComboBox1->addItem(tr("GEOM_MINDIST_NO_SOL"));
else {
for (int i = 0; i < nbSols; i++) {
myGrp->ComboBox1->addItem(tr("GEOM_SOLUTION_I").arg(i + 1));
}
myGrp->ComboBox1->setCurrentIndex(0);
2009-02-13 17:16:39 +05:00
}
}
2004-01-07 20:46:21 +05:00
//=================================================================================
2004-12-01 15:39:14 +05:00
// function : buildPrs()
2004-01-07 20:46:21 +05:00
// purpose :
//=================================================================================
2004-12-01 15:39:14 +05:00
SALOME_Prs* MeasureGUI_DistanceDlg::buildPrs()
2004-01-07 20:46:21 +05:00
{
SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
2013-02-12 17:35:16 +06:00
int currSol = myGrp->ComboBox1->currentIndex();
if (myObj1->_is_nil() || myObj2->_is_nil() ||
currSol == -1 || (currSol+1)*6 > myDbls->length() ||
vw->getViewManager()->getType() != OCCViewer_Viewer::Type())
2004-12-01 15:39:14 +05:00
return 0;
2013-02-12 17:35:16 +06:00
gp_Pnt aPnt1 (myDbls[currSol*6 + 0], myDbls[currSol*6 + 1], myDbls[currSol*6 + 2]);
gp_Pnt aPnt2 (myDbls[currSol*6 + 3], myDbls[currSol*6 + 4], myDbls[currSol*6 + 5]);
double aDist = aPnt1.Distance(aPnt2);
2004-12-01 15:39:14 +05:00
try
{
2009-02-13 17:16:39 +05:00
if (aDist <= 1.e-9) {
2013-02-12 17:35:16 +06:00
BRepBuilderAPI_MakeVertex aMaker (aPnt1);
2009-02-13 17:16:39 +05:00
return getDisplayer()->BuildPrs(aMaker.Vertex());
2004-12-01 15:39:14 +05:00
}
2009-02-13 17:16:39 +05:00
else {
2013-02-12 17:35:16 +06:00
BRepBuilderAPI_MakeEdge MakeEdge (aPnt1, aPnt2);
2009-02-13 17:16:39 +05:00
TopoDS_Vertex aVert1 = BRepBuilderAPI_MakeVertex(aPnt1);
TopoDS_Vertex aVert2 = BRepBuilderAPI_MakeVertex(aPnt2);
2004-01-07 20:46:21 +05:00
//QString aLabel;
//aLabel.sprintf("%.1f", aDist);
2004-01-07 20:46:21 +05:00
2013-02-12 17:35:16 +06:00
gp_Pnt aPnt3 ((aPnt1.X() + aPnt2.X()) / 2,
2009-02-13 17:16:39 +05:00
(aPnt1.Y() + aPnt2.Y()) / 2,
(aPnt1.Z() + aPnt2.Z()) / 2);
2004-01-07 20:46:21 +05:00
2013-02-12 17:35:16 +06:00
gp_Vec va (aPnt3, aPnt1);
gp_Vec vb (aPnt3, aPnt2);
2004-01-07 20:46:21 +05:00
2009-02-13 17:16:39 +05:00
if (va.IsParallel(vb, Precision::Angular())) {
aPnt3.SetY((aPnt1.Y() + aPnt2.Y()) / 2 + 100);
aPnt3.SetZ((aPnt1.Z() + aPnt2.Z()) / 2);
2004-01-07 20:46:21 +05:00
}
2013-02-12 17:35:16 +06:00
gce_MakePln gce_MP (aPnt1, aPnt2, aPnt3);
Handle(Geom_Plane) P = new Geom_Plane (gce_MP.Value());
2004-01-07 20:46:21 +05:00
Handle(AIS_LengthDimension) anIO = new AIS_LengthDimension( aVert1, aVert2, P->Pln() );
2012-08-09 13:58:02 +06:00
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
int w = resMgr->integerValue( "Geometry", "measures_line_width", 1 );
Handle(Prs3d_DimensionAspect) aDimensionStyle = new Prs3d_DimensionAspect;
aDimensionStyle->ArrowAspect()->SetLength( aDist / 20.0 );
aDimensionStyle->LineAspect()->SetWidth( w );
aDimensionStyle->SetTextHorizontalPosition( Prs3d_DTHP_Center );
aDimensionStyle->SetTextVerticalPosition( Prs3d_DTVP_Center );
aDimensionStyle->MakeText3d( Standard_False );
aDimensionStyle->MakeArrows3d( Standard_True );
anIO->SetFlyout( 0.0 );
anIO->SetDimensionAspect( aDimensionStyle );
2004-12-01 15:39:14 +05:00
2009-02-13 17:16:39 +05:00
SOCC_Prs* aPrs = dynamic_cast<SOCC_Prs*>(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0));
2004-12-01 15:39:14 +05:00
2009-02-13 17:16:39 +05:00
if (aPrs)
aPrs->AddObject(anIO);
2004-12-01 15:39:14 +05:00
return aPrs;
2004-01-07 20:46:21 +05:00
}
}
2013-02-12 17:35:16 +06:00
catch (Standard_Failure) {
2004-12-01 15:39:14 +05:00
return 0;
2004-01-07 20:46:21 +05:00
}
}
2013-02-12 17:35:16 +06:00
//=================================================================================
// function : createOperation
// purpose :
//=================================================================================
GEOM::GEOM_IOperations_ptr MeasureGUI_DistanceDlg::createOperation()
{
return getGeomEngine()->GetIMeasureOperations(getStudyId());
}
2004-01-07 20:46:21 +05:00
//=================================================================================
2004-12-01 15:39:14 +05:00
// function : isValid()
2004-01-07 20:46:21 +05:00
// purpose :
//=================================================================================
2009-02-13 17:16:39 +05:00
bool MeasureGUI_DistanceDlg::isValid (QString& msg)
2004-01-07 20:46:21 +05:00
{
2013-02-12 17:35:16 +06:00
return !myObj1->_is_nil() && !myObj2->_is_nil();
}
//=================================================================================
// function : execute
// purpose :
//=================================================================================
bool MeasureGUI_DistanceDlg::execute (ObjectList& objects)
{
GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow(getOperation());
GEOM::GEOM_IBasicOperations_var aBasicOper = getGeomEngine()->GetIBasicOperations(getStudyId());
GEOM::ListOfDouble_var aDbls;
int nbSols = anOper->ClosestPoints(myObj1, myObj2, aDbls);
if (anOper->IsDone()) {
2013-02-28 20:00:05 +06:00
bool doPublishAll = true;
if (nbSols > 1) {
QMessageBox::StandardButton anAnswer =
SUIT_MessageBox::question(this, tr("GEOM_MINDIST_PUBLISH_TITLE"),
tr("GEOM_MINDIST_PUBLISH_TEXT"),
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,
QMessageBox::No);
if (anAnswer == QMessageBox::No)
doPublishAll = false;
else if (anAnswer != QMessageBox::Yes)
return true;
}
if (doPublishAll) {
for (int i = 0; i < nbSols; i++) {
GEOM::GEOM_Object_var anObj1 =
aBasicOper->MakePointXYZ(aDbls[i*6 + 0], aDbls[i*6 + 1], aDbls[i*6 + 2]);
GEOM::GEOM_Object_var anObj2 =
aBasicOper->MakePointXYZ(aDbls[i*6 + 3], aDbls[i*6 + 4], aDbls[i*6 + 5]);
if (!anObj1->_is_nil() && !anObj2->_is_nil()) {
objects.push_back(anObj1._retn());
objects.push_back(anObj2._retn());
}
}
}
else {
int i = myGrp->ComboBox1->currentIndex();
GEOM::GEOM_Object_var anObj1 =
aBasicOper->MakePointXYZ(aDbls[i*6 + 0], aDbls[i*6 + 1], aDbls[i*6 + 2]);
GEOM::GEOM_Object_var anObj2 =
aBasicOper->MakePointXYZ(aDbls[i*6 + 3], aDbls[i*6 + 4], aDbls[i*6 + 5]);
2013-02-12 17:35:16 +06:00
if (!anObj1->_is_nil() && !anObj2->_is_nil()) {
objects.push_back(anObj1._retn());
objects.push_back(anObj2._retn());
}
}
}
return true;
}
//=================================================================================
// function : redisplayPreview()
// purpose :
//=================================================================================
void MeasureGUI_DistanceDlg::redisplayPreview()
{
QString aMess;
if (!isValid(aMess)) {
erasePreview(true);
return;
}
erasePreview(false);
try {
SUIT_OverrideCursor();
getDisplayer()->SetColor(Quantity_NOC_VIOLET);
getDisplayer()->SetToActivate(false);
if (SALOME_Prs* aPrs = buildPrs())
displayPreview(aPrs);
}
catch (const SALOME::SALOME_Exception& e) {
SalomeApp_Tools::QtCatchCorbaException(e);
}
}
//================================================================
// Function : getNewObjectName
// Purpose : Redefine this method to return proper name for a new object
//================================================================
QString MeasureGUI_DistanceDlg::getNewObjectName (int currObj) const
{
QString aName = tr("GEOM_MINDIST_NAME") + QString("_%1_").arg((currObj+1)/2);
aName += GEOMBase::GetName(currObj%2 ? myObj1 : myObj2);
return aName;
}
//=================================================================================
// function : MeasureGUI_DistanceGroup
// purpose :
//=================================================================================
MeasureGUI_DistanceGroup::MeasureGUI_DistanceGroup (QWidget *parent)
{
gridLayout = new QGridLayout (parent);
gridLayout->setSpacing(6);
gridLayout->setContentsMargins(11, 11, 11, 11);
gridLayout->setHorizontalSpacing(0);
gridLayout->setVerticalSpacing(0);
gridLayout->setContentsMargins(0, 0, 0, 0);
GroupBox1 = new QGroupBox (parent);
gridLayout1 = new QGridLayout (GroupBox1);
gridLayout1->setSpacing(6);
gridLayout1->setContentsMargins(11, 11, 11, 11);
gridLayout1->setHorizontalSpacing(6);
gridLayout1->setVerticalSpacing(6);
gridLayout1->setContentsMargins(9, 9, 9, 9);
// 2Sel
TextLabel1 = new QLabel(GroupBox1);
TextLabel2 = new QLabel(GroupBox1);
PushButton1 = new QPushButton (GroupBox1);
PushButton2 = new QPushButton (GroupBox1);
LineEdit1 = new QLineEdit(GroupBox1);
LineEdit2 = new QLineEdit(GroupBox1);
gridLayout1->addWidget(TextLabel1, 0, 0, 1, 1);
gridLayout1->addWidget(TextLabel2, 1, 0, 1, 1);
gridLayout1->addWidget(PushButton1, 0, 1, 1, 1);
gridLayout1->addWidget(PushButton2, 1, 1, 1, 1);
gridLayout1->addWidget(LineEdit1, 0, 2, 1, 1);
gridLayout1->addWidget(LineEdit2, 1, 2, 1, 1);
// 1Combo
TextLabel7 = new QLabel (GroupBox1);
ComboBox1 = new QComboBox (GroupBox1);
gridLayout1->addWidget(TextLabel7, 2, 0, 1, 1);
gridLayout1->addWidget(ComboBox1, 2, 1, 1, 2);
// 4Text
TextLabel3 = new QLabel (GroupBox1);
TextLabel4 = new QLabel (GroupBox1);
TextLabel5 = new QLabel (GroupBox1);
TextLabel6 = new QLabel (GroupBox1);
LineEdit3 = new QLineEdit(GroupBox1);
LineEdit4 = new QLineEdit(GroupBox1);
LineEdit5 = new QLineEdit(GroupBox1);
LineEdit6 = new QLineEdit(GroupBox1);
gridLayout1->addWidget(TextLabel3, 3, 0, 1, 1);
gridLayout1->addWidget(TextLabel4, 4, 0, 1, 1);
gridLayout1->addWidget(TextLabel5, 5, 0, 1, 1);
gridLayout1->addWidget(TextLabel6, 6, 0, 1, 1);
gridLayout1->addWidget(LineEdit3, 3, 1, 1, 2);
gridLayout1->addWidget(LineEdit4, 4, 1, 1, 2);
gridLayout1->addWidget(LineEdit5, 5, 1, 1, 2);
gridLayout1->addWidget(LineEdit6, 6, 1, 1, 2);
gridLayout->addWidget(GroupBox1, 0, 0, 1, 1);
}
//=================================================================================
// function : ~MeasureGUI_DistanceGroup()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
MeasureGUI_DistanceGroup::~MeasureGUI_DistanceGroup()
{
// no need to delete child widgets, Qt does it all for us
2004-01-07 20:46:21 +05:00
}