mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-22 15:00:33 +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
|
||||
//=================================================================================
|
||||
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();
|
||||
if ( aDlg && ( QString( aDlg->metaObject()->className() ).compare( "EntityGUI_FeatureDetectorDlg" ) == 0 ) &&
|
||||
theViewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() &&
|
||||
@ -209,8 +209,7 @@ bool EntityGUI::OnMouseMove( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWin
|
||||
|
||||
gp_Pnt aPnt;
|
||||
|
||||
if ( QApplication::mouseButtons() == Qt::LeftButton &&
|
||||
aCornerDlg->acceptMouseEvent() )
|
||||
if ( aCornerDlg->acceptMouseEvent() )
|
||||
{
|
||||
// QPoint end = QPoint(pe->x(),pe->y());
|
||||
OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
|
||||
|
@ -49,7 +49,8 @@ public :
|
||||
|
||||
bool OnGUIEvent( int, SUIT_Desktop* );
|
||||
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 );
|
||||
|
||||
|
@ -36,7 +36,6 @@
|
||||
#include <EntityGUI.h>
|
||||
#include <GEOMBase.h>
|
||||
#include <GEOM_Object.hxx>
|
||||
#include <ShapeRec_FeatureDetector.hxx>
|
||||
|
||||
#include <SUIT_Desktop.h>
|
||||
#include <SUIT_ResourceMgr.h>
|
||||
@ -141,11 +140,23 @@ EntityGUI_FeatureDetectorDlg::EntityGUI_FeatureDetectorDlg( GeometryGUI* theGeom
|
||||
mySelButton->setIcon(image1);
|
||||
myLineEdit = new QLineEdit(mySelectionGroup);
|
||||
|
||||
mySnapshotLabel = new QLabel(mySelectionGroup);
|
||||
mySelectGrpLayout->addWidget(myLineEdit, 0, 1);
|
||||
mySelectGrpLayout->addWidget(mySelButton, 0, 0);
|
||||
mySelectGrpLayout->addWidget(mySnapshotLabel, 1, 1);
|
||||
mySelectGrpLayout->addWidget(myPushButton, 1, 0);
|
||||
mySnapshotLabel = new QLabel(mySelectionGroup);
|
||||
QFrame* myImgSampleFrame = new QFrame(mySelectionGroup);
|
||||
// myImgSampleFrame->setFrameRect(QRect(0,0,10,10));
|
||||
myImgSampleFrame->setFrameStyle(QFrame::Box);
|
||||
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->GroupBox1->setTitle(tr("GEOM_DETECT_OUTPUT"));
|
||||
@ -163,6 +174,9 @@ EntityGUI_FeatureDetectorDlg::EntityGUI_FeatureDetectorDlg( GeometryGUI* theGeom
|
||||
|
||||
// mainFrame()->GroupBoxName->hide();
|
||||
|
||||
// Build an instance of detection used to perform image processing operations
|
||||
aDetector = new ShapeRec_FeatureDetector();
|
||||
|
||||
Init();
|
||||
|
||||
}
|
||||
@ -246,6 +260,11 @@ void EntityGUI_FeatureDetectorDlg::SetEditCurrentArgument()
|
||||
//=================================================================================
|
||||
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())
|
||||
return;
|
||||
|
||||
@ -255,6 +274,7 @@ void EntityGUI_FeatureDetectorDlg::SelectionIntoArgument()
|
||||
SALOME_ListIO aSelList;
|
||||
aSelMgr->selectedObjects(aSelList);
|
||||
SALOME_ListIteratorOfListIO anIt( aSelList );
|
||||
|
||||
for( ; anIt.More(); anIt.Next() )
|
||||
if( !anIt.Value().IsNull() )
|
||||
{
|
||||
@ -273,10 +293,29 @@ void EntityGUI_FeatureDetectorDlg::SelectionIntoArgument()
|
||||
if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
|
||||
QString aName = GEOMBase::GetName( aSelectedObject.get() );
|
||||
myEditCurrentArgument->setText( aName );
|
||||
|
||||
if ( myEditCurrentArgument == myLineEdit ) {
|
||||
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;
|
||||
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
|
||||
// purpose :
|
||||
@ -436,29 +507,28 @@ bool EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects )
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow();
|
||||
std::map< std::string , std::vector<Handle(AIS_InteractiveObject)> >::iterator AISit;
|
||||
SOCC_Viewer* soccViewer = (SOCC_Viewer*)(theViewWindow->getViewManager()->getViewModel());
|
||||
// SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow();
|
||||
// std::map< std::string , std::vector<Handle(AIS_InteractiveObject)> >::iterator AISit;
|
||||
// SOCC_Viewer* soccViewer = (SOCC_Viewer*)(theViewWindow->getViewManager()->getViewModel());
|
||||
|
||||
AISit = soccViewer->entry2aisobjects.find(myFaceEntry.toStdString());
|
||||
if (AISit == soccViewer->entry2aisobjects.end())
|
||||
return res;
|
||||
|
||||
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 res;
|
||||
|
||||
std::string theImgFileName = myAISShape->TextureFile();
|
||||
|
||||
if ( theImgFileName == "" )
|
||||
return res;
|
||||
|
||||
// Build an instance of detection used to perform image processing operations
|
||||
ShapeRec_FeatureDetector* aDetector = new ShapeRec_FeatureDetector( theImgFileName );
|
||||
// AISit = soccViewer->entry2aisobjects.find(myFaceEntry.toStdString());
|
||||
// if (AISit == soccViewer->entry2aisobjects.end())
|
||||
// return res;
|
||||
//
|
||||
// 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 res;
|
||||
//
|
||||
// std::string theImgFileName = myAISShape->TextureFile();
|
||||
//
|
||||
// if ( theImgFileName == "" )
|
||||
// return res;
|
||||
//
|
||||
// aDetector->SetPath( theImgFileName );
|
||||
|
||||
int height = aDetector->GetImgHeight();
|
||||
int width = aDetector->GetImgWidth();
|
||||
|
@ -22,6 +22,8 @@
|
||||
|
||||
#include <GEOMBase_Skeleton.h>
|
||||
#include <gp_Ax3.hxx>
|
||||
#include <ShapeRec_FeatureDetector.hxx>
|
||||
#include <QBitmap>
|
||||
|
||||
class QLineEdit;
|
||||
class QCheckBox;
|
||||
@ -59,6 +61,7 @@ protected:
|
||||
|
||||
private:
|
||||
void Init();
|
||||
void showImageSample();
|
||||
|
||||
|
||||
private slots:
|
||||
@ -72,6 +75,8 @@ private slots:
|
||||
|
||||
|
||||
private:
|
||||
ShapeRec_FeatureDetector* aDetector;
|
||||
|
||||
GEOM::GeomObjPtr myFace;
|
||||
QString myFaceEntry;
|
||||
|
||||
@ -80,6 +85,7 @@ private:
|
||||
QGroupBox* mySelectionGroup;
|
||||
|
||||
QLabel* mySnapshotLabel;
|
||||
QLabel* myImgSampleLabel;
|
||||
|
||||
DlgRef_1Sel* mySelWidget;
|
||||
|
||||
|
@ -182,7 +182,8 @@ bool EntityGUI_PictureImportDlg::execute( ObjectList& objects )
|
||||
if ( theImgFileName.isEmpty() )
|
||||
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 width = aDetector->GetImgWidth();
|
||||
|
Loading…
Reference in New Issue
Block a user