mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-02-02 11:00:34 +05:00
rnc: Import Picture and Feature Detection dialogs small modifications
This commit is contained in:
parent
8aab8f5cb5
commit
71d480a550
@ -194,12 +194,12 @@ bool EntityGUI::OnMousePress( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWi
|
|||||||
}
|
}
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
// function : 0nMouseMove()
|
// function : 0nMouseRelease()
|
||||||
// purpose : [static] manage mouse events
|
// purpose : [static] manage mouse events
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
bool EntityGUI::OnMouseMove( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWindow* theViewWindow )
|
bool EntityGUI::OnMouseRelease( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWindow* theViewWindow )
|
||||||
{
|
{
|
||||||
// MESSAGE("EntityGUI::OnMouseMove")
|
MESSAGE("EntityGUI::OnMouseRelease")
|
||||||
QDialog* aDlg = getGeometryGUI()->GetActiveDialogBox();
|
QDialog* aDlg = getGeometryGUI()->GetActiveDialogBox();
|
||||||
if ( aDlg && ( QString( aDlg->metaObject()->className() ).compare( "EntityGUI_FeatureDetectorDlg" ) == 0 ) &&
|
if ( aDlg && ( QString( aDlg->metaObject()->className() ).compare( "EntityGUI_FeatureDetectorDlg" ) == 0 ) &&
|
||||||
theViewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() &&
|
theViewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() &&
|
||||||
@ -209,8 +209,7 @@ bool EntityGUI::OnMouseMove( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWin
|
|||||||
|
|
||||||
gp_Pnt aPnt;
|
gp_Pnt aPnt;
|
||||||
|
|
||||||
if ( QApplication::mouseButtons() == Qt::LeftButton &&
|
if ( aCornerDlg->acceptMouseEvent() )
|
||||||
aCornerDlg->acceptMouseEvent() )
|
|
||||||
{
|
{
|
||||||
// QPoint end = QPoint(pe->x(),pe->y());
|
// QPoint end = QPoint(pe->x(),pe->y());
|
||||||
OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
|
OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
|
||||||
|
@ -49,7 +49,8 @@ public :
|
|||||||
|
|
||||||
bool OnGUIEvent( int, SUIT_Desktop* );
|
bool OnGUIEvent( int, SUIT_Desktop* );
|
||||||
bool OnMousePress( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWindow* theViewWindow );
|
bool OnMousePress( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWindow* theViewWindow );
|
||||||
bool OnMouseMove( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWindow* theViewWindow );
|
// bool OnMouseMove( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWindow* theViewWindow );
|
||||||
|
bool OnMouseRelease( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWindow* theViewWindow );
|
||||||
|
|
||||||
static gp_Pnt ConvertClickToPoint( int x, int y, Handle(V3d_View) aView );
|
static gp_Pnt ConvertClickToPoint( int x, int y, Handle(V3d_View) aView );
|
||||||
|
|
||||||
|
@ -36,7 +36,6 @@
|
|||||||
#include <EntityGUI.h>
|
#include <EntityGUI.h>
|
||||||
#include <GEOMBase.h>
|
#include <GEOMBase.h>
|
||||||
#include <GEOM_Object.hxx>
|
#include <GEOM_Object.hxx>
|
||||||
#include <ShapeRec_FeatureDetector.hxx>
|
|
||||||
|
|
||||||
#include <SUIT_Desktop.h>
|
#include <SUIT_Desktop.h>
|
||||||
#include <SUIT_ResourceMgr.h>
|
#include <SUIT_ResourceMgr.h>
|
||||||
@ -142,10 +141,22 @@ EntityGUI_FeatureDetectorDlg::EntityGUI_FeatureDetectorDlg( GeometryGUI* theGeom
|
|||||||
myLineEdit = new QLineEdit(mySelectionGroup);
|
myLineEdit = new QLineEdit(mySelectionGroup);
|
||||||
|
|
||||||
mySnapshotLabel = new QLabel(mySelectionGroup);
|
mySnapshotLabel = new QLabel(mySelectionGroup);
|
||||||
mySelectGrpLayout->addWidget(myLineEdit, 0, 1);
|
QFrame* myImgSampleFrame = new QFrame(mySelectionGroup);
|
||||||
mySelectGrpLayout->addWidget(mySelButton, 0, 0);
|
// myImgSampleFrame->setFrameRect(QRect(0,0,10,10));
|
||||||
mySelectGrpLayout->addWidget(mySnapshotLabel, 1, 1);
|
myImgSampleFrame->setFrameStyle(QFrame::Box);
|
||||||
mySelectGrpLayout->addWidget(myPushButton, 1, 0);
|
QLabel* myPictureLabel = new QLabel(tr( "GEOM_PICTURE" ),mySelectionGroup);
|
||||||
|
mySelectGrpLayout->addWidget(myPictureLabel, 0, 0);
|
||||||
|
mySelectGrpLayout->addWidget(mySelButton, 0, 1);
|
||||||
|
mySelectGrpLayout->addWidget(myLineEdit, 0, 2);// 1, 2);
|
||||||
|
|
||||||
|
mySelectGrpLayout->addWidget(mySnapshotLabel, 1, 0);
|
||||||
|
mySelectGrpLayout->addWidget(myPushButton, 1, 1);
|
||||||
|
mySelectGrpLayout->addWidget(myImgSampleFrame, 1, 2);
|
||||||
|
// mySelectGrpLayout->setColumnStretch(3, 1);
|
||||||
|
|
||||||
|
QGridLayout* myFrameLayout = new QGridLayout(myImgSampleFrame);
|
||||||
|
myImgSampleLabel = new QLabel(myImgSampleFrame);
|
||||||
|
myFrameLayout->addWidget(myImgSampleLabel, 0, 0);
|
||||||
|
|
||||||
myOutputGroup = new DlgRef_3Radio(centralWidget());
|
myOutputGroup = new DlgRef_3Radio(centralWidget());
|
||||||
myOutputGroup->GroupBox1->setTitle(tr("GEOM_DETECT_OUTPUT"));
|
myOutputGroup->GroupBox1->setTitle(tr("GEOM_DETECT_OUTPUT"));
|
||||||
@ -163,6 +174,9 @@ EntityGUI_FeatureDetectorDlg::EntityGUI_FeatureDetectorDlg( GeometryGUI* theGeom
|
|||||||
|
|
||||||
// mainFrame()->GroupBoxName->hide();
|
// mainFrame()->GroupBoxName->hide();
|
||||||
|
|
||||||
|
// Build an instance of detection used to perform image processing operations
|
||||||
|
aDetector = new ShapeRec_FeatureDetector();
|
||||||
|
|
||||||
Init();
|
Init();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -246,6 +260,11 @@ void EntityGUI_FeatureDetectorDlg::SetEditCurrentArgument()
|
|||||||
//=================================================================================
|
//=================================================================================
|
||||||
void EntityGUI_FeatureDetectorDlg::SelectionIntoArgument()
|
void EntityGUI_FeatureDetectorDlg::SelectionIntoArgument()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow();
|
||||||
|
std::map< std::string , std::vector<Handle(AIS_InteractiveObject)> >::iterator AISit;
|
||||||
|
SOCC_Viewer* soccViewer = (SOCC_Viewer*)(theViewWindow->getViewManager()->getViewModel());
|
||||||
|
|
||||||
if (!myEditCurrentArgument->isEnabled())
|
if (!myEditCurrentArgument->isEnabled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -255,6 +274,7 @@ void EntityGUI_FeatureDetectorDlg::SelectionIntoArgument()
|
|||||||
SALOME_ListIO aSelList;
|
SALOME_ListIO aSelList;
|
||||||
aSelMgr->selectedObjects(aSelList);
|
aSelMgr->selectedObjects(aSelList);
|
||||||
SALOME_ListIteratorOfListIO anIt( aSelList );
|
SALOME_ListIteratorOfListIO anIt( aSelList );
|
||||||
|
|
||||||
for( ; anIt.More(); anIt.Next() )
|
for( ; anIt.More(); anIt.Next() )
|
||||||
if( !anIt.Value().IsNull() )
|
if( !anIt.Value().IsNull() )
|
||||||
{
|
{
|
||||||
@ -273,10 +293,29 @@ void EntityGUI_FeatureDetectorDlg::SelectionIntoArgument()
|
|||||||
if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
|
if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
|
||||||
QString aName = GEOMBase::GetName( aSelectedObject.get() );
|
QString aName = GEOMBase::GetName( aSelectedObject.get() );
|
||||||
myEditCurrentArgument->setText( aName );
|
myEditCurrentArgument->setText( aName );
|
||||||
|
|
||||||
if ( myEditCurrentArgument == myLineEdit ) {
|
if ( myEditCurrentArgument == myLineEdit ) {
|
||||||
myFace = aSelectedObject;
|
myFace = aSelectedObject;
|
||||||
|
AISit = soccViewer->entry2aisobjects.find(myFaceEntry.toStdString());
|
||||||
|
if (AISit == soccViewer->entry2aisobjects.end())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Handle(AIS_InteractiveObject) myAIS = (*AISit).second[0];
|
||||||
|
Handle(GEOM_AISShape) myAISShape;
|
||||||
|
if( myAIS->IsInstance( STANDARD_TYPE(GEOM_AISShape) ) ) {
|
||||||
|
myAISShape = Handle(GEOM_AISShape)::DownCast( myAIS );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return ;
|
||||||
|
|
||||||
|
std::string theImgFileName = myAISShape->TextureFile();
|
||||||
|
if ( theImgFileName == "" )
|
||||||
|
return ;
|
||||||
|
|
||||||
|
aDetector->SetPath( theImgFileName );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
@ -417,8 +456,40 @@ void EntityGUI_FeatureDetectorDlg::setEndPnt(const gp_Pnt& theEndPnt)
|
|||||||
{
|
{
|
||||||
myEndPnt = theEndPnt;
|
myEndPnt = theEndPnt;
|
||||||
MESSAGE("myEndPnt = ("<<theEndPnt.X()<<", "<<theEndPnt.Y()<<")")
|
MESSAGE("myEndPnt = ("<<theEndPnt.X()<<", "<<theEndPnt.Y()<<")")
|
||||||
|
showImageSample();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=================================================================================
|
||||||
|
// function : showImageSample()
|
||||||
|
// purpose :
|
||||||
|
//=================================================================================
|
||||||
|
void EntityGUI_FeatureDetectorDlg::showImageSample()
|
||||||
|
{
|
||||||
|
int height = aDetector->GetImgHeight();
|
||||||
|
int width = aDetector->GetImgWidth();
|
||||||
|
|
||||||
|
// Operations to display the corners properly in the 3D scene
|
||||||
|
double pictureLeft = -0.5 * width; // X coordinate of the top left corner of the background image in the view
|
||||||
|
double pictureTop = 0.5 * height; // Y coordinate of both top corners
|
||||||
|
|
||||||
|
// Set detection rectangle in the background image coordinates system
|
||||||
|
QPoint topLeft = QPoint(myStartPnt.X() - pictureLeft, pictureTop - myStartPnt.Y());
|
||||||
|
QPoint bottomRight = QPoint(myEndPnt.X() - pictureLeft, pictureTop - myEndPnt.Y());
|
||||||
|
QRect aRect = QRect(topLeft, bottomRight);
|
||||||
|
|
||||||
|
if( !aRect.isEmpty() && aRect.width() > 1 )
|
||||||
|
{
|
||||||
|
aDetector->SetROI( aRect );
|
||||||
|
std::string samplePicturePath = aDetector->CroppImage();
|
||||||
|
MESSAGE("samplePicturePath = "<<samplePicturePath)
|
||||||
|
QPixmap pixmap(QString(samplePicturePath.c_str()));
|
||||||
|
myImgSampleLabel->setPixmap(pixmap);
|
||||||
|
myImgSampleLabel->setMask(pixmap.mask());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
// function : createOperation
|
// function : createOperation
|
||||||
// purpose :
|
// purpose :
|
||||||
@ -436,29 +507,28 @@ bool EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects )
|
|||||||
{
|
{
|
||||||
bool res = false;
|
bool res = false;
|
||||||
|
|
||||||
SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow();
|
// SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow();
|
||||||
std::map< std::string , std::vector<Handle(AIS_InteractiveObject)> >::iterator AISit;
|
// std::map< std::string , std::vector<Handle(AIS_InteractiveObject)> >::iterator AISit;
|
||||||
SOCC_Viewer* soccViewer = (SOCC_Viewer*)(theViewWindow->getViewManager()->getViewModel());
|
// SOCC_Viewer* soccViewer = (SOCC_Viewer*)(theViewWindow->getViewManager()->getViewModel());
|
||||||
|
|
||||||
AISit = soccViewer->entry2aisobjects.find(myFaceEntry.toStdString());
|
// AISit = soccViewer->entry2aisobjects.find(myFaceEntry.toStdString());
|
||||||
if (AISit == soccViewer->entry2aisobjects.end())
|
// if (AISit == soccViewer->entry2aisobjects.end())
|
||||||
return res;
|
// return res;
|
||||||
|
//
|
||||||
Handle(AIS_InteractiveObject) myAIS = (*AISit).second[0];
|
// Handle(AIS_InteractiveObject) myAIS = (*AISit).second[0];
|
||||||
Handle(GEOM_AISShape) myAISShape;
|
// Handle(GEOM_AISShape) myAISShape;
|
||||||
if( myAIS->IsInstance( STANDARD_TYPE(GEOM_AISShape) ) ) {
|
// if( myAIS->IsInstance( STANDARD_TYPE(GEOM_AISShape) ) ) {
|
||||||
myAISShape = Handle(GEOM_AISShape)::DownCast( myAIS );
|
// myAISShape = Handle(GEOM_AISShape)::DownCast( myAIS );
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
return res;
|
// return res;
|
||||||
|
//
|
||||||
std::string theImgFileName = myAISShape->TextureFile();
|
// std::string theImgFileName = myAISShape->TextureFile();
|
||||||
|
//
|
||||||
if ( theImgFileName == "" )
|
// if ( theImgFileName == "" )
|
||||||
return res;
|
// return res;
|
||||||
|
//
|
||||||
// Build an instance of detection used to perform image processing operations
|
// aDetector->SetPath( theImgFileName );
|
||||||
ShapeRec_FeatureDetector* aDetector = new ShapeRec_FeatureDetector( theImgFileName );
|
|
||||||
|
|
||||||
int height = aDetector->GetImgHeight();
|
int height = aDetector->GetImgHeight();
|
||||||
int width = aDetector->GetImgWidth();
|
int width = aDetector->GetImgWidth();
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
#include <GEOMBase_Skeleton.h>
|
#include <GEOMBase_Skeleton.h>
|
||||||
#include <gp_Ax3.hxx>
|
#include <gp_Ax3.hxx>
|
||||||
|
#include <ShapeRec_FeatureDetector.hxx>
|
||||||
|
#include <QBitmap>
|
||||||
|
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
@ -59,6 +61,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void Init();
|
void Init();
|
||||||
|
void showImageSample();
|
||||||
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
@ -72,6 +75,8 @@ private slots:
|
|||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
ShapeRec_FeatureDetector* aDetector;
|
||||||
|
|
||||||
GEOM::GeomObjPtr myFace;
|
GEOM::GeomObjPtr myFace;
|
||||||
QString myFaceEntry;
|
QString myFaceEntry;
|
||||||
|
|
||||||
@ -80,6 +85,7 @@ private:
|
|||||||
QGroupBox* mySelectionGroup;
|
QGroupBox* mySelectionGroup;
|
||||||
|
|
||||||
QLabel* mySnapshotLabel;
|
QLabel* mySnapshotLabel;
|
||||||
|
QLabel* myImgSampleLabel;
|
||||||
|
|
||||||
DlgRef_1Sel* mySelWidget;
|
DlgRef_1Sel* mySelWidget;
|
||||||
|
|
||||||
|
@ -182,7 +182,8 @@ bool EntityGUI_PictureImportDlg::execute( ObjectList& objects )
|
|||||||
if ( theImgFileName.isEmpty() )
|
if ( theImgFileName.isEmpty() )
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
ShapeRec_FeatureDetector* aDetector = new ShapeRec_FeatureDetector( theImgFileName.toStdString() );
|
ShapeRec_FeatureDetector* aDetector = new ShapeRec_FeatureDetector();
|
||||||
|
aDetector->SetPath( theImgFileName.toStdString() );
|
||||||
|
|
||||||
int height = aDetector->GetImgHeight();
|
int height = aDetector->GetImgHeight();
|
||||||
int width = aDetector->GetImgWidth();
|
int width = aDetector->GetImgWidth();
|
||||||
|
Loading…
Reference in New Issue
Block a user