HYDROData_DTM.cxx
)
+SET( ECW_INCLUDES $ENV{ECWLIB_ROOT_DIR}/include )
+link_directories( $ENV{ECWLIB_ROOT_DIR}/lib )
+
+IF( ${WIN32} )
+ SET( ECW_LIBRARIES libecwj2 )
+ELSE()
+ SET( ECW_LIBRARIES libecwj2 )
+ENDIF()
+
add_definitions(
-DHYDRODATA_EXPORTS
${CAS_DEFINITIONS}
${KERNEL_INCLUDE_DIRS}
${GUI_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/../shapelib
+ ${ECW_INCLUDES}
)
add_library(HYDROData SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
+set_target_properties( HYDROData PROPERTIES LINK_INTERFACE_LIBRARIES "" )
target_link_libraries(HYDROData shapelib ${GEOM_GEOMUtils} ${CAS_OCAF} ${CAS_OCAFVIS} ${CAS_TKG3d} ${CAS_TKGeomBase} ${CAS_TKGeomAlgo}
${CAS_TKBrep} ${CAS_TKIGES} ${CAS_TKSTEP} ${CAS_TKTopAlgo} ${CAS_TKBO} ${CAS_TKBool} ${CAS_TKOffset} ${VTK_LIBRARIES}
- ${QT_LIBRARIES} ${GUI_ImageComposer} ${CAS_TKHLR} ${GEOM_GEOM} ${GEOM_GEOMBase} ${GEOM_CurveCreator} )
+ ${QT_LIBRARIES} ${GUI_ImageComposer} ${CAS_TKHLR} ${GEOM_GEOM} ${GEOM_GEOMBase} ${GEOM_CurveCreator} ${ECW_LIBRARIES} )
INSTALL(TARGETS HYDROData EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
set(PROJECT_LIBRARIES shapelib HYDROData)
#ifndef HYDROData_Entity_HeaderFile
#define HYDROData_Entity_HeaderFile
+#pragma comment(lib, "C:/libecw-master/lib/NCSUtild.lib")
+#pragma comment(lib, "C:/libecw-master/lib/NCSEcwd.lib")
+
#include "HYDROData.h"
#include <NCollection_Sequence.hxx>
#include <TDF_Label.hxx>
#include <QString>
#include <Standard_Type.hxx>
+
+#ifdef NONLS
+#undef NONLS
+#endif
+
+#ifdef NOMINMAX
+#undef NOMINMAX
+#endif
+
class QColor;
class QVariant;
class QStringList;
#include <TDataStd_UAttribute.hxx>
#include <TDataStd_AsciiString.hxx>
+#include <NCSDefs.h>
+#include <NCSFile.h>
+
#ifdef WIN32
#pragma warning ( disable: 4251 )
#endif
{
QImage anImage( theFilePath );
SetImage( anImage );
-
SetFilePath( theFilePath );
+ return !anImage.isNull(); //TODO open ecw from this func!
+}
+
+bool HYDROData_Image::OpenECW(char* theFileName, QImage& theImage, ECW_FileInfo* theECWInfo)
+{
+ NCSFileView *pNCSFileView;
+ NCSFileViewFileInfo *pNCSFileInfo;
+ NCSError eError = NCS_SUCCESS;
+ UINT32 band, nBands;
+ UINT32 XSize, YSize;
+ NCSecwInit();
+
+ eError = NCScbmOpenFileView(theFileName, &pNCSFileView, NULL);
+ if(eError != NCS_SUCCESS)
+ return false;
+
+ eError = NCScbmGetViewFileInfo(pNCSFileView, &pNCSFileInfo);
+ if(eError != NCS_SUCCESS)
+ return false;
+
+ XSize = pNCSFileInfo->nSizeX;
+ YSize = pNCSFileInfo->nSizeY;
+ nBands = pNCSFileInfo->nBands;
+ if (theECWInfo)
+ {
+ //ECW_CellUnits myCellSizeUnits;
+ CellSizeUnits aCellUnits = pNCSFileInfo->eCellSizeUnits;
+ if (aCellUnits == ECW_CELL_UNITS_METERS)
+ theECWInfo->myCellSizeUnits = ECW_CellUnits_Meters;
+ else if (aCellUnits == ECW_CELL_UNITS_DEGREES)
+ theECWInfo->myCellSizeUnits = ECW_CellUnits_Deg;
+ else if (aCellUnits == ECW_CELL_UNITS_FEET)
+ theECWInfo->myCellSizeUnits = ECW_CellUnits_Feet;
+ else
+ theECWInfo->myCellSizeUnits = ECW_CellUnits_Unknown;
+ theECWInfo->myCellIncrementX = pNCSFileInfo->fCellIncrementX;
+ theECWInfo->myCellIncrementY = pNCSFileInfo->fCellIncrementY;
+ theECWInfo->myOriginX = pNCSFileInfo->fOriginX;
+ theECWInfo->myOriginY = pNCSFileInfo->fOriginY;
+ theECWInfo->myXSize = pNCSFileInfo->nSizeX;
+ theECWInfo->myYSize = pNCSFileInfo->nSizeY;
+ }
+
+ std::vector<UINT32> band_list(nBands);
+ for( band = 0; band < nBands; band++ )
+ band_list[band] = band;
+
+ eError = NCScbmSetFileView(pNCSFileView, nBands, &band_list[0], 0, 0, XSize - 1, YSize - 1, XSize, YSize); //view an image into the original size
+
+ if(eError != NCS_SUCCESS)
+ {
+ NCScbmCloseFileView(pNCSFileView);
+ return false;
+ }
+
+ UINT8 *pRGBTriplets;
+ pRGBTriplets = (UINT8 *) malloc(XSize*3);
+
+ QImage anImage(XSize, YSize, QImage::Format_RGB32);
+ for(UINT32 line = 0; line < YSize; line++)
+ {
+ NCSEcwReadStatus eStatus;
+ eStatus = NCScbmReadViewLineRGB(pNCSFileView, pRGBTriplets);
+ if(eStatus == NCSECW_READ_OK)
+ {
+ QRgb* crp = (QRgb*)anImage.scanLine(line);
+ for(UINT32 j = 0; j < XSize; j++)
+ {
+ QRgb val = qRgb((int)pRGBTriplets[j*3],(int)pRGBTriplets[j*3+1],(int)pRGBTriplets[j*3+2]);
+ memcpy((void*)(crp+j), &val, sizeof(QRgb));
+ }
+ }
+ else
+ {
+ free(pRGBTriplets);
+ NCScbmCloseFileView(pNCSFileView);
+ return false;
+ }
+ }
+
+ free(pRGBTriplets);
+ NCScbmCloseFileView(pNCSFileView);
+ theImage = anImage;
+}
+
+bool HYDROData_Image::LoadImageECW( const QString& theFilePath )
+{
+ QImage anImage;
+ if (HYDROData_Image::OpenECW(theFilePath.toLatin1().data(), anImage, NULL))
+ {
+ SetImage( anImage );
+ SetFilePath( theFilePath );
+ }
return !anImage.isNull();
}
ReferenceImage
};
+ enum ECW_CellUnits
+ {
+ ECW_CellUnits_Meters = 1,
+ ECW_CellUnits_Deg = 2,
+ ECW_CellUnits_Feet = 3,
+ ECW_CellUnits_Unknown = -1
+ };
+
+ struct ECW_FileInfo
+ {
+ ECW_CellUnits myCellSizeUnits;
+ double myCellIncrementX;
+ double myCellIncrementY;
+ double myOriginX;
+ double myOriginY;
+ int myXSize;
+ int myYSize;
+ };
+
protected:
/**
* Enumeration of tags corresponding to the persistent object parameters.
*/
HYDRODATA_EXPORT bool LoadImage(const QString& theFilePath);
+ /**
+ * Load the ECW image from file
+ * \param theFilePath path to image
+ */
+ HYDRODATA_EXPORT bool LoadImageECW( const QString& theFilePath );
+
+
+ HYDRODATA_EXPORT static bool OpenECW(char* theFileName, QImage& theImage, ECW_FileInfo* theECWInfo);
+
/**
* Returns the kept image
*/
#include <NCollection_List.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
-static int aMaxNameId = std::numeric_limits<int>::max();
-
+static int aMaxNameId = INT_MAX;
void HYDROData_Tool::WriteStringsToFile( QFile& theFile,
const QStringList& theStrings,
const QString& theSep )
blockSignalsCartesian( false );
}
+void HYDROGUI_ImportImageDlg::ECW_initializePointSelection(HYDROData_Image::ECW_FileInfo* theECW_FileInfo)
+{
+ if( myIsInitialized )
+ return;
+
+ myIsInitialized = true;
+
+ myPointBtnMap[ HYDROGUI_PrsImage::PointA ]->setChecked( true );
+ myPointBtnMap[ HYDROGUI_PrsImage::PointB ]->setChecked( true );
+ myPointBtnMap[ HYDROGUI_PrsImage::PointC ]->setChecked( true );
+
+ setByTwoPoints(false);
+
+ HYDROData_Image::ECW_CellUnits Units = theECW_FileInfo->myCellSizeUnits;
+
+ if (Units == HYDROData_Image::ECW_CellUnits::ECW_CellUnits_Deg)
+ {
+ blockSignalsGeodesic( true );
+ double Xa, Ya, Xb, Yb, Xc, Yc;
+ Xa = theECW_FileInfo->myOriginX;
+ Ya = theECW_FileInfo->myOriginY;
+ Xb = theECW_FileInfo->myOriginX;
+ Yb = theECW_FileInfo->myOriginY + theECW_FileInfo->myCellIncrementY * theECW_FileInfo->myYSize;
+ Xc = theECW_FileInfo->myOriginX + theECW_FileInfo->myCellIncrementX * theECW_FileInfo->myXSize;
+ Yc = theECW_FileInfo->myOriginY;
+
+ int Deg = 0, Min = 0;
+ double Sec = 0.0;
+ //
+ HYDROData_Lambert93::degToDMS( Xa, Deg, Min, Sec );
+ myPointXDegMap[HYDROGUI_PrsImage::PointA]->setValue(Deg);
+ myPointXMinMap[HYDROGUI_PrsImage::PointA]->setValue(Min);
+ myPointXSecMap[HYDROGUI_PrsImage::PointA]->setValue(Sec);
+ HYDROData_Lambert93::degToDMS( Ya, Deg, Min, Sec );
+ myPointYDegMap[HYDROGUI_PrsImage::PointA]->setValue(Deg);
+ myPointYMinMap[HYDROGUI_PrsImage::PointA]->setValue(Min);
+ myPointYSecMap[HYDROGUI_PrsImage::PointA]->setValue(Sec);
+ //
+ HYDROData_Lambert93::degToDMS( Xb, Deg, Min, Sec );
+ myPointXDegMap[HYDROGUI_PrsImage::PointB]->setValue(Deg);
+ myPointXMinMap[HYDROGUI_PrsImage::PointB]->setValue(Min);
+ myPointXSecMap[HYDROGUI_PrsImage::PointB]->setValue(Sec);
+ HYDROData_Lambert93::degToDMS( Yb, Deg, Min, Sec );
+ myPointYDegMap[HYDROGUI_PrsImage::PointB]->setValue(Deg);
+ myPointYMinMap[HYDROGUI_PrsImage::PointB]->setValue(Min);
+ myPointYSecMap[HYDROGUI_PrsImage::PointB]->setValue(Sec);
+ //
+ HYDROData_Lambert93::degToDMS( Xc, Deg, Min, Sec );
+ myPointXDegMap[HYDROGUI_PrsImage::PointC]->setValue(Deg);
+ myPointXMinMap[HYDROGUI_PrsImage::PointC]->setValue(Min);
+ myPointXSecMap[HYDROGUI_PrsImage::PointC]->setValue(Sec);
+ HYDROData_Lambert93::degToDMS( Yc, Deg, Min, Sec );
+ myPointYDegMap[HYDROGUI_PrsImage::PointC]->setValue(Deg);
+ myPointYMinMap[HYDROGUI_PrsImage::PointC]->setValue(Min);
+ myPointYSecMap[HYDROGUI_PrsImage::PointC]->setValue(Sec);
+ //
+ for( int aPointType = HYDROGUI_PrsImage::PointA; aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
+ onGeodesicCoordChanged( aPointType );
+ blockSignalsGeodesic( false );
+ setTransformationMode( HYDROData_Image::ManualGeodesic );
+ }
+ if (Units == HYDROData_Image::ECW_CellUnits::ECW_CellUnits_Meters ||
+ Units == HYDROData_Image::ECW_CellUnits::ECW_CellUnits_Feet )
+ {
+ double Coeff = 1;
+ if (Units == HYDROData_Image::ECW_CellUnits::ECW_CellUnits_Feet)
+ Coeff = 0.3048; //feets
+ blockSignalsCartesian( true );
+ double X1 = 0, Y1 = 0, X2 = 0, Y2 = 0, X3 = 0, Y3 = 0;
+ X1 = theECW_FileInfo->myOriginX;
+ Y1 = theECW_FileInfo->myOriginY;
+ X2 = theECW_FileInfo->myOriginX;
+ Y2 = theECW_FileInfo->myOriginY + Coeff * theECW_FileInfo->myCellIncrementY * theECW_FileInfo->myXSize;
+ X3 = theECW_FileInfo->myOriginX + Coeff * theECW_FileInfo->myCellIncrementX * theECW_FileInfo->myYSize;
+ Y3 = theECW_FileInfo->myOriginY;
+
+ //extract to A-point (top-left), B-point (bottom-left), C-Point (top-right)
+ double Xa = 0, Ya = 0, Xb = 0, Yb = 0, Xc = 0, Yc = 0;
+ Xa = Min(X1, Min(X2, X3));
+ Ya = Max(Y1, Max(Y2, Y3));
+ Xb = Max(X1, Max(X2, X3));
+ Yb = Ya;
+ Xc = Xa;
+ Yc = Min(Y1, Min(Y2, Y3));
+
+ myCartPointXMap[HYDROGUI_PrsImage::PointA]->setValue(Xa);
+ myCartPointYMap[HYDROGUI_PrsImage::PointA]->setValue(Ya);
+ //
+ myCartPointXMap[HYDROGUI_PrsImage::PointB]->setValue(Xb);
+ myCartPointYMap[HYDROGUI_PrsImage::PointB]->setValue(Yb);
+ //
+ myCartPointXMap[HYDROGUI_PrsImage::PointC]->setValue(Xc);
+ myCartPointYMap[HYDROGUI_PrsImage::PointC]->setValue(Yc);
+ //
+ for( int aPointType = HYDROGUI_PrsImage::PointA; aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
+ onCartesianCoordChanged( aPointType );
+ blockSignalsCartesian( false );
+ setTransformationMode( HYDROData_Image::ManualCartesian );
+ }
+}
+
+
HYDROGUI_ImportImageDlg::TransformationData HYDROGUI_ImportImageDlg::ComputeTrsfData(
const int theMode,
const QPoint& theLocalPoint,
if( !theFileName.isEmpty() )
{
- QImage anImage( theFileName );
+ QFileInfo aFI( theFileName );
+ QImage anImage;
+ HYDROData_Image::ECW_FileInfo* theECWInfo = NULL;
+ if (aFI.completeSuffix().toLower() == "ecw")
+ {
+ theECWInfo = new HYDROData_Image::ECW_FileInfo;
+ HYDROData_Image::OpenECW(theFileName.toLatin1().data(), anImage, theECWInfo);
+ }
+ else
+ anImage = QImage(theFileName);
if( anImage.isNull() )
{
QString aTitle = QObject::tr( "INPUT_VALID_DATA" );
{
setFileName( theFileName );
setImageName( "" );
- emit createPreview( anImage );
+ emit createPreview( anImage, theECWInfo );
}
}
}
#define HYDROGUI_IMPORTIMAGEDLG_H
#include "HYDROGUI_InputPanel.h"
+#include <HYDROData_Image.h>
#include <QMap>
void initializePointSelection();
+
+ void ECW_initializePointSelection(HYDROData_Image::ECW_FileInfo* theECW_FileInfo);
+
+
void ActivateFile( const QString& theFileName, bool isEnableFilesChoice );
public:
bool blockSignalsCartesian( const bool theState );
signals:
- void createPreview( QImage );
+ void createPreview( QImage, HYDROData_Image::ECW_FileInfo* );
void activatePointSelection( int );
void pointCoordChanged( bool theIsRef,
int thePointType,
myEditedObject->GetLocalPoints( aLocalPointA, aLocalPointB, aLocalPointC );
// Create the edited image preview presentation in the viewer
- onCreatePreview( anImage );
+ onCreatePreview( anImage, NULL ); //TODO
// Set transformation local points A,B,C to the image preview presentation
setPresentationTrsfPoints( myPreviewPrs, anIsByTwoPoints, aLocalPointA,
HYDROGUI_InputPanel* HYDROGUI_ImportImageOp::createInputPanel() const
{
HYDROGUI_InputPanel* aPanel = new HYDROGUI_ImportImageDlg( module(), getName() );
- connect( aPanel, SIGNAL( createPreview( QImage ) ), SLOT( onCreatePreview( QImage ) ) );
+ connect( aPanel, SIGNAL( createPreview( QImage, HYDROData_Image::ECW_FileInfo* ) ),
+ SLOT( onCreatePreview( QImage, HYDROData_Image::ECW_FileInfo* ) ) );
connect( aPanel, SIGNAL( activatePointSelection( int ) ), SLOT( onActivatePointSelection( int ) ) );
connect( aPanel, SIGNAL( pointCoordChanged( bool, int, bool, int ) ),
SLOT( onPointCoordChanged( bool, int, bool, int ) ) );
}
}
-void HYDROGUI_ImportImageOp::onCreatePreview( QImage theImage )
+void HYDROGUI_ImportImageOp::onCreatePreview( QImage theImage, HYDROData_Image::ECW_FileInfo* theFileInfo )
{
HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel();
aPanel->setImageSize( myImage.size() );
- aPanel->initializePointSelection();
+ if (!theFileInfo)
+ aPanel->initializePointSelection();
+ else
+ aPanel->ECW_initializePointSelection(theFileInfo);
onPointSelected( false );
onSetCIsUsed( !aPanel->isByTwoPoints() );
}
virtual void apply();
protected slots:
- void onCreatePreview( QImage );
+ void onCreatePreview( QImage, HYDROData_Image::ECW_FileInfo* );
void onActivatePointSelection( int );
void onPointCoordChanged( bool, int, bool, int );
void onModeActivated( int );
</message>
<message>
<source>IMAGE_FILTER</source>
- <translation>Image files (*.bmp *.jpg *.jpeg *.png *.tif);;All files (*.* *)</translation>
+ <translation>Image files (*.bmp *.jpg *.jpeg *.png *.tif *.ecw);;All files (*.* *)</translation>
</message>
<message>
<source>INCORRECT_OBJECT_NAME</source>
# sources / to compile
ADD_LIBRARY( HYDROPy ${_sip_SOURCES} ${_add_SOURCES} )
-TARGET_LINK_LIBRARIES(HYDROPy ${_link_LIBRARIES})
+TARGET_LINK_LIBRARIES(HYDROPy ${_link_LIBRARIES} ${CAS_OCAF} ${CAS_TKKernel} ${CAS_TKBRep} ${QT_LIBRARIES} ${OMNIORB_LIBRARIES} ${GEOM_GEOM} ${GEOM_GEOMBase})
INSTALL(TARGETS HYDROPy EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
IF(WIN32)
SET( KERNEL_INCLUDES $ENV{KERNEL_ROOT_DIR}/include/salome )
SET( GUI_INCLUDES $ENV{GUI_ROOT_DIR}/include/salome )
SET( GEOM_INCLUDES $ENV{GEOM_ROOT_DIR}/include/salome )
+SET( ECW_INCLUDES $ENV{ECWLIB_ROOT_DIR}/include )
IF( ${WIN32} )
link_directories( $ENV{CASROOT}/win64/vc10/lib )
SET( GUI_LIBRARIES ImageComposer qtx suit LightApp CAM OCCViewer )
SET( GEOM_LIBRARIES CurveCreator GEOMUtils GEOMUtils )
+link_directories( $ENV{ECWLIB_ROOT_DIR}/lib )
+IF( ${WIN32} )
+ SET( ECW_LIBRARIES libecwj2 )
+ELSE()
+ SET( ECW_LIBRARIES libecwj2 )
+ENDIF()
+
include_directories(
${CAS_INCLUDES}
${QT_INCLUDES}
${CMAKE_CURRENT_SOURCE_DIR}/../HYDROData
${CMAKE_CURRENT_SOURCE_DIR}/../HYDROGUI
${CMAKE_CURRENT_SOURCE_DIR}/../shapelib
+ ${ECW_INCLUDES}
)
source_group( "External files" FILES ${EXTERNAL_FILES} )
add_executable( HYDROData_tests ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${EXTERNAL_FILES} ${PROJECT_MOC_HEADERS} )
-target_link_libraries( HYDROData_tests ${GUI_LIBRARIES} ${GEOM_LIBRARIES} ${CAS_LIBRARIES} ${QT_LIBRARIES} ${CPPUNIT_LIBRARIES} shapelib HYDROData )
+target_link_libraries( HYDROData_tests ${GUI_LIBRARIES} ${GEOM_LIBRARIES} ${CAS_LIBRARIES} ${QT_LIBRARIES} ${CPPUNIT_LIBRARIES} shapelib HYDROData ${ECW_LIBRARIES} )
INSTALL(TARGETS HYDROData_tests EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_BINS})