mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-27 13:10:34 +05:00
rnc :
- added a dialog to import pictures and display it in viewer as a texture on a face. - The created object can then be selected into the Feature Detection dialog
This commit is contained in:
parent
c0790b80d5
commit
775f0ac393
@ -52,6 +52,7 @@
|
||||
#include "EntityGUI_3DSketcherDlg.h" // Sketcher
|
||||
#include "EntityGUI_SubShapeDlg.h" // Method SUBSHAPE
|
||||
#include "EntityGUI_FeatureDetectorDlg.h" // Feature Detection
|
||||
#include "EntityGUI_PictureImportDlg.h" // Import Picture in viewer
|
||||
|
||||
//=======================================================================
|
||||
// function : EntityGUI()
|
||||
@ -95,9 +96,12 @@ bool EntityGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
|
||||
case GEOMOp::OpExplode: // EXPLODE
|
||||
aDlg = new EntityGUI_SubShapeDlg( getGeometryGUI(), parent );
|
||||
break;
|
||||
case GEOMOp::OpFeatureDetect: // CORNER DETECTION
|
||||
case GEOMOp::OpFeatureDetect: // FEATURE DETECTION
|
||||
aDlg = new EntityGUI_FeatureDetectorDlg( getGeometryGUI(), parent );
|
||||
break;
|
||||
case GEOMOp::OpPictureImport: // IMPORT PICTURE IN VIEWER
|
||||
aDlg = new EntityGUI_PictureImportDlg( getGeometryGUI(), parent );
|
||||
break;
|
||||
default:
|
||||
app->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) );
|
||||
break;
|
||||
|
@ -43,7 +43,8 @@
|
||||
#include <SUIT_Session.h>
|
||||
#include <SUIT_ViewWindow.h>
|
||||
#include <SalomeApp_Application.h>
|
||||
// #include <LightApp_Application.h>
|
||||
#include <LightApp_Application.h>
|
||||
#include <LightApp_SelectionMgr.h>
|
||||
|
||||
#include <SalomeApp_Study.h>
|
||||
|
||||
@ -125,8 +126,8 @@ EntityGUI_FeatureDetectorDlg::EntityGUI_FeatureDetectorDlg( GeometryGUI* theGeom
|
||||
mainFrame()->RadioButton2->setText(tr("GEOM_CORNERS"));
|
||||
// mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
|
||||
// mainFrame()->RadioButton2->close();
|
||||
// mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
|
||||
// mainFrame()->RadioButton3->close();
|
||||
mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
|
||||
mainFrame()->RadioButton3->close();
|
||||
|
||||
myViewGroup = new DlgRef_3Radio(centralWidget());
|
||||
myViewGroup->GroupBox1->setTitle(tr("GEOM_VIEW"));
|
||||
@ -139,15 +140,19 @@ EntityGUI_FeatureDetectorDlg::EntityGUI_FeatureDetectorDlg( GeometryGUI* theGeom
|
||||
myViewButtonGroup->addButton( myViewGroup->RadioButton3, XZ ); // Left View
|
||||
|
||||
mySelectionGroup = new QGroupBox(tr("GEOM_DETECT"), centralWidget());
|
||||
QHBoxLayout* mySelectGrpLayout = new QHBoxLayout(mySelectionGroup);
|
||||
QGridLayout* mySelectGrpLayout = new QGridLayout(mySelectionGroup);
|
||||
myPushButton = new QPushButton(mySelectionGroup);
|
||||
myPushButton->setIcon(image0);
|
||||
myPushButton->setCheckable(true);
|
||||
|
||||
mySelButton = new QPushButton(mySelectionGroup);
|
||||
myLineEdit = new QLineEdit(mySelectionGroup);
|
||||
|
||||
mySnapshotLabel = new QLabel(mySelectionGroup);
|
||||
mySelectGrpLayout->addWidget(mySnapshotLabel, 0);
|
||||
mySelectGrpLayout->addWidget(myPushButton, 0);
|
||||
mySelectGrpLayout->addStretch(1);
|
||||
mySelectGrpLayout->addWidget(myLineEdit, 0, 0);
|
||||
mySelectGrpLayout->addWidget(mySelButton, 0, 1);
|
||||
mySelectGrpLayout->addWidget(mySnapshotLabel, 1, 0);
|
||||
mySelectGrpLayout->addWidget(myPushButton, 1, 1);
|
||||
|
||||
myCoordGrp1 = new QGroupBox(tr("GEOM_SCALING"), centralWidget());
|
||||
QGridLayout* myCoordGrpLayout = new QGridLayout(myCoordGrp1);
|
||||
@ -241,11 +246,14 @@ void EntityGUI_FeatureDetectorDlg::Init()
|
||||
connect( this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
|
||||
|
||||
connect( myPushButton, SIGNAL( toggled( bool ) ), this, SLOT( onButtonToggled( bool ) ) );
|
||||
connect( mySelButton, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
|
||||
connect( myPushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
|
||||
connect( myPushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
|
||||
|
||||
connect( myViewButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( onViewClicked( int ) ) );
|
||||
|
||||
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),this, SLOT( SelectionIntoArgument() ) );
|
||||
|
||||
// /* Get setting of step value from file configuration */
|
||||
// SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
|
||||
// double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
|
||||
@ -331,31 +339,45 @@ void EntityGUI_FeatureDetectorDlg::Init()
|
||||
void EntityGUI_FeatureDetectorDlg::SetEditCurrentArgument()
|
||||
{
|
||||
QPushButton* send = (QPushButton*)sender();
|
||||
if ( send == myPushButton1 ) {
|
||||
myPushButton2->setDown(false);
|
||||
myX2->setEnabled(false);
|
||||
myY2->setEnabled(false);
|
||||
myZ2->setEnabled(false);
|
||||
myX->setEnabled(true);
|
||||
myX->setFocus();
|
||||
myY->setEnabled(true);
|
||||
myZ->setEnabled(true);
|
||||
|
||||
if ( send == mySelButton ) {
|
||||
myEditCurrentArgument = myLineEdit;
|
||||
myLineEdit->setEnabled(true);
|
||||
}
|
||||
else if ( send == myPushButton2 ) {
|
||||
myPushButton1->setDown(false);
|
||||
myX2->setEnabled(true);
|
||||
myX2->setFocus();
|
||||
myY2->setEnabled(true);
|
||||
myZ2->setEnabled(true);
|
||||
myX->setEnabled(false);
|
||||
myY->setEnabled(false);
|
||||
myZ->setEnabled(false);
|
||||
}
|
||||
|
||||
send->setDown(true);
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : SelectionIntoArgument()
|
||||
// purpose : Called when selection as changed or other case
|
||||
//=================================================================================
|
||||
void EntityGUI_FeatureDetectorDlg::SelectionIntoArgument()
|
||||
{
|
||||
myEditCurrentArgument->setText( "" );
|
||||
|
||||
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
|
||||
SALOME_ListIO aSelList;
|
||||
aSelMgr->selectedObjects(aSelList);
|
||||
|
||||
if (aSelList.Extent() != 1) {
|
||||
if (myEditCurrentArgument == myLineEdit)
|
||||
myFace.nullify();
|
||||
return;
|
||||
}
|
||||
|
||||
TopAbs_ShapeEnum aNeedType = TopAbs_FACE ;
|
||||
GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
|
||||
TopoDS_Shape aShape;
|
||||
if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
|
||||
QString aName = GEOMBase::GetName( aSelectedObject.get() );
|
||||
myEditCurrentArgument->setText( aName );
|
||||
if ( myEditCurrentArgument == myLineEdit ) {
|
||||
myFace = aSelectedObject;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//=================================================================================
|
||||
// function : OnPointSelected
|
||||
// purpose :
|
||||
@ -522,12 +544,7 @@ void EntityGUI_FeatureDetectorDlg::setEndPnt(const QPoint& theEndPnt)
|
||||
//=================================================================================
|
||||
GEOM::GEOM_IOperations_ptr EntityGUI_FeatureDetectorDlg::createOperation()
|
||||
{
|
||||
GEOM::GEOM_IOperations_ptr anOp;
|
||||
if (myConstructorId == CORNERS || myConstructorId == CONTOURS)
|
||||
anOp=myGeomGUI->GetGeomGen()->GetIShapesOperations( getStudyId() );
|
||||
else
|
||||
anOp=myGeomGUI->GetGeomGen()->GetIBlocksOperations( getStudyId() );
|
||||
return anOp;
|
||||
return myGeomGUI->GetGeomGen()->GetIShapesOperations( getStudyId() );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
@ -725,38 +742,6 @@ bool EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects )
|
||||
|
||||
res=true;
|
||||
}
|
||||
else if (myConstructorId == 2)
|
||||
{
|
||||
// gp_Pnt p1(0,0,0);
|
||||
// gp_Pnt p2(0,height,0);
|
||||
// gp_Pnt p3(width,height,0);
|
||||
// gp_Pnt p4(width,0,0);
|
||||
|
||||
GEOM::GEOM_Object_var P1 = aBasicOperations->MakePointXYZ( 0,0,0 );
|
||||
GEOM::GEOM_Object_var P2 = aBasicOperations->MakePointXYZ( 0,height,0 );
|
||||
GEOM::GEOM_Object_var P3 = aBasicOperations->MakePointXYZ( width,height,0 );
|
||||
GEOM::GEOM_Object_var P4 = aBasicOperations->MakePointXYZ( width,0,0 );
|
||||
|
||||
GEOM::GEOM_IBlocksOperations_var aBlocksOperations = myGeomGUI->GetGeomGen()->GetIBlocksOperations( getStudyId() );
|
||||
GEOM::GEOM_Object_var aFace = aBlocksOperations->MakeQuad4Vertices(P1,P2,P3,P4);
|
||||
getDisplayer()->SetTexture(theImgFileName.toStdString());
|
||||
getDisplayer()->SetDisplayMode( 3 );
|
||||
// OCCViewer_Viewer* anOCCViewer =((OCCViewer_ViewWindow*)theViewWindow)->getViewManager())->getOCCViewer();
|
||||
// Handle(AIS_InteractiveContext) aContext = anOCCViewer->getAISContext();
|
||||
|
||||
MESSAGE("EntityGUI_FeatureDetectorDlg::execute() theImgFileName = "<<theImgFileName.toStdString());
|
||||
if ( !aFace->_is_nil() )
|
||||
{
|
||||
objects.push_back( aFace._retn() );
|
||||
}
|
||||
|
||||
res=true;
|
||||
}
|
||||
// else
|
||||
// {
|
||||
//
|
||||
// res = true;
|
||||
// }
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ class QPushButton;
|
||||
class QLabel;
|
||||
class QPoint;
|
||||
class DlgRef_3Radio;
|
||||
class DlgRef_1Sel;
|
||||
|
||||
class gp_Pnt;
|
||||
|
||||
@ -60,6 +61,7 @@ private:
|
||||
|
||||
private slots:
|
||||
void SetEditCurrentArgument();
|
||||
void SelectionIntoArgument();
|
||||
void ConstructorsClicked( int );
|
||||
void onViewClicked( int );
|
||||
void onButtonToggled( bool );
|
||||
@ -68,6 +70,7 @@ private slots:
|
||||
|
||||
|
||||
private:
|
||||
GEOM::GeomObjPtr myFace;
|
||||
|
||||
int myConstructorId;
|
||||
|
||||
@ -76,6 +79,8 @@ private:
|
||||
|
||||
QLabel* mySnapshotLabel;
|
||||
|
||||
DlgRef_1Sel* mySelWidget;
|
||||
|
||||
QLineEdit* myX;
|
||||
QLineEdit* myY;
|
||||
QLineEdit* myZ;
|
||||
@ -99,6 +104,10 @@ private:
|
||||
gp_Ax3 aGlobalCS;
|
||||
|
||||
QPushButton* myPushButton;
|
||||
QPushButton* mySelButton;
|
||||
|
||||
QLineEdit* myLineEdit;
|
||||
|
||||
QPushButton* myPushButton1;
|
||||
QPushButton* myPushButton2;
|
||||
|
||||
|
465
src/EntityGUI/EntityGUI_PictureImportDlg.cxx
Normal file
465
src/EntityGUI/EntityGUI_PictureImportDlg.cxx
Normal file
@ -0,0 +1,465 @@
|
||||
// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
//
|
||||
// Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
|
||||
// GEOM GEOMGUI : GUI for Geometry component
|
||||
// File : EntityGUI_PictureImportDlg.cxx
|
||||
// Author : Renaud NEDELEC, Open CASCADE S.A.S.
|
||||
//
|
||||
#include "EntityGUI_PictureImportDlg.h"
|
||||
|
||||
#include <DlgRef.h>
|
||||
#include <GeometryGUI.h>
|
||||
#include <GEOMBase.h>
|
||||
|
||||
#include <SUIT_ResourceMgr.h>
|
||||
#include <SUIT_Session.h>
|
||||
#include <SalomeApp_Application.h>
|
||||
#include <LightApp_SelectionMgr.h>
|
||||
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TColStd_IndexedMapOfInteger.hxx>
|
||||
#include <TopTools_IndexedMapOfShape.hxx>
|
||||
|
||||
#include <GEOMImpl_Types.hxx>
|
||||
|
||||
#include <OCCViewer_FeatureDetector.h>
|
||||
|
||||
|
||||
#include <QFileDialog>
|
||||
|
||||
//=================================================================================
|
||||
// class : EntityGUI_PictureImportDlg()
|
||||
// purpose : Constructs a EntityGUI_PictureImportDlg 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.
|
||||
//=================================================================================
|
||||
EntityGUI_PictureImportDlg::EntityGUI_PictureImportDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
|
||||
bool modal, Qt::WindowFlags fl )
|
||||
: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
|
||||
{
|
||||
// QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_LINE_2P" ) ) );
|
||||
// QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
|
||||
// QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_LINE_2F" ) ) );
|
||||
//
|
||||
setWindowTitle( tr( "GEOM_IMPORT_PICT_TITLE" ) );
|
||||
//
|
||||
// /***************************************************************/
|
||||
// mainFrame()->GroupConstructors->setTitle( tr( "GEOM_LINE" ) );
|
||||
// mainFrame()->RadioButton1->setIcon( image0 );
|
||||
// mainFrame()->RadioButton2->setIcon( image2 );
|
||||
|
||||
mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
|
||||
mainFrame()->RadioButton2->close();
|
||||
mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
|
||||
mainFrame()->RadioButton3->close();
|
||||
|
||||
QGroupBox* GroupFileSel = new QGroupBox( centralWidget() );
|
||||
QHBoxLayout* myFileSelGrpLayout = new QHBoxLayout(GroupFileSel );
|
||||
myPushButton = new QPushButton( GroupFileSel );
|
||||
myLineEdit = new QLineEdit( GroupFileSel );
|
||||
|
||||
myFileSelGrpLayout->addWidget( myLineEdit, 1);
|
||||
myFileSelGrpLayout->addWidget( myPushButton, 0);
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
|
||||
layout->setMargin( 0 ); layout->setSpacing( 6 );
|
||||
layout->addWidget( GroupFileSel );
|
||||
|
||||
// setHelpFileName( "create_line_page.html" );
|
||||
|
||||
Init();
|
||||
}
|
||||
|
||||
|
||||
//=================================================================================
|
||||
// function : ~EntityGUI_PictureImportDlg()
|
||||
// purpose : Destroys the object and frees any allocated resources
|
||||
//=================================================================================
|
||||
EntityGUI_PictureImportDlg::~EntityGUI_PictureImportDlg()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=================================================================================
|
||||
// function : Init()
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void EntityGUI_PictureImportDlg::Init()
|
||||
{
|
||||
// /* init variables */
|
||||
// myEditCurrentArgument = GroupPoints->LineEdit1;
|
||||
// myPoint1.nullify();
|
||||
// myPoint2.nullify();
|
||||
// myFace1.nullify();
|
||||
// myFace2.nullify();
|
||||
//
|
||||
// GroupPoints->PushButton1->setDown(true);
|
||||
|
||||
/* signals and slots connections */
|
||||
// connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
|
||||
// connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
|
||||
//
|
||||
// connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
|
||||
//
|
||||
connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
|
||||
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
|
||||
//
|
||||
connect( myPushButton, SIGNAL( clicked() ), this, SLOT( FileSelectionClicked() ) );
|
||||
// connect( GroupPoints->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
|
||||
// connect( GroupFaces->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
|
||||
// connect( GroupFaces->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
|
||||
//
|
||||
// connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
|
||||
// this, SLOT( SelectionIntoArgument() ) );
|
||||
|
||||
resize(100,100);
|
||||
|
||||
gp_Pnt aOrigin = gp_Pnt(0, 0, 0);
|
||||
gp_Dir aDirZ = gp_Dir(0, 0, 1);
|
||||
gp_Dir aDirX = gp_Dir(1, 0, 0);
|
||||
|
||||
gp_Ax3 aGlobalCS = gp_Ax3(aOrigin, aDirZ, aDirX);
|
||||
|
||||
myGeomGUI->SetWorkingPlane( aGlobalCS );
|
||||
myGeomGUI->ActiveWorkingPlane();
|
||||
|
||||
initName( tr( "GEOM_PICTURE" ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// =================================================================================
|
||||
// function : FileSelectionClicked()
|
||||
// purpose :
|
||||
// =================================================================================
|
||||
void EntityGUI_PictureImportDlg::FileSelectionClicked()
|
||||
{
|
||||
QString selFile = QFileDialog::getOpenFileName(this,tr( "SELECT_IMAGE"),"/home", tr("OCC_IMAGE_FILES"));
|
||||
if ( ! selFile.isEmpty() )
|
||||
myLineEdit->setText(selFile);
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : ClickOnOk()
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void EntityGUI_PictureImportDlg::ClickOnOk()
|
||||
{
|
||||
MESSAGE("EntityGUI_PictureImportDlg::ClickOnOk()")
|
||||
setIsApplyAndClose( true );
|
||||
if ( ClickOnApply() )
|
||||
ClickOnCancel();
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : ClickOnApply()
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
bool EntityGUI_PictureImportDlg::ClickOnApply()
|
||||
{
|
||||
MESSAGE("EntityGUI_PictureImportDlg::ClickOnApply()")
|
||||
if ( !onAccept() )
|
||||
return false;
|
||||
|
||||
initName();
|
||||
|
||||
myLineEdit->setText( "" );
|
||||
// ConstructorsClicked( getConstructorId() );
|
||||
|
||||
return true;
|
||||
}
|
||||
//
|
||||
// //=================================================================================
|
||||
// // function : ConstructorsClicked()
|
||||
// // purpose : Radio button management
|
||||
// //=================================================================================
|
||||
// void EntityGUI_PictureImportDlg::ConstructorsClicked( int constructorId )
|
||||
// {
|
||||
// switch ( constructorId ) {
|
||||
// case 0:
|
||||
// {
|
||||
// myEditCurrentArgument = GroupPoints->LineEdit1;
|
||||
// myEditCurrentArgument->setText( "" );
|
||||
// GroupPoints->LineEdit2->setText( "" );
|
||||
// myPoint1.nullify();
|
||||
// myPoint2.nullify();
|
||||
// GroupPoints->PushButton1->setDown(true);
|
||||
// GroupPoints->PushButton2->setDown(false);
|
||||
// GroupPoints->LineEdit1->setEnabled(true);
|
||||
// GroupPoints->LineEdit2->setEnabled(false);
|
||||
// GroupPoints->show();
|
||||
// GroupFaces->hide();
|
||||
// break;
|
||||
// }
|
||||
// case 1:
|
||||
// {
|
||||
// myEditCurrentArgument = GroupFaces->LineEdit1;
|
||||
// myEditCurrentArgument->setText("");
|
||||
// myFace1.nullify();
|
||||
// myFace2.nullify();
|
||||
// GroupFaces->PushButton1->setDown(true);
|
||||
// GroupFaces->PushButton2->setDown(false);
|
||||
// GroupFaces->LineEdit1->setEnabled(true);
|
||||
// GroupFaces->LineEdit2->setEnabled(false);
|
||||
// GroupPoints->hide();
|
||||
// GroupFaces->show();
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupFaces->LineEdit1 ||
|
||||
// myEditCurrentArgument == GroupFaces->LineEdit2 ) ?
|
||||
// TopAbs_FACE : TopAbs_VERTEX;
|
||||
// globalSelection(); // close local selection to clear it
|
||||
// localSelection( GEOM::GEOM_Object::_nil(), aNeedType );
|
||||
//
|
||||
// qApp->processEvents();
|
||||
// updateGeometry();
|
||||
// resize( minimumSizeHint() );
|
||||
// SelectionIntoArgument();
|
||||
// }
|
||||
//
|
||||
// //=================================================================================
|
||||
// // function : SelectionIntoArgument()
|
||||
// // purpose : Called when selection as changed or other case
|
||||
// //=================================================================================
|
||||
// void EntityGUI_PictureImportDlg::SelectionIntoArgument()
|
||||
// {
|
||||
// myEditCurrentArgument->setText( "" );
|
||||
//
|
||||
// LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
|
||||
// SALOME_ListIO aSelList;
|
||||
// aSelMgr->selectedObjects(aSelList);
|
||||
//
|
||||
// if (aSelList.Extent() != 1) {
|
||||
// if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint1.nullify();
|
||||
// else if (myEditCurrentArgument == GroupPoints->LineEdit2) myPoint2.nullify();
|
||||
// else if (myEditCurrentArgument == GroupFaces->LineEdit1) myFace1.nullify();
|
||||
// else if (myEditCurrentArgument == GroupFaces->LineEdit2) myFace2.nullify();
|
||||
// displayPreview(true);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupFaces->LineEdit1 ||
|
||||
// myEditCurrentArgument == GroupFaces->LineEdit2 ) ?
|
||||
// TopAbs_FACE : TopAbs_VERTEX;
|
||||
// GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
|
||||
// TopoDS_Shape aShape;
|
||||
// if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
|
||||
// QString aName = GEOMBase::GetName( aSelectedObject.get() );
|
||||
// myEditCurrentArgument->setText( aName );
|
||||
// if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
|
||||
// myPoint1 = aSelectedObject;
|
||||
// if ( myPoint1 && !myPoint2 )
|
||||
// GroupPoints->PushButton2->click();
|
||||
// }
|
||||
// else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) {
|
||||
// myPoint2 = aSelectedObject;
|
||||
// if ( myPoint2 && !myPoint1 )
|
||||
// GroupPoints->PushButton1->click();
|
||||
// }
|
||||
// else if ( myEditCurrentArgument == GroupFaces->LineEdit1 ) {
|
||||
// myFace1 = aSelectedObject;
|
||||
// if ( myFace1 && !myFace2 )
|
||||
// GroupFaces->PushButton2->click();
|
||||
// }
|
||||
// else if ( myEditCurrentArgument == GroupFaces->LineEdit2 ) {
|
||||
// myFace2 = aSelectedObject;
|
||||
// if ( myFace2 && !myFace1 )
|
||||
// GroupFaces->PushButton1->click();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// displayPreview(true);
|
||||
// }
|
||||
|
||||
// //=================================================================================
|
||||
// // function : SetEditCurrentArgument()
|
||||
// // purpose :
|
||||
// //=================================================================================
|
||||
// void EntityGUI_PictureImportDlg::SetEditCurrentArgument()
|
||||
// {
|
||||
// QPushButton* send = (QPushButton*)sender();
|
||||
// if ( send == GroupPoints->PushButton1 ) {
|
||||
// myEditCurrentArgument = GroupPoints->LineEdit1;
|
||||
// GroupPoints->PushButton2->setDown(false);
|
||||
// GroupPoints->LineEdit1->setEnabled(true);
|
||||
// GroupPoints->LineEdit2->setEnabled(false);
|
||||
// }
|
||||
// else if ( send == GroupPoints->PushButton2 ) {
|
||||
// myEditCurrentArgument = GroupPoints->LineEdit2;
|
||||
// GroupPoints->PushButton1->setDown(false);
|
||||
// GroupPoints->LineEdit1->setEnabled(false);
|
||||
// GroupPoints->LineEdit2->setEnabled(true);
|
||||
// }
|
||||
// else if ( send == GroupFaces->PushButton1 ) {
|
||||
// myEditCurrentArgument = GroupFaces->LineEdit1;
|
||||
// GroupFaces->PushButton2->setDown(false);
|
||||
// GroupFaces->LineEdit1->setEnabled(true);
|
||||
// GroupFaces->LineEdit2->setEnabled(false);
|
||||
// }
|
||||
// else if ( send == GroupFaces->PushButton2 ) {
|
||||
// myEditCurrentArgument = GroupFaces->LineEdit2;
|
||||
// GroupFaces->PushButton1->setDown(false);
|
||||
// GroupFaces->LineEdit1->setEnabled(false);
|
||||
// GroupFaces->LineEdit2->setEnabled(true);
|
||||
// }
|
||||
//
|
||||
// TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupFaces->LineEdit1 ||
|
||||
// myEditCurrentArgument == GroupFaces->LineEdit2 ) ?
|
||||
// TopAbs_FACE : TopAbs_VERTEX;
|
||||
// globalSelection(); // close local selection to clear it
|
||||
// localSelection( GEOM::GEOM_Object::_nil(), aNeedType );
|
||||
//
|
||||
// myEditCurrentArgument->setFocus();
|
||||
// // SelectionIntoArgument();
|
||||
// send->setDown(true);
|
||||
// displayPreview(true);
|
||||
// }
|
||||
//
|
||||
// //=================================================================================
|
||||
// // function : ActivateThisDialog()
|
||||
// // purpose :
|
||||
// //=================================================================================
|
||||
// void EntityGUI_PictureImportDlg::ActivateThisDialog()
|
||||
// {
|
||||
// GEOMBase_Skeleton::ActivateThisDialog();
|
||||
// connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
|
||||
// this, SLOT( SelectionIntoArgument() ) );
|
||||
//
|
||||
// ConstructorsClicked( getConstructorId() );
|
||||
// }
|
||||
//
|
||||
// //=================================================================================
|
||||
// // function : DeactivateActiveDialog()
|
||||
// // purpose : public slot to deactivate if active
|
||||
// //=================================================================================
|
||||
// void EntityGUI_PictureImportDlg::DeactivateActiveDialog()
|
||||
// {
|
||||
// GEOMBase_Skeleton::DeactivateActiveDialog();
|
||||
// }
|
||||
//
|
||||
// //=================================================================================
|
||||
// // function : enterEvent()
|
||||
// // purpose :
|
||||
// //=================================================================================
|
||||
// void EntityGUI_PictureImportDlg::enterEvent( QEvent* )
|
||||
// {
|
||||
// if ( !mainFrame()->GroupConstructors->isEnabled() )
|
||||
// ActivateThisDialog();
|
||||
// }
|
||||
|
||||
//=================================================================================
|
||||
// function : createOperation
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
GEOM::GEOM_IOperations_ptr EntityGUI_PictureImportDlg::createOperation()
|
||||
{
|
||||
return myGeomGUI->GetGeomGen()->GetIBlocksOperations( getStudyId() );
|
||||
}
|
||||
//
|
||||
// //=================================================================================
|
||||
// // function : isValid
|
||||
// // purpose :
|
||||
// //=================================================================================
|
||||
// bool EntityGUI_PictureImportDlg::isValid( QString& msg )
|
||||
// {
|
||||
// bool ok = false;
|
||||
// switch ( getConstructorId() ) {
|
||||
// case 0 :
|
||||
// ok = myPoint1 && myPoint2;
|
||||
// break;
|
||||
// case 1:
|
||||
// ok = myFace1 && myFace2;
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// return ok;
|
||||
// }
|
||||
|
||||
//=================================================================================
|
||||
// function : execute
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
bool EntityGUI_PictureImportDlg::execute( ObjectList& objects )
|
||||
{
|
||||
MESSAGE("EntityGUI_PictureImportDlg::execute()")
|
||||
bool res = false;
|
||||
GEOM::GEOM_Object_var anObj;
|
||||
GEOM::GEOM_IBasicOperations_var aBasicOperations = myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() );
|
||||
GEOM::GEOM_IBlocksOperations_var aBlocksOperations = GEOM::GEOM_IBlocksOperations::_narrow( getOperation() );
|
||||
QString theImgFileName = myLineEdit->text();
|
||||
if ( theImgFileName.isEmpty() )
|
||||
return res;
|
||||
|
||||
OCCViewer_FeatureDetector* aDetector = new OCCViewer_FeatureDetector( theImgFileName );
|
||||
|
||||
int height = aDetector->GetImgHeight();
|
||||
int width = aDetector->GetImgWidth();
|
||||
|
||||
|
||||
GEOM::GEOM_Object_var P1 = aBasicOperations->MakePointXYZ( -0.5*width, -0.5*height,0 );
|
||||
GEOM::GEOM_Object_var P2 = aBasicOperations->MakePointXYZ( -0.5*width, 0.5*height,0 );
|
||||
GEOM::GEOM_Object_var P3 = aBasicOperations->MakePointXYZ( 0.5*width, 0.5*height,0 );
|
||||
GEOM::GEOM_Object_var P4 = aBasicOperations->MakePointXYZ( 0.5*width, -0.5*height,0 );
|
||||
|
||||
GEOM::GEOM_Object_var aFace = aBlocksOperations->MakeQuad4Vertices(P1,P2,P3,P4);
|
||||
getDisplayer()->SetTexture(theImgFileName.toStdString());
|
||||
getDisplayer()->SetDisplayMode( 3 );
|
||||
// OCCViewer_Viewer* anOCCViewer =((OCCViewer_ViewWindow*)theViewWindow)->getViewManager())->getOCCViewer();
|
||||
// Handle(AIS_InteractiveContext) aContext = anOCCViewer->getAISContext();
|
||||
|
||||
MESSAGE("EntityGUI_FeatureDetectorDlg::execute() theImgFileName = "<<theImgFileName.toStdString());
|
||||
if ( !aFace->_is_nil() )
|
||||
{
|
||||
objects.push_back( aFace._retn() );
|
||||
}
|
||||
|
||||
res=true;
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
// //=================================================================================
|
||||
// // function : addSubshapeToStudy
|
||||
// // purpose : virtual method to add new SubObjects if local selection
|
||||
// //=================================================================================
|
||||
// void EntityGUI_PictureImportDlg::addSubshapesToStudy()
|
||||
// {
|
||||
// switch ( getConstructorId() ) {
|
||||
// case 0 :
|
||||
// GEOMBase::PublishSubObject( myPoint1.get() );
|
||||
// GEOMBase::PublishSubObject( myPoint2.get() );
|
||||
// break;
|
||||
// case 1 :
|
||||
// GEOMBase::PublishSubObject( myFace1.get() );
|
||||
// GEOMBase::PublishSubObject( myFace2.get() );
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// }
|
74
src/EntityGUI/EntityGUI_PictureImportDlg.h
Normal file
74
src/EntityGUI/EntityGUI_PictureImportDlg.h
Normal file
@ -0,0 +1,74 @@
|
||||
// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
//
|
||||
// Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
|
||||
// GEOM GEOMGUI : GUI for Geometry component
|
||||
// File : EntityGUI_PictureImportDlg.h
|
||||
// Author : Renaud NEDELEC, Open CASCADE S.A.S.
|
||||
//
|
||||
#ifndef BASICGUI_LINEDLG_H
|
||||
#define BASICGUI_LINEDLG_H
|
||||
|
||||
#include "GEOMBase_Skeleton.h"
|
||||
#include "GEOM_GenericObjPtr.h"
|
||||
|
||||
class QGroupBox;
|
||||
//=================================================================================
|
||||
// class : EntityGUI_PictureImportDlg
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
class EntityGUI_PictureImportDlg : public GEOMBase_Skeleton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
EntityGUI_PictureImportDlg( GeometryGUI*, QWidget* = 0, bool = false, Qt::WindowFlags = 0 );
|
||||
~EntityGUI_PictureImportDlg();
|
||||
|
||||
protected:
|
||||
// // redefined from GEOMBase_Helper
|
||||
virtual GEOM::GEOM_IOperations_ptr createOperation();
|
||||
// virtual bool isValid( QString& );
|
||||
virtual bool execute( ObjectList& );
|
||||
// virtual void addSubshapesToStudy();
|
||||
|
||||
private:
|
||||
void Init();
|
||||
// void enterEvent( QEvent* );
|
||||
|
||||
private:
|
||||
QGroupBox* GroupSelFile;
|
||||
QPushButton* myPushButton;
|
||||
QLineEdit* myLineEdit;
|
||||
|
||||
private slots:
|
||||
void ClickOnOk();
|
||||
bool ClickOnApply();
|
||||
//
|
||||
// void ActivateThisDialog();
|
||||
// void DeactivateActiveDialog();
|
||||
void FileSelectionClicked( );
|
||||
//
|
||||
// void SelectionIntoArgument();
|
||||
// void SetEditCurrentArgument();
|
||||
};
|
||||
|
||||
#endif // BASICGUI_LINEDLG_H
|
@ -34,7 +34,8 @@ salomeinclude_HEADERS = \
|
||||
EntityGUI_SketcherDlg.h \
|
||||
EntityGUI_3DSketcherDlg.h \
|
||||
EntityGUI_SubShapeDlg.h \
|
||||
EntityGUI_FeatureDetectorDlg.h
|
||||
EntityGUI_FeatureDetectorDlg.h \
|
||||
EntityGUI_PictureImportDlg.h
|
||||
|
||||
dist_libEntityGUI_la_SOURCES = \
|
||||
EntityGUI.cxx \
|
||||
@ -42,14 +43,16 @@ dist_libEntityGUI_la_SOURCES = \
|
||||
EntityGUI_SketcherDlg.cxx \
|
||||
EntityGUI_3DSketcherDlg.cxx \
|
||||
EntityGUI_SubShapeDlg.cxx \
|
||||
EntityGUI_FeatureDetectorDlg.cxx
|
||||
EntityGUI_FeatureDetectorDlg.cxx\
|
||||
EntityGUI_PictureImportDlg.cxx
|
||||
|
||||
MOC_FILES = \
|
||||
EntityGUI_Widgets_moc.cxx \
|
||||
EntityGUI_SketcherDlg_moc.cxx \
|
||||
EntityGUI_3DSketcherDlg_moc.cxx \
|
||||
EntityGUI_SubShapeDlg_moc.cxx \
|
||||
EntityGUI_FeatureDetectorDlg_moc.cxx
|
||||
EntityGUI_FeatureDetectorDlg_moc.cxx \
|
||||
EntityGUI_PictureImportDlg_moc.cxx
|
||||
|
||||
nodist_libEntityGUI_la_SOURCES = \
|
||||
$(MOC_FILES)
|
||||
|
@ -281,8 +281,7 @@ void GeometryGUI::ActiveWorkingPlane()
|
||||
|
||||
view3d->SetProj(DZ.X(), DZ.Y(), DZ.Z());
|
||||
view3d->SetUp(DY.X(), DY.Y(), DY.Z());
|
||||
|
||||
// vw->onViewFitAll(); TEST (don't forget to remove comments)
|
||||
vw->onViewFitAll();
|
||||
}
|
||||
}
|
||||
else if( ViewVTK ) {
|
||||
@ -462,6 +461,7 @@ void GeometryGUI::OnGUIEvent( int id )
|
||||
case GEOMOp::Op3dSketcher: // MENU ENTITY - 3D SKETCHER
|
||||
case GEOMOp::OpExplode: // MENU ENTITY - EXPLODE
|
||||
case GEOMOp::OpFeatureDetect: // MENU ENTITY - FEATURE DETECTION
|
||||
case GEOMOp::OpPictureImport: // MENU ENTITY - IMPORT PICTURE IN VIEWER
|
||||
libName = "EntityGUI";
|
||||
break;
|
||||
case GEOMOp::OpEdge: // MENU BUILD - EDGE
|
||||
@ -710,6 +710,7 @@ void GeometryGUI::initialize( CAM_Application* app )
|
||||
createGeomAction( GEOMOp::Op3dSketcher, "3DSKETCH" );
|
||||
createGeomAction( GEOMOp::OpExplode, "EXPLODE" );
|
||||
createGeomAction( GEOMOp::OpFeatureDetect,"FEATURE_DETECTION" );
|
||||
createGeomAction( GEOMOp::OpPictureImport,"PICTURE_IMPORT" );
|
||||
|
||||
createGeomAction( GEOMOp::OpEdge, "EDGE" );
|
||||
createGeomAction( GEOMOp::OpWire, "WIRE" );
|
||||
@ -908,6 +909,7 @@ void GeometryGUI::initialize( CAM_Application* app )
|
||||
createMenu( separator(), newEntId, -1 );
|
||||
|
||||
createMenu( GEOMOp::OpFeatureDetect, newEntId, -1 );
|
||||
createMenu( GEOMOp::OpPictureImport, newEntId, -1 );
|
||||
|
||||
int operId = createMenu( tr( "MEN_OPERATIONS" ), -1, -1, 10 );
|
||||
|
||||
@ -1073,7 +1075,8 @@ void GeometryGUI::initialize( CAM_Application* app )
|
||||
createTool( separator(), operTbId );
|
||||
createTool( GEOMOp::OpExplode, operTbId );
|
||||
createTool( separator(), operTbId );
|
||||
createTool( GEOMOp::OpFeatureDetect, operTbId );
|
||||
createTool( GEOMOp::OpFeatureDetect, operTbId );
|
||||
createTool( GEOMOp::OpPictureImport, operTbId );
|
||||
createTool( separator(), operTbId );
|
||||
createTool( GEOMOp::OpPartition, operTbId );
|
||||
createTool( GEOMOp::OpArchimede, operTbId );
|
||||
|
@ -94,6 +94,7 @@ namespace GEOMOp {
|
||||
Op3dSketcher = 3301, // MENU NEW ENTITY - 3D SKETCHER
|
||||
OpExplode = 3302, // MENU NEW ENTITY - EXPLODE
|
||||
OpFeatureDetect = 3303, // MENU NEW ENTITY - FEATURE DETECTION
|
||||
OpPictureImport = 3304, // MENU NEW ENTITY - IMPORT PICTURE IN VIEWER
|
||||
// BuildGUI ------------------//--------------------------------
|
||||
OpEdge = 3400, // MENU NEW ENTITY - BUILD - EDGE
|
||||
OpWire = 3401, // MENU NEW ENTITY - BUILD - WIRE
|
||||
|
Loading…
Reference in New Issue
Block a user