#include <TDataStd_UAttribute.hxx>
#include <TDF_ListIteratorOfLabelList.hxx>
-// tage of the child of my label that contains information about the operator
-static const int TAG_OPERATOR = 1;
+// tag of the child of my label that contains information about the operator
+static const int TAG_OPERATOR = 1;
+
+// tag of the child of my label that contains information transformation points
+static const int TAG_TRSF_POINTS = 2;
+
static const Standard_GUID GUID_MUST_BE_UPDATED("80f2bb81-3873-4631-8ddd-940d2119f000");
IMPLEMENT_STANDARD_HANDLE(HYDROData_Image, HYDROData_Object)
return aTrsf;
}
+void HYDROData_Image::SetTrsfPoints(const QPoint& thePointAIn,
+ const QPoint& thePointBIn,
+ const QPoint& thePointCIn,
+ const QPointF& thePointAOut,
+ const QPointF& thePointBOut,
+ const QPointF& thePointCOut)
+{
+ Handle(TDataStd_RealArray) anArray;
+ if (!myLab.FindChild(TAG_TRSF_POINTS).FindAttribute(TDataStd_RealArray::GetID(), anArray)) {
+ anArray = TDataStd_RealArray::Set(myLab.FindChild(TAG_TRSF_POINTS), 1, 12);
+ }
+ anArray->SetValue(1, thePointAIn.x());
+ anArray->SetValue(2, thePointAIn.y());
+ anArray->SetValue(3, thePointBIn.x());
+ anArray->SetValue(4, thePointBIn.y());
+ anArray->SetValue(5, thePointCIn.x());
+ anArray->SetValue(6, thePointCIn.y());
+ anArray->SetValue(7, thePointAOut.x());
+ anArray->SetValue(8, thePointAOut.y());
+ anArray->SetValue(9, thePointBOut.x());
+ anArray->SetValue(10, thePointBOut.y());
+ anArray->SetValue(11, thePointCOut.x());
+ anArray->SetValue(12, thePointCOut.y());
+}
+
+void HYDROData_Image::TrsfPoints(QPoint& thePointAIn,
+ QPoint& thePointBIn,
+ QPoint& thePointCIn,
+ QPointF& thePointAOut,
+ QPointF& thePointBOut,
+ QPointF& thePointCOut)
+{
+ Handle(TDataStd_RealArray) anArray;
+ if (myLab.FindChild(TAG_TRSF_POINTS).FindAttribute(TDataStd_RealArray::GetID(), anArray)) {
+ thePointAIn = QPointF( anArray->Value(1), anArray->Value(2) ).toPoint();
+ thePointBIn = QPointF( anArray->Value(3), anArray->Value(4) ).toPoint();
+ thePointCIn = QPointF( anArray->Value(5), anArray->Value(6) ).toPoint();
+ thePointAOut = QPointF( anArray->Value(7), anArray->Value(8) );
+ thePointBOut = QPointF( anArray->Value(9), anArray->Value(10) );
+ thePointCOut = QPointF( anArray->Value(11), anArray->Value(12) );
+ }
+}
+
void HYDROData_Image::AppendReference(Handle(HYDROData_Image) theReferenced)
{
Handle(TDataStd_ReferenceList) aRefs;
*/
HYDRODATA_EXPORT QTransform Trsf();
+ /**
+ * Stores the image transformation points (3 input + 3 output)
+ * \param thePointAIn input point A
+ * \param thePointBIn input point B
+ * \param thePointCIn input point C
+ * \param thePointAOut output point A
+ * \param thePointBOut output point B
+ * \param thePointCOut output point C
+ */
+ HYDRODATA_EXPORT void SetTrsfPoints(const QPoint& thePointAIn,
+ const QPoint& thePointBIn,
+ const QPoint& thePointCIn,
+ const QPointF& thePointAOut,
+ const QPointF& thePointBOut,
+ const QPointF& thePointCOut);
+
+ /**
+ * Returns the image transformation points (3 input + 3 output)
+ * \param thePointAIn input point A
+ * \param thePointBIn input point B
+ * \param thePointCIn input point C
+ * \param thePointAOut output point A
+ * \param thePointBOut output point B
+ * \param thePointCOut output point C
+ */
+ HYDRODATA_EXPORT void TrsfPoints(QPoint& thePointAIn,
+ QPoint& thePointBIn,
+ QPoint& thePointCIn,
+ QPointF& thePointAOut,
+ QPointF& thePointBOut,
+ QPointF& thePointCOut);
+
/**
* Appends reference to other image.
* \param theReferenced the image referenced by this
HYDROGUI_GVSelector.h
HYDROGUI_ImportImageDlg.h
HYDROGUI_ImportImageOp.h
- HYDROGUI_PolylineOp.h
- HYDROGUI_PolylineDlg.h
HYDROGUI_InputPanel.h
HYDROGUI_Module.h
HYDROGUI_ObjSelector.h
HYDROGUI_Operation.h
HYDROGUI_Operations.h
+ HYDROGUI_PolylineDlg.h
+ HYDROGUI_PolylineOp.h
HYDROGUI_Prs.h
HYDROGUI_PrsDriver.h
HYDROGUI_PrsImage.h
HYDROGUI_GVSelector.cxx
HYDROGUI_ImportImageDlg.cxx
HYDROGUI_ImportImageOp.cxx
- HYDROGUI_PolylineDlg.cxx
- HYDROGUI_PolylineOp.cxx
HYDROGUI_InputPanel.cxx
HYDROGUI_Module.cxx
HYDROGUI_ObjSelector.cxx
HYDROGUI_Operation.cxx
HYDROGUI_Operations.cxx
- HYDROGUI_TwoImagesDlg.cxx
+ HYDROGUI_PolylineDlg.cxx
+ HYDROGUI_PolylineOp.cxx
HYDROGUI_Prs.cxx
HYDROGUI_PrsDriver.cxx
HYDROGUI_PrsImage.cxx
HYDROGUI_PrsImageDriver.cxx
HYDROGUI_PrsImageFrame.cxx
HYDROGUI_Tool.cxx
+ HYDROGUI_TwoImagesDlg.cxx
HYDROGUI_TwoImagesOp.cxx
)
#include <HYDROData_Document.h>
#include <HYDROData_Image.h>
#include <HYDROData_Iterator.h>
+#include <HYDROData_Polyline.h>
#include <CAM_Application.h>
#include <CAM_DataObject.h>
LightApp_DataObject* aPolylineRootObj = createObject( aRootObj, "POLYLINES" );
- HYDROData_Iterator aPolyIterator( aDocument, KIND_IMAGE );
+ HYDROData_Iterator aPolyIterator( aDocument, KIND_POLYLINE );
for( ; aPolyIterator.More(); aPolyIterator.Next() )
{
- Handle(HYDROData_Image) aPolylineObj =
- Handle(HYDROData_Image)::DownCast( anIterator.Current() );
+ Handle(HYDROData_Polyline) aPolylineObj =
+ Handle(HYDROData_Polyline)::DownCast( anIterator.Current() );
if( !aPolylineObj.IsNull() )
createObject( aPolylineRootObj, aPolylineObj );
}
#include "HYDROGUI_ImportImageDlg.h"
#include "HYDROGUI_PrsImage.h"
+#include "HYDROGUI_Tool.h"
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
#include <QDoubleValidator>
#include <QFileDialog>
#include <QGroupBox>
+#include <QIntValidator>
#include <QLabel>
#include <QLayout>
#include <QLineEdit>
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
// Import image from file
- QGroupBox* aFileGroup = new QGroupBox( tr( "IMPORT_IMAGE_FROM_FILE" ) );
+ myFileGroup = new QGroupBox( tr( "IMPORT_IMAGE_FROM_FILE" ) );
- QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), aFileGroup );
+ QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), myFileGroup );
- myFileName = new QLineEdit( aFileGroup );
+ myFileName = new QLineEdit( myFileGroup );
myFileName->setReadOnly( true );
- QToolButton* aBrowseBtn = new QToolButton( aFileGroup );
+ QToolButton* aBrowseBtn = new QToolButton( myFileGroup );
aBrowseBtn->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "BROWSE_ICO" ) ) );
- QBoxLayout* aFileLayout = new QHBoxLayout( aFileGroup );
+ QBoxLayout* aFileLayout = new QHBoxLayout( myFileGroup );
aFileLayout->setMargin( 5 );
aFileLayout->setSpacing( 5 );
aFileLayout->addWidget( aFileNameLabel );
QString aPointStr;
switch( aPointType )
{
- case HYDROGUI_PrsImage::PointA: aPointStr = tr( "POINT_A" ); break;
- case HYDROGUI_PrsImage::PointB: aPointStr = tr( "POINT_B" ); break;
- case HYDROGUI_PrsImage::PointC: aPointStr = tr( "POINT_C" ); break;
+ case HYDROGUI_PrsImage::PointA: aPointStr = tr( "ACTIVATE_POINT_A_SELECTION" ); break;
+ case HYDROGUI_PrsImage::PointB: aPointStr = tr( "ACTIVATE_POINT_B_SELECTION" ); break;
+ case HYDROGUI_PrsImage::PointC: aPointStr = tr( "ACTIVATE_POINT_C_SELECTION" ); break;
}
QPushButton* aPointBtn = new QPushButton( aPointStr, myMappingGroup );
aPointBtn->setCheckable( true );
- QLabel* aPointXLabel = new QLabel( tr( "X" ), myMappingGroup );
- QLabel* aPointYLabel = new QLabel( tr( "Y" ), myMappingGroup );
+ QLabel* aPointXLabel = new QLabel( "X", myMappingGroup );
+ QLabel* aPointYLabel = new QLabel( "Y", myMappingGroup );
- QLineEdit* aPointX1 = new QLineEdit( myMappingGroup );
- QLineEdit* aPointY1 = new QLineEdit( myMappingGroup );
+ QLineEdit* aPointX = new QLineEdit( myMappingGroup );
+ QLineEdit* aPointY = new QLineEdit( myMappingGroup );
- aPointX1->setReadOnly( true );
- aPointY1->setReadOnly( true );
+ aPointX->setReadOnly( true );
+ aPointY->setReadOnly( true );
//QLabel* aPointArrowLabel = new QLabel( ">", myMappingGroup );
QLabel* aPointArrowLabel = new QLabel( myMappingGroup );
aPointArrowLabel->setPicture( anArrowPicture );
- QLineEdit* aPointX2 = new QLineEdit( myMappingGroup );
- QLineEdit* aPointY2 = new QLineEdit( myMappingGroup );
-
- QDoubleValidator* aDoubleValidator = new QDoubleValidator();
- aPointX2->setValidator( aDoubleValidator );
- aPointY2->setValidator( aDoubleValidator );
-
- int aRow = 3 * aPointType;
- aMappingLayout->addWidget( aPointBtn, aRow, 0, 2, 1 );
- aMappingLayout->addWidget( aPointXLabel, aRow, 1 );
- aMappingLayout->addWidget( aPointX1, aRow, 2 );
- aMappingLayout->addWidget( aPointArrowLabel, aRow, 3, 2, 1 );
- aMappingLayout->addWidget( aPointX2, aRow, 4 );
- aMappingLayout->addWidget( aPointYLabel, aRow + 1, 1 );
- aMappingLayout->addWidget( aPointY1, aRow + 1, 2 );
- aMappingLayout->addWidget( aPointY2, aRow + 1, 4 );
+ QLabel* aPointXDegLabel = new QLabel( QChar( 0x00B0 ), myMappingGroup );
+ QLabel* aPointYDegLabel = new QLabel( QChar( 0x00B0 ), myMappingGroup );
+ QLabel* aPointXMinLabel = new QLabel( "'", myMappingGroup );
+ QLabel* aPointYMinLabel = new QLabel( "'", myMappingGroup );
+ QLabel* aPointXSecLabel = new QLabel( "\"", myMappingGroup );
+ QLabel* aPointYSecLabel = new QLabel( "\"", myMappingGroup );
+
+ QLineEdit* aPointXDeg = new QLineEdit( myMappingGroup );
+ QLineEdit* aPointYDeg = new QLineEdit( myMappingGroup );
+ QLineEdit* aPointXMin = new QLineEdit( myMappingGroup );
+ QLineEdit* aPointYMin = new QLineEdit( myMappingGroup );
+ QLineEdit* aPointXSec = new QLineEdit( myMappingGroup );
+ QLineEdit* aPointYSec = new QLineEdit( myMappingGroup );
+
+ QIntValidator* aXDegValidator = new QIntValidator( -180, 180, this );
+ QIntValidator* aYDegValidator = new QIntValidator( -90, 90, this );
+ QIntValidator* aMinValidator = new QIntValidator( 0, 59, this );
+ QDoubleValidator* aSecValidator = new QDoubleValidator( 0, 59.9999, 4, this );
+
+ aPointXDeg->setValidator( aXDegValidator );
+ aPointYDeg->setValidator( aYDegValidator );
+ aPointXMin->setValidator( aMinValidator );
+ aPointYMin->setValidator( aMinValidator );
+ aPointXSec->setValidator( aSecValidator );
+ aPointYSec->setValidator( aSecValidator );
+
+ int aRow = 4 * aPointType;
+ aMappingLayout->addWidget( aPointBtn, aRow, 0, 1, 9 );
+
+ aMappingLayout->addWidget( aPointXLabel, aRow + 1, 0 );
+ aMappingLayout->addWidget( aPointX, aRow + 1, 1 );
+ aMappingLayout->addWidget( aPointArrowLabel, aRow + 1, 2, 2, 1 );
+ aMappingLayout->addWidget( aPointXDeg, aRow + 1, 3 );
+ aMappingLayout->addWidget( aPointXDegLabel, aRow + 1, 4 );
+ aMappingLayout->addWidget( aPointXMin, aRow + 1, 5 );
+ aMappingLayout->addWidget( aPointXMinLabel, aRow + 1, 6 );
+ aMappingLayout->addWidget( aPointXSec, aRow + 1, 7 );
+ aMappingLayout->addWidget( aPointXSecLabel, aRow + 1, 8 );
+
+ aMappingLayout->addWidget( aPointYLabel, aRow + 2, 0 );
+ aMappingLayout->addWidget( aPointY, aRow + 2, 1 );
+ aMappingLayout->addWidget( aPointYDeg, aRow + 2, 3 );
+ aMappingLayout->addWidget( aPointYDegLabel, aRow + 2, 4 );
+ aMappingLayout->addWidget( aPointYMin, aRow + 2, 5 );
+ aMappingLayout->addWidget( aPointYMinLabel, aRow + 2, 6 );
+ aMappingLayout->addWidget( aPointYSec, aRow + 2, 7 );
+ aMappingLayout->addWidget( aPointYSecLabel, aRow + 2, 8 );
if( aPointType != HYDROGUI_PrsImage::PointC )
{
QFrame* aLine = new QFrame( myMappingGroup );
aLine->setFrameShape( QFrame::HLine );
aLine->setFrameShadow( QFrame::Sunken );
- aMappingLayout->addWidget( aLine, aRow + 2, 0, 1, 5 );
+ aMappingLayout->addWidget( aLine, aRow + 3, 0, 1, 9 );
}
myPointBtnMap[ aPointType ] = aPointBtn;
- myPointX1Map[ aPointType ] = aPointX1;
- myPointY1Map[ aPointType ] = aPointY1;
- myPointX2Map[ aPointType ] = aPointX2;
- myPointY2Map[ aPointType ] = aPointY2;
+ myPointXMap[ aPointType ] = aPointX;
+ myPointYMap[ aPointType ] = aPointY;
+ myPointXDegMap[ aPointType ] = aPointXDeg;
+ myPointYDegMap[ aPointType ] = aPointYDeg;
+ myPointXMinMap[ aPointType ] = aPointXMin;
+ myPointYMinMap[ aPointType ] = aPointYMin;
+ myPointXSecMap[ aPointType ] = aPointXSec;
+ myPointYSecMap[ aPointType ] = aPointYSec;
connect( aPointBtn, SIGNAL( toggled( bool ) ), this, SLOT( onPointBtnToggled( bool ) ) );
}
+ aMappingLayout->setColumnStretch( 1, 1 ); // x
+ aMappingLayout->setColumnStretch( 3, 1 ); // degrees
+ aMappingLayout->setColumnStretch( 5, 1 ); // minutes
+ aMappingLayout->setColumnStretch( 7, 2 ); // seconds (double with 4 digits)
// Common
- addWidget( aFileGroup, 0, 0 );
+ addWidget( myFileGroup, 0, 0 );
addWidget( myMappingGroup, 1, 0 );
setRowStretch();
{
}
+void HYDROGUI_ImportImageDlg::setIsEdit( const bool theIsEdit )
+{
+ myFileGroup->setVisible( !theIsEdit );
+ myMappingGroup->setEnabled( theIsEdit );
+}
+
void HYDROGUI_ImportImageDlg::reset()
{
myFileName->clear();
aBtn->setChecked( false );
aBtn->blockSignals( anIsBlocked );
- myPointX1Map[ aPointType ]->clear();
- myPointY1Map[ aPointType ]->clear();
- myPointX2Map[ aPointType ]->clear();
- myPointY2Map[ aPointType ]->clear();
+ myPointXMap[ aPointType ]->clear();
+ myPointYMap[ aPointType ]->clear();
+ myPointXDegMap[ aPointType ]->clear();
+ myPointYDegMap[ aPointType ]->clear();
+ myPointXMinMap[ aPointType ]->clear();
+ myPointYMinMap[ aPointType ]->clear();
+ myPointXSecMap[ aPointType ]->clear();
+ myPointYSecMap[ aPointType ]->clear();
}
myMappingGroup->setEnabled( false );
}
-void HYDROGUI_ImportImageDlg::setTransformationDataMap( const TransformationDataMap& theMap )
+void HYDROGUI_ImportImageDlg::setTransformationDataMap( const TransformationDataMap& theMap,
+ const bool theIsOnlyInput )
{
for( int aPointType = HYDROGUI_PrsImage::PointA;
aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
if( theMap.contains( aPointType ) )
{
const TransformationData& aData = theMap[ aPointType ];
- myPointX1Map[ aPointType ]->setText( QString::number( aData.first.x() ) );
- myPointY1Map[ aPointType ]->setText( QString::number( aData.first.y() ) );
+ myPointXMap[ aPointType ]->setText( QString::number( aData.first.x() ) );
+ myPointYMap[ aPointType ]->setText( QString::number( aData.first.y() ) );
+
+ if( !theIsOnlyInput )
+ {
+ QPointF aPoint = aData.second;
+ int aXDeg = 0, aYDeg = 0;
+ int aXMin = 0, aYMin = 0;
+ double aXSec = 0, aYSec = 0;
+ HYDROGUI_Tool::DoubleToLambert( aPoint.x(), aXDeg, aXMin, aXSec );
+ HYDROGUI_Tool::DoubleToLambert( aPoint.y(), aYDeg, aYMin, aYSec );
+
+ myPointXDegMap[ aPointType ]->setText( QString::number( aXDeg ) );
+ myPointYDegMap[ aPointType ]->setText( QString::number( aYDeg ) );
+ myPointXMinMap[ aPointType ]->setText( QString::number( aXMin ) );
+ myPointYMinMap[ aPointType ]->setText( QString::number( aYMin ) );
+ myPointXSecMap[ aPointType ]->setText( QString::number( aXSec ) );
+ myPointYSecMap[ aPointType ]->setText( QString::number( aYSec ) );
+ }
}
}
}
for( int aPointType = HYDROGUI_PrsImage::PointA;
aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
{
- bool anIsOk = false;
- int aX1 = myPointX1Map[ aPointType ]->text().toInt( &anIsOk );
- if( !anIsOk )
- return false;
-
- anIsOk = false;
- int aY1 = myPointY1Map[ aPointType ]->text().toInt( &anIsOk );
- if( !anIsOk )
- return false;
-
- anIsOk = false;
- double aX2 = myPointX2Map[ aPointType ]->text().toDouble( &anIsOk );
- if( !anIsOk )
- return false;
-
- anIsOk = false;
- double aY2 = myPointY2Map[ aPointType ]->text().toDouble( &anIsOk );
- if( !anIsOk )
- return false;
+ bool anIsOk[8];
+ for( int i = 0; i < 8; i++ )
+ anIsOk[ i ] = false;
+
+ int aX1 = myPointXMap[ aPointType ]->text().toInt( &anIsOk[0] );
+ int aY1 = myPointYMap[ aPointType ]->text().toInt( &anIsOk[1] );
+ int aXDeg = myPointXDegMap[ aPointType ]->text().toInt( &anIsOk[2] );
+ int aYDeg = myPointYDegMap[ aPointType ]->text().toInt( &anIsOk[3] );
+ int aXMin = myPointXMinMap[ aPointType ]->text().toInt( &anIsOk[4] );
+ int aYMin = myPointYMinMap[ aPointType ]->text().toInt( &anIsOk[5] );
+ double aXSec = myPointXSecMap[ aPointType ]->text().toDouble( &anIsOk[6] );
+ double aYSec = myPointYSecMap[ aPointType ]->text().toDouble( &anIsOk[7] );
+
+ for( int i = 0; i < 8; i++ )
+ if( !anIsOk[ i ] )
+ return false;
+
+ double aX2 = 0, aY2 = 0;
+ HYDROGUI_Tool::LambertToDouble( aXDeg, aXMin, aXSec, aX2 );
+ HYDROGUI_Tool::LambertToDouble( aYDeg, aYMin, aYSec, aY2 );
TransformationData aData( QPoint( aX1, aY1 ), QPointF( aX2, aY2 ) );
theMap[ aPointType ] = aData;
void HYDROGUI_ImportImageDlg::initializePointSelection()
{
myPointBtnMap[ HYDROGUI_PrsImage::PointA ]->setChecked( true );
-}
-void HYDROGUI_ImportImageDlg::synchronizeTransformedPoints()
-{
- for( int aPointType = HYDROGUI_PrsImage::PointA;
- aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
- {
- myPointX2Map[ aPointType ]->setText( myPointX1Map[ aPointType ]->text() );
- myPointY2Map[ aPointType ]->setText( myPointY1Map[ aPointType ]->text() );
- }
+ // ouv: tmp
+ myPointXDegMap[ HYDROGUI_PrsImage::PointA ]->setText( "50" );
+ myPointXMinMap[ HYDROGUI_PrsImage::PointA ]->setText( "0" );
+ myPointXSecMap[ HYDROGUI_PrsImage::PointA ]->setText( "0" );
+ myPointYDegMap[ HYDROGUI_PrsImage::PointA ]->setText( "50" );
+ myPointYMinMap[ HYDROGUI_PrsImage::PointA ]->setText( "0" );
+ myPointYSecMap[ HYDROGUI_PrsImage::PointA ]->setText( "0" );
+
+ myPointXDegMap[ HYDROGUI_PrsImage::PointB ]->setText( "50" );
+ myPointXMinMap[ HYDROGUI_PrsImage::PointB ]->setText( "1" );
+ myPointXSecMap[ HYDROGUI_PrsImage::PointB ]->setText( "0" );
+ myPointYDegMap[ HYDROGUI_PrsImage::PointB ]->setText( "50" );
+ myPointYMinMap[ HYDROGUI_PrsImage::PointB ]->setText( "0" );
+ myPointYSecMap[ HYDROGUI_PrsImage::PointB ]->setText( "0" );
+
+ myPointXDegMap[ HYDROGUI_PrsImage::PointC ]->setText( "50" );
+ myPointXMinMap[ HYDROGUI_PrsImage::PointC ]->setText( "0" );
+ myPointXSecMap[ HYDROGUI_PrsImage::PointC ]->setText( "0" );
+ myPointYDegMap[ HYDROGUI_PrsImage::PointC ]->setText( "50" );
+ myPointYMinMap[ HYDROGUI_PrsImage::PointC ]->setText( "1" );
+ myPointYSecMap[ HYDROGUI_PrsImage::PointC ]->setText( "0" );
}
void HYDROGUI_ImportImageDlg::onBrowse()
{
QString aFilter( tr( "IMAGE_FILTER" ) );
- QString aFileName = QFileDialog::getOpenFileName( this, tr( "BROWSE_IMAGE_FILE" ), "", aFilter );
+ //QString aFileName = QFileDialog::getOpenFileName( this, tr( "BROWSE_IMAGE_FILE" ), "", aFilter );
+ QString aFileName = "W:/Work/HYDRO/doc/samples/1.bmp";
if( !aFileName.isEmpty() )
{
- myFileName->setText( aFileName );
- emit createPreview( aFileName );
- myMappingGroup->setEnabled( true );
+ QImage anImage( aFileName );
+ if( !anImage.isNull() )
+ {
+ myFileName->setText( aFileName );
+ emit createPreview( anImage );
+ myMappingGroup->setEnabled( true );
+ }
}
}
HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, const QString& theTitle );
virtual ~HYDROGUI_ImportImageDlg();
+ void setIsEdit( const bool theIsEdit );
void reset();
- void setTransformationDataMap( const TransformationDataMap& theMap );
+ void setTransformationDataMap( const TransformationDataMap& theMap,
+ const bool theIsOnlyInput = false );
bool getTransformationDataMap( TransformationDataMap& theMap ) const;
void initializePointSelection();
- void synchronizeTransformedPoints();
protected slots:
void onBrowse();
void onPointBtnToggled( bool );
signals:
- void createPreview( QString );
+ void createPreview( QImage );
void activatePointSelection( int );
private:
+ QGroupBox* myFileGroup;
QLineEdit* myFileName;
QGroupBox* myMappingGroup;
QMap<int, QPushButton*> myPointBtnMap;
- QMap<int, QLineEdit*> myPointX1Map;
- QMap<int, QLineEdit*> myPointY1Map;
- QMap<int, QLineEdit*> myPointX2Map;
- QMap<int, QLineEdit*> myPointY2Map;
+ QMap<int, QLineEdit*> myPointXMap;
+ QMap<int, QLineEdit*> myPointYMap;
+ QMap<int, QLineEdit*> myPointXDegMap;
+ QMap<int, QLineEdit*> myPointYDegMap;
+ QMap<int, QLineEdit*> myPointXMinMap;
+ QMap<int, QLineEdit*> myPointYMinMap;
+ QMap<int, QLineEdit*> myPointXSecMap;
+ QMap<int, QLineEdit*> myPointYSecMap;
};
#endif
#include "HYDROGUI_ImportImageOp.h"
+#include "HYDROGUI_DataModel.h"
#include "HYDROGUI_ImportImageDlg.h"
#include "HYDROGUI_Module.h"
#include "HYDROGUI_PrsImage.h"
#include "HYDROGUI_Tool.h"
+#include "HYDROGUI_UpdateFlags.h"
#include <HYDROData_Document.h>
-#include <HYDROData_Image.h>
#include <GraphicsView_ViewManager.h>
#include <GraphicsView_ViewPort.h>
#include <LightApp_Application.h>
#include <LightApp_UpdateFlags.h>
-HYDROGUI_ImportImageOp::HYDROGUI_ImportImageOp( HYDROGUI_Module* theModule )
+HYDROGUI_ImportImageOp::HYDROGUI_ImportImageOp( HYDROGUI_Module* theModule,
+ const bool theIsEdit )
: HYDROGUI_Operation( theModule ),
+ myIsEdit( theIsEdit ),
+ myEditedObject( 0 ),
myActiveViewManager( 0 ),
myPreviewViewManager( 0 ),
myPreviewPrs( 0 ),
myPointType( HYDROGUI_PrsImage::None )
{
- setName( tr( "IMPORT_IMAGE" ) );
+ setName( theIsEdit ? tr( "EDIT_IMAGE" ) : tr( "IMPORT_IMAGE" ) );
}
HYDROGUI_ImportImageOp::~HYDROGUI_ImportImageOp()
HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel();
aPanel->reset();
+ aPanel->setIsEdit( myIsEdit );
+
+ if( myIsEdit )
+ {
+ myEditedObject = Handle(HYDROData_Image)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+ if( !myEditedObject.IsNull() )
+ {
+ QImage anImage = myEditedObject->Image();
+
+ QPoint aPointA1, aPointB1, aPointC1;
+ QPointF aPointA2, aPointB2, aPointC2;
+ myEditedObject->TrsfPoints( aPointA1, aPointB1, aPointC1,
+ aPointA2, aPointB2, aPointC2 );
+
+ onCreatePreview( anImage );
+
+ if( myPreviewPrs )
+ {
+ HYDROGUI_PrsImage::TransformationPointMap aPointMap =
+ myPreviewPrs->getTransformationPointMap();
+ if( !aPointMap.isEmpty() )
+ {
+ aPointMap[ HYDROGUI_PrsImage::PointA ].Point = aPointA1;
+ aPointMap[ HYDROGUI_PrsImage::PointB ].Point = aPointB1;
+ aPointMap[ HYDROGUI_PrsImage::PointC ].Point = aPointC1;
+ myPreviewPrs->setTransformationPointMap( aPointMap );
+ }
+ }
+
+ HYDROGUI_ImportImageDlg::TransformationDataMap aDataMap;
+ aDataMap[ HYDROGUI_PrsImage::PointA ] =
+ HYDROGUI_ImportImageDlg::TransformationData( aPointA1, aPointA2 );
+ aDataMap[ HYDROGUI_PrsImage::PointB ] =
+ HYDROGUI_ImportImageDlg::TransformationData( aPointB1, aPointB2 );
+ aDataMap[ HYDROGUI_PrsImage::PointC ] =
+ HYDROGUI_ImportImageDlg::TransformationData( aPointC1, aPointC2 );
+ ( (HYDROGUI_ImportImageDlg*)inputPanel() )->setTransformationDataMap( aDataMap );
+ }
+ }
}
HYDROGUI_InputPanel* HYDROGUI_ImportImageOp::createInputPanel() const
{
HYDROGUI_InputPanel* aPanel = new HYDROGUI_ImportImageDlg( module(), getName() );
- connect( aPanel, SIGNAL( createPreview( QString ) ),
- this, SLOT( onCreatePreview( QString ) ) );
+ connect( aPanel, SIGNAL( createPreview( QImage ) ),
+ this, SLOT( onCreatePreview( QImage ) ) );
connect( aPanel, SIGNAL( activatePointSelection( int ) ),
this, SLOT( onActivatePointSelection( int ) ) );
return aPanel;
if( !anIsOk || !myPreviewPrs )
return false;
- double xa1 = aMap[ HYDROGUI_PrsImage::PointA ].first.x();
- double ya1 = aMap[ HYDROGUI_PrsImage::PointA ].first.y();
- double xb1 = aMap[ HYDROGUI_PrsImage::PointB ].first.x();
- double yb1 = aMap[ HYDROGUI_PrsImage::PointB ].first.y();
- double xc1 = aMap[ HYDROGUI_PrsImage::PointC ].first.x();
- double yc1 = aMap[ HYDROGUI_PrsImage::PointC ].first.y();
+ QPoint aPointA1 = aMap[ HYDROGUI_PrsImage::PointA ].first;
+ QPoint aPointB1 = aMap[ HYDROGUI_PrsImage::PointB ].first;
+ QPoint aPointC1 = aMap[ HYDROGUI_PrsImage::PointC ].first;
- double xa2 = aMap[ HYDROGUI_PrsImage::PointA ].second.x();
- double ya2 = aMap[ HYDROGUI_PrsImage::PointA ].second.y();
- double xb2 = aMap[ HYDROGUI_PrsImage::PointB ].second.x();
- double yb2 = aMap[ HYDROGUI_PrsImage::PointB ].second.y();
- double xc2 = aMap[ HYDROGUI_PrsImage::PointC ].second.x();
- double yc2 = aMap[ HYDROGUI_PrsImage::PointC ].second.y();
+ QPointF aPointA2 = aMap[ HYDROGUI_PrsImage::PointA ].second;
+ QPointF aPointB2 = aMap[ HYDROGUI_PrsImage::PointB ].second;
+ QPointF aPointC2 = aMap[ HYDROGUI_PrsImage::PointC ].second;
+
+ double xa1 = aPointA1.x();
+ double ya1 = aPointA1.y();
+ double xb1 = aPointB1.x();
+ double yb1 = aPointB1.y();
+ double xc1 = aPointC1.x();
+ double yc1 = aPointC1.y();
+
+ double xa2 = aPointA2.x();
+ double ya2 = aPointA2.y();
+ double xb2 = aPointB2.x();
+ double yb2 = aPointB2.y();
+ double xc2 = aPointC2.x();
+ double yc2 = aPointC2.y();
QTransform aTransform1( xa1, ya1, 1, xb1, yb1, 1, xc1, yc1, 1 );
QTransform aTransform2( xa2, ya2, 1, xb2, yb2, 1, xc2, yc2, 1 );
closePreview();
- int aStudyId = module()->getStudyId();
- Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( aStudyId );
- if( aDocument.IsNull() )
- return false;
+ Handle(HYDROData_Image) anImageObj;
+ if( myIsEdit )
+ anImageObj = myEditedObject;
+ else
+ anImageObj = Handle(HYDROData_Image)::DownCast( doc()->CreateObject( KIND_IMAGE ) );
- Handle(HYDROData_Image) anImageObj =
- Handle(HYDROData_Image)::DownCast( aDocument->CreateObject( KIND_IMAGE ) );
if( anImageObj.IsNull() )
return false;
- static int ImageId = 0;
- anImageObj->SetName( QString( "Image_%1" ).arg( QString::number( ++ImageId ) ) );
+ if( !myIsEdit )
+ {
+ static int ImageId = 0;
+ anImageObj->SetName( QString( "Image_%1" ).arg( QString::number( ++ImageId ) ) );
+ }
anImageObj->SetImage( anImage );
anImageObj->SetTrsf( aTransform );
+
+ anImageObj->SetTrsfPoints( aPointA1, aPointB1, aPointC1,
+ aPointA2, aPointB2, aPointC2 );
+
anImageObj->SetVisibility( true );
- theUpdateFlags = UF_Model | UF_Viewer;
+ theUpdateFlags = UF_Model | UF_Viewer | UF_GV_Forced;
return true;
}
closePreview();
}
-void HYDROGUI_ImportImageOp::onCreatePreview( QString theFileName )
+void HYDROGUI_ImportImageOp::onCreatePreview( QImage theImage )
{
LightApp_Application* anApp = module()->getApp();
myActiveViewManager = anApp->activeViewManager();
- myPreviewPrs = new HYDROGUI_PrsImage( 0 ); // no data object
-
- QImage anImage( theFileName );
- myPreviewPrs->setImage( anImage );
-
+ myPreviewPrs = new HYDROGUI_PrsImage( myIsEdit ? myEditedObject : 0 );
+ myPreviewPrs->setImage( theImage );
myPreviewPrs->compute();
myPreviewViewManager =
aPanel->initializePointSelection();
onPointSelected();
-
- aPanel->synchronizeTransformedPoints();
}
void HYDROGUI_ImportImageOp::onActivatePointSelection( int thePointType )
aDataMap[ aPointType ] = aData;
}
- ( (HYDROGUI_ImportImageDlg*)inputPanel() )->setTransformationDataMap( aDataMap );
+ ( (HYDROGUI_ImportImageDlg*)inputPanel() )->setTransformationDataMap( aDataMap, true );
}
void HYDROGUI_ImportImageOp::closePreview()
#include "HYDROGUI_Operation.h"
+#include <HYDROData_Image.h>
+
+#include <QImage>
+
class GraphicsView_ViewManager;
class SUIT_ViewManager;
Q_OBJECT
public:
- HYDROGUI_ImportImageOp( HYDROGUI_Module* theModule );
+ HYDROGUI_ImportImageOp( HYDROGUI_Module* theModule, const bool theIsEdit );
virtual ~HYDROGUI_ImportImageOp();
protected:
virtual void processCancel();
protected slots:
- void onCreatePreview( QString );
+ void onCreatePreview( QImage );
void onActivatePointSelection( int );
void onPointSelected();
void closePreview();
private:
+ bool myIsEdit;
+ Handle(HYDROData_Image) myEditedObject;
+
SUIT_ViewManager* myActiveViewManager;
GraphicsView_ViewManager* myPreviewViewManager;
bool anIsVisibleInSelection = false;
bool anIsHiddenInSelection = false;
+ bool anIsImage = false;
+
foreach( SUIT_DataOwner* aSUITOwner, anOwners )
{
if( LightApp_DataOwner* anOwner = dynamic_cast<LightApp_DataOwner*>( aSUITOwner ) )
Handle(HYDROData_Object) anObject = aModel->objectByEntry( anOwner->entry() );
if( !anObject.IsNull() )
{
+ anIsSelection = true;
+
bool aVisibility = anObject->GetVisibility();
anIsVisibleInSelection |= aVisibility;
anIsHiddenInSelection |= !aVisibility;
- anIsSelection = true;
+
+ if( anObject->GetKind() == KIND_IMAGE )
+ anIsImage = true;
}
}
}
+ if( anOwners.count() == 1 && anIsImage )
+ {
+ theMenu->addAction( action( EditImageId ) );
+ theMenu->addSeparator();
+ }
+
if( anIsSelection )
{
theMenu->addAction( action( DeleteId ) );
{
if( GraphicsView_Viewer* aViewer = dynamic_cast<GraphicsView_Viewer*>( aViewFrame->getViewer() ) )
{
- update( UF_Viewer | UF_GV_Forced );
+ //update( UF_Viewer | UF_GV_Forced ); // ouv: to do
aViewer->activateTransform( GraphicsView_Viewer::FitAll );
if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
aViewPort->setInteractionFlag( GraphicsView_ViewPort::TraceBoundingRect );
aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateContextMenu );
aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateSelection );
+
+ // ouv: tmp
+ aViewPort->setMousePositionEnabled( true );
}
}
}
#include "HYDROGUI_DeleteOp.h"
#include "HYDROGUI_ImportImageOp.h"
#include "HYDROGUI_Module.h"
+#include "HYDROGUI_PolylineOp.h"
#include "HYDROGUI_ShowHideOp.h"
#include "HYDROGUI_TwoImagesOp.h"
-#include "HYDROGUI_PolylineOp.h"
#include "HYDROGUI_UpdateFlags.h"
#include <CAM_Application.h>
void HYDROGUI_Module::createActions()
{
createAction( ImportImageId, "IMPORT_IMAGE", "", Qt::CTRL + Qt::Key_I );
- createAction( FuseId, "FUSE_IMAGES" );
- createAction( CutId, "CUT_IMAGES" );
-
+ createAction( EditImageId, "EDIT_IMAGE" );
createAction( PolylineId, "POLYLINE" );
+ createAction( FuseId, "FUSE_IMAGES" );
+ createAction( CutId, "CUT_IMAGES" );
createAction( DeleteId, "DELETE", "", Qt::Key_Delete );
int aHydroMenu = 6; // Edit menu id == 5, View menu id == 10
int aHydroId = createMenu( tr( "MEN_DESK_HYDRO" ), -1, -1, aHydroMenu );
createMenu( ImportImageId, aHydroId, -1, -1 );
+ createMenu( PolylineId, aHydroId, -1, -1 );
createMenu( FuseId, aHydroId, -1, -1 );
createMenu( CutId, aHydroId, -1, -1 );
- createMenu( PolylineId, aHydroId, -1, -1 );
}
void HYDROGUI_Module::createPopups()
switch( theId )
{
case ImportImageId:
- anOp = new HYDROGUI_ImportImageOp( aModule );
+ case EditImageId:
+ anOp = new HYDROGUI_ImportImageOp( aModule, theId == EditImageId );
break;
+ case PolylineId:
+ anOp = new HYDROGUI_PolylineOp( aModule );
case FuseId:
anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Fuse );
break;
case HideAllId:
anOp = new HYDROGUI_ShowHideOp( aModule, theId );
break;
- case PolylineId:
- anOp = new HYDROGUI_PolylineOp( aModule );
}
if( !anOp )
enum OperationId
{
FirstId = 0,
-
UndoId,
RedoId,
-
ImportImageId,
+ EditImageId,
+ PolylineId,
FuseId,
CutId,
-
DeleteId,
-
ShowId,
ShowOnlyId,
ShowAllId,
HideId,
HideAllId,
- PolylineId,
};
#endif
computeTransformationPoints();
}
+//================================================================
+// Function : setTransformationPointMap
+// Purpose :
+//================================================================
+void HYDROGUI_PrsImage::setTransformationPointMap( const TransformationPointMap& theMap )
+{
+ myTransformationPointMap = theMap;
+ if( !theMap.isEmpty() )
+ computeTransformationPoints();
+}
+
//================================================================
// Function : boundingRect
// Purpose :
bool getIsTransformationPointPreview() const;
void setTransformationPointMode( const int theMode );
+
+ void setTransformationPointMap( const TransformationPointMap& theMap );
const TransformationPointMap& getTransformationPointMap() const { return myTransformationPointMap; }
public:
#include <HYDROData_Iterator.h>
#include <LightApp_Application.h>
+#include <LightApp_DataOwner.h>
+#include <LightApp_SelectionMgr.h>
#include <QtxWorkstack.h>
return new TCollection_HExtendedString( ToExtString( src ) );
}
+void HYDROGUI_Tool::LambertToDouble( const int theDegrees,
+ const int theMinutes,
+ const double theSeconds,
+ double& theCoord )
+{
+ // ouv: check the case of negative degrees
+ theCoord = theDegrees * 3600 + theMinutes * 60 + theSeconds;
+}
+
+void HYDROGUI_Tool::DoubleToLambert( const double theCoord,
+ int& theDegrees,
+ int& theMinutes,
+ double& theSeconds )
+{
+ // ouv: check the case of negative degrees
+ theDegrees = int( theCoord / 3600 );
+
+ double aRemainder = theCoord - theDegrees * 3600;
+ theMinutes = int( aRemainder / 60 );
+
+ theSeconds = aRemainder - theMinutes * 60;
+}
+
void HYDROGUI_Tool::SetActiveViewManager( HYDROGUI_Module* theModule,
SUIT_ViewManager* theViewManager )
{
}
return aList;
}
+
+HYDROData_SequenceOfObjects HYDROGUI_Tool::GetSelectedObjects( HYDROGUI_Module* theModule )
+{
+ HYDROData_SequenceOfObjects aSeq;
+
+ HYDROGUI_DataModel* aModel = theModule->getDataModel();
+
+ SUIT_SelectionMgr* aSelectionMgr = theModule->getApp()->selectionMgr();
+ SUIT_DataOwnerPtrList anOwners;
+ aSelectionMgr->selected( anOwners );
+
+ foreach( SUIT_DataOwner* aSUITOwner, anOwners )
+ {
+ if( LightApp_DataOwner* anOwner = dynamic_cast<LightApp_DataOwner*>( aSUITOwner ) )
+ {
+ Handle(HYDROData_Object) anObject = aModel->objectByEntry( anOwner->entry(), KIND_UNKNOWN );
+ if( !anObject.IsNull() )
+ aSeq.Append( anObject );
+ }
+ }
+ return aSeq;
+}
+
+Handle(HYDROData_Object) HYDROGUI_Tool::GetSelectedObject( HYDROGUI_Module* theModule )
+{
+ HYDROData_SequenceOfObjects aSeq = GetSelectedObjects( theModule );
+ if( !aSeq.IsEmpty() )
+ return aSeq.First();
+ return NULL;
+}
*/
static Handle(TCollection_HExtendedString) ToHExtString( const QString& );
+ /**
+ * \brief Encode the Lambert93 coordinates to the absolute double value
+ */
+ static void LambertToDouble( const int theDegrees,
+ const int theMinutes,
+ const double theSeconds,
+ double& theCoord );
+
+ /**
+ * \brief Decode the Lambert93 coordinates from the absolute double value
+ */
+ static void DoubleToLambert( const double theCoord,
+ int& theDegrees,
+ int& theMinutes,
+ double& theSeconds );
+
/**
* \brief Set the specified view manager to be active on the desktop.
* \param theModule module
const GraphicsView_ObjectList& theObjects );
/**
- * \brief Get list of HYDRO presentations from the specified viewport
+ * \brief Get list of HYDRO presentations from the specified viewport.
* \param theViewPort viewport
* \return list of HYDRO presentations
*/
static GraphicsView_ObjectList GetPrsList( GraphicsView_ViewPort* theViewPort );
+
+ /**
+ * \brief Get list of the selected data objects.
+ * \param theModule module
+ * \return list of the selected data objects
+ */
+ static HYDROData_SequenceOfObjects GetSelectedObjects( HYDROGUI_Module* theModule );
+
+ /**
+ * \brief Get the selected data object (first in the selected list).
+ * \param theModule module
+ * \return selected data object
+ */
+ static Handle(HYDROData_Object) GetSelectedObject( HYDROGUI_Module* theModule );
};
#endif
<translation>Mapping</translation>
</message>
<message>
- <source>POINT_A</source>
- <translation>Point A</translation>
+ <source>ACTIVATE_POINT_A_SELECTION</source>
+ <translation>Activate point A selection</translation>
</message>
<message>
- <source>POINT_B</source>
- <translation>Point B</translation>
+ <source>ACTIVATE_POINT_B_SELECTION</source>
+ <translation>Activate point B selection</translation>
</message>
<message>
- <source>POINT_C</source>
- <translation>Point C</translation>
+ <source>ACTIVATE_POINT_C_SELECTION</source>
+ <translation>Activate point C selection</translation>
</message>
</context>
<context>
<name>HYDROGUI_ImportImageOp</name>
+ <message>
+ <source>EDIT_IMAGE</source>
+ <translation>Edit image</translation>
+ </message>
<message>
<source>IMPORT_IMAGE</source>
<translation>Import image</translation>
<source>DSK_DELETE</source>
<translation>Delete</translation>
</message>
+ <message>
+ <source>DSK_EDIT_IMAGE</source>
+ <translation>Edit image</translation>
+ </message>
<message>
<source>DSK_FUSE_IMAGES</source>
<translation>Fuse images</translation>
<source>MEN_DESK_HYDRO</source>
<translation>HYDRO</translation>
</message>
+ <message>
+ <source>MEN_EDIT_IMAGE</source>
+ <translation>Edit image</translation>
+ </message>
<message>
<source>MEN_FUSE_IMAGES</source>
<translation>Fuse images</translation>
<source>STB_DELETE</source>
<translation>Delete</translation>
</message>
+ <message>
+ <source>STB_EDIT_IMAGE</source>
+ <translation>Edit image</translation>
+ </message>
<message>
<source>STB_FUSE_IMAGES</source>
<translation>Fuse images</translation>
<translation>Import image</translation>
</message>
<message>
- <source>STB_IMPORT_IMAGE</source>
+ <source>STB_POLYLINE</source>
<translation>Create polyline</translation>
</message>
<message>