#include <QApplication>
#include <QFileInfo>
+#define _DEVDEBUG_
+#include "HYDRO_trace.hxx"
+
HYDROGUI_ImportImageOp::HYDROGUI_ImportImageOp( HYDROGUI_Module* theModule,
const bool theIsEdit )
: HYDROGUI_Operation( theModule ),
myRefPreviewPrs( 0 ),
myPointType( HYDROGUI_PrsImage::None )
{
+ DEBTRACE("HYDROGUI_ImportImageOp");
setName( theIsEdit ? tr( "EDIT_IMPORTED_IMAGE" ) : tr( "IMPORT_IMAGE" ) );
}
HYDROGUI_ImportImageOp::~HYDROGUI_ImportImageOp()
{
+ DEBTRACE("~HYDROGUI_ImportImageOp");
}
void HYDROGUI_ImportImageOp::startOperation()
{
+ DEBTRACE("startOperation");
HYDROGUI_Operation::startOperation();
+ myEditedObject = 0;
+ myActiveViewManager = 0;
+ myPreviewViewManager = 0;
+ myRefViewManager = 0;
+ myPreviewPrs = 0;
+ myRefPreviewPrs = 0;
+ myPointType = HYDROGUI_PrsImage::None;
HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel();
aPanel->reset();
aPanel->setIsEdit( myIsEdit );
const QPoint theLocalPointB,
const QPoint theLocalPointC )
{
+ DEBTRACE("setPresentationTrsfPoints");
// Set transformation points A,B,C to the image presentation
if( thePrs )
{
void HYDROGUI_ImportImageOp::getReferenceDataList(
HYDROGUI_ImportImageDlg::PrsPointDataList& theList ) const
{
+ DEBTRACE("getReferenceDataList");
// Collect information about existing images and initialize the combobox
// reference image selector in the dialog.
HYDROData_Iterator anIterator( doc(), KIND_IMAGE );
const QPointF& theGlobalPointC,
HYDROGUI_ImportImageDlg::TransformationDataMap& theDataMap ) const
{
+ DEBTRACE("computeTrsfData");
// Build the local-global points map
HYDROGUI_ImportImageDlg::TransformationDataMap aDataMap;
theDataMap[ HYDROGUI_PrsImage::PointA ] =
void HYDROGUI_ImportImageOp::abortOperation()
{
+ DEBTRACE("abortOperation");
closePreview();
-
HYDROGUI_Operation::abortOperation();
}
void HYDROGUI_ImportImageOp::commitOperation()
{
+ DEBTRACE("commitOperation");
if ( isApplyAndClose() )
closePreview();
HYDROGUI_InputPanel* HYDROGUI_ImportImageOp::createInputPanel() const
{
+ DEBTRACE("createInputPanel");
HYDROGUI_InputPanel* aPanel = new HYDROGUI_ImportImageDlg( module(), getName() );
connect( aPanel, SIGNAL( createPreview( QImage, HYDROData_Image::ECW_FileInfo* ) ),
SLOT( onCreatePreview( QImage, HYDROData_Image::ECW_FileInfo* ) ) );
void HYDROGUI_ImportImageOp::onSetCIsUsed( bool theCIsUsed )
{
+ DEBTRACE("onSetCIsUsed");
if ( myPreviewPrs )
{
myPreviewPrs->setIsByTwoPoints( !theCIsUsed );
QString& theErrorMsg,
const bool theIsToCheckInvertibles ) const
{
+ DEBTRACE("checkPoints");
double xa = thePointA.x();
double ya = thePointA.y();
double xb = thePointB.x();
QString& theErrorMsg,
QStringList& theBrowseObjectsEntries )
{
+ DEBTRACE("processApply");
HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel();
if( !myIsEdit )
// must be done after all checks and before calling SetVisible() method below
if ( isApplyAndClose() )
+ {
+ DEBTRACE("closePreview");
closePreview();
+ }
if( !myIsEdit )
module()->setObjectVisible( HYDROGUI_Tool::GetActiveGraphicsViewId( module() ), anImageObj, true );
bool HYDROGUI_ImportImageOp::isReferenceCorrect() const
{
+ DEBTRACE("isReferenceCorrect");
bool isCorrect = true;
if( myIsEdit && !myEditedObject.IsNull() )
void HYDROGUI_ImportImageOp::apply()
{
+ DEBTRACE("apply");
HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel();
bool aCanApply = isReferenceCorrect();
void HYDROGUI_ImportImageOp::onCreatePreview( QImage theImage, HYDROData_Image::ECW_FileInfo* theFileInfo )
{
+ DEBTRACE("onCreatePreview");
HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel();
myImage = theImage;
void HYDROGUI_ImportImageOp::onActivatePointSelection( int thePointType )
{
+ DEBTRACE("onActivatePointSelection");
myPointType = thePointType;
if( myPreviewPrs )
myPreviewPrs->setTransformationPointType( thePointType );
bool theIsY,
int theValue )
{
+ DEBTRACE("onPointCoordChanged");
if( !theIsRef && myPreviewPrs )
myPreviewPrs->updateTransformationPoint( thePointType, theIsY, theValue );
else if( theIsRef && myRefPreviewPrs )
void HYDROGUI_ImportImageOp::onModeActivated( int theMode )
{
+ DEBTRACE("onModeActivated");
HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel();
QString aRefImageName;
void HYDROGUI_ImportImageOp::onRefImageActivated( const QString& theName )
{
+ DEBTRACE("onRefImageActivated");
if( theName.isEmpty() ) {
if( myRefViewManager )
closeView( myRefViewManager );
void HYDROGUI_ImportImageOp::onLastViewClosed( SUIT_ViewManager* theViewManager )
{
+ DEBTRACE("onLastViewClosed");
closePreview();
}
void HYDROGUI_ImportImageOp::onPointSelected()
{
+ DEBTRACE("onPointSelected");
onPointSelected( myRefPreviewPrs && myRefPreviewPrs->isSelected() );
}
void HYDROGUI_ImportImageOp::onRefPointSelected()
{
+ DEBTRACE("onRefPointSelected");
onPointSelected( true );
}
void HYDROGUI_ImportImageOp::onPointSelected( bool theIsRefImage )
{
+ DEBTRACE("onPointSelected");
HYDROGUI_PrsImage* aPrs = theIsRefImage ? myRefPreviewPrs : myPreviewPrs;
if( !aPrs )
return;
void HYDROGUI_ImportImageOp::closePreview()
{
+ DEBTRACE("closePreview");
closeView( myPreviewViewManager );
closeView( myRefViewManager );
void HYDROGUI_ImportImageOp::closeView( GraphicsView_ViewManager* &aViewMgr )
{
+ DEBTRACE("closeView");
if( aViewMgr )
{
GraphicsView_ViewPort* aViewPort = 0;
}
// Remove the appropriate presentation from the view
- if( aPrs && aViewPort )
+ if( aPrs )
{
- aViewPort->removeItem( aPrs );
+ if( aViewPort )
+ {
+ aViewPort->removeItem( aPrs );
+ }
delete aPrs;
}
void HYDROGUI_ImportImageOp::onFilesSelected( const QStringList& theFileNames )
{
+ DEBTRACE("onFilesSelected");
myFiles = theFileNames;
myFileIndex = -1;
SetNextFile();
bool HYDROGUI_ImportImageOp::SetNextFile()
{
+ DEBTRACE("SetNextFile");
myFileIndex++;
bool isEnabledEdit = myFiles.count()==1 || myFileIndex==myFiles.count();
bool isValid = ( myFileIndex>=0 && myFileIndex<myFiles.count() );