]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
rnc : previous work ...
authorgdd <gdd>
Tue, 13 Sep 2011 13:01:59 +0000 (13:01 +0000)
committergdd <gdd>
Tue, 13 Sep 2011 13:01:59 +0000 (13:01 +0000)
src/OCCViewer/Makefile.am
src/OCCViewer/OCCViewer_ViewModel.cxx
src/OCCViewer/OCCViewer_ViewPort3d.cxx
src/OCCViewer/OCCViewer_ViewPort3d.h
src/OCCViewer/OCCViewer_ViewWindow.cxx

index fb30817446bd610cfe9e71bb88611ff5a5488cfa..beaa3834cacc0fd0c76a8214ffde3663cac2e914 100755 (executable)
@@ -23,6 +23,7 @@
 #  Author : Vladimir Klyachin (OCN)
 #  Module : OCCViewer
 #  $Header$
+#
 
 include $(top_srcdir)/adm_local/unix/make_common_starter.am
 
@@ -46,7 +47,8 @@ salomeinclude_HEADERS =                               \
        OCCViewer_FontWidget.h                  \
        OCCViewer_CubeAxesDlg.h                 \
        OCCViewer_ToolTip.h                     \
-       OCCViewer_ViewFrame.h
+       OCCViewer_ViewFrame.h                   \
+       OCCViewer_FeatureDetector.h
 
 dist_libOCCViewer_la_SOURCES =                 \
        OCCViewer_AISSelector.cxx               \
@@ -65,7 +67,8 @@ dist_libOCCViewer_la_SOURCES =                        \
        OCCViewer_FontWidget.cxx                \
        OCCViewer_CubeAxesDlg.cxx               \
        OCCViewer_ToolTip.cxx                   \
-       OCCViewer_ViewFrame.cxx
+       OCCViewer_ViewFrame.cxx                 \
+        OCCViewer_FeatureDetector.cxx
 
 MOC_FILES =                                    \
        OCCViewer_AISSelector_moc.cxx           \
@@ -125,8 +128,11 @@ nodist_salomeres_DATA =            \
 
 libOCCViewer_la_CPPFLAGS = $(QT_INCLUDES) $(OGL_INCLUDES) $(CAS_CPPFLAGS) @KERNEL_CXXFLAGS@ \
        -I$(srcdir)/../SUIT -I$(srcdir)/../ViewerTools -I$(srcdir)/../Qtx \
-       -I$(srcdir)/../OpenGLUtils -I$(srcdir)/../CASCatch
+       -I$(srcdir)/../OpenGLUtils -I$(srcdir)/../CASCatch              \
+       -I/home/palmco/OpenCV/OpenCV-2.3.0/install/include/opencv \
+       -I/home/palmco/OpenCV/OpenCV-2.3.0/install/include
 
-libOCCViewer_la_LDFLAGS  = $(OGL_LIBS) $(QT_MT_LIBS) $(CAS_KERNEL) $(CAS_VIEWER)
+libOCCViewer_la_LDFLAGS  = $(OGL_LIBS) $(QT_MT_LIBS) $(CAS_KERNEL) $(CAS_VIEWER) \
+       -L/home/palmco/OpenCV/OpenCV-2.3.0/install/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann  
 libOCCViewer_la_LIBADD   = ../Qtx/libqtx.la ../SUIT/libsuit.la \
        ../ViewerTools/libViewerTools.la ../OpenGLUtils/libOpenGLUtils.la
index 35c81ac3f2f6e6649faecd543d93aa6891ae2407..8bdb3b0d6192e571c86b18f8e8e4ee808c0126b0 100755 (executable)
@@ -18,6 +18,7 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 
 #include "OCCViewer_ViewModel.h"
 #include "OCCViewer_ViewWindow.h"
@@ -56,6 +57,8 @@
 #include <Prs3d_AngleAspect.hxx>
 #include <Prs3d_TextAspect.hxx>
 
+#include "utilities.h"
+
 /*!
   Constructor
   \param DisplayTrihedron - is trihedron displayed
@@ -215,6 +218,7 @@ void OCCViewer_Viewer::onMousePress(SUIT_ViewWindow* theWindow, QMouseEvent* the
 */
 void OCCViewer_Viewer::onMouseMove(SUIT_ViewWindow* theWindow, QMouseEvent* theEvent)
 {
+//   MESSAGE("OCCViewer_Viewer::onMouseMove")
   if (!mySelectionEnabled) return;
   if (!theWindow->inherits("OCCViewer_ViewWindow")) return;
 
@@ -240,6 +244,7 @@ void OCCViewer_Viewer::onMouseMove(SUIT_ViewWindow* theWindow, QMouseEvent* theE
 */
 void OCCViewer_Viewer::onMouseRelease(SUIT_ViewWindow* theWindow, QMouseEvent* theEvent)
 {
+  MESSAGE("OCCViewer_Viewer::onMouseRelease")
   if (!mySelectionEnabled) return;
   if (theEvent->button() != Qt::LeftButton) return;
   if (!theWindow->inherits("OCCViewer_ViewWindow")) return;
@@ -461,9 +466,10 @@ void OCCViewer_Viewer::onChangeBgImageCentered()
   if ( !aView )
     return;
   
-  QString selFile = QFileDialog::getOpenFileName(aView,tr( "SELECT_IMAGE"),aView->backgroundImageFilename(), tr("OCC_BG_IMAGE_FILES"));
-  if ( ! selFile.isEmpty() )
+  QString selFile = QFileDialog::getOpenFileName(aView,tr( "SELECT_IMAGE"),aView->backgroundImageFilename(), tr("OCC_IMAGE_FILES"));
+  if ( ! selFile.isEmpty() ){
     aView->setBackgroundImage(selFile,Aspect_FM_CENTERED);
+  }
 }
 
 /*!
@@ -475,7 +481,7 @@ void OCCViewer_Viewer::onChangeBgImageTiled()
   if ( !aView )
     return;
   
-  QString selFile = QFileDialog::getOpenFileName(aView,tr( "SELECT_IMAGE"),aView->backgroundImageFilename(), tr("OCC_BG_IMAGE_FILES"));
+  QString selFile = QFileDialog::getOpenFileName(aView,tr( "SELECT_IMAGE"),aView->backgroundImageFilename(), tr("OCC_IMAGE_FILES"));
   if ( ! selFile.isEmpty() )
     aView->setBackgroundImage(selFile,Aspect_FM_TILED);
 }
@@ -489,9 +495,9 @@ void OCCViewer_Viewer::onChangeBgImageStretched()
   if ( !aView )
     return;
   
-  QString selFile = QFileDialog::getOpenFileName(aView,tr( "SELECT_IMAGE"),aView->backgroundImageFilename(), tr("OCC_BG_IMAGE_FILES"));
+  QString selFile = QFileDialog::getOpenFileName(aView,tr( "SELECT_IMAGE"),aView->backgroundImageFilename(), tr("OCC_IMAGE_FILES"));
   if ( ! selFile.isEmpty() )
-    aView->setBackgroundImage(selFile,Aspect_FM_STRETCH);
+    aView->setBackgroundImage(selFile,Aspect_FM_STRETCH_NODEF);
 }
 /*!
   Updates OCC 3D viewer
index 06801b37a18d409e5745c23284dd5be89c875030..f6ebec16f1755c81a54e417f9d08bc0ce2a931c1 100755 (executable)
@@ -28,6 +28,7 @@
 #include <Basics_OCCTVersion.hxx>
 
 #include <SUIT_ViewManager.h>
+#include <SUIT_ViewModel.h>
 
 #include <QColor>
 #include <QString>
 #include <V3d_PerspectiveView.hxx>
 #include <V3d_OrthographicView.hxx>
 
+#include <InterfaceGraphic_Visual3d.hxx>
+#include <OpenGl_cmn_varargs.h>
+#include <OpenGl_tsm_ws.h>
+
+#include "utilities.h"
+
 #if defined WNT
 #include <WNT_Window.hxx>
 #else
@@ -299,9 +306,41 @@ QString OCCViewer_ViewPort3d::backgroundImageFilename() const
 void OCCViewer_ViewPort3d::setBackgroundImage( const QString& fileName,const Aspect_FillMethod& theFillMethod)
 { 
   myBackgroundImageFilename=fileName;
-  if ( !activeView().IsNull() ) {
-    activeView()->SetBackgroundImage( (Standard_CString)fileName.toLatin1().constData(),theFillMethod,true);
-  }
+  //TEST
+//   if ( !activeView().IsNull() ) {
+//     activeView()->SetBackgroundImage( (Standard_CString)fileName.toLatin1().constData(),theFillMethod,true);
+    
+//     //TEST
+//     SUIT_ViewWindow*       theViewWindow    = getDesktop()->activeWindow();
+//   OCCViewer_Viewer*      anOCCViewer      = ( (OCCViewer_ViewManager*)( theViewWindow->getViewManager() ) )->getOCCViewer();
+//   QString                theImgFileName   = backgroundImageFilename();
+//   Handle(AIS_InteractiveContext) aContext = anOCCViewer->getAISContext(); 
+//   
+//   gp_Pnt p1(0,0,0);
+//   gp_Pnt p2(0,100,0);
+//   gp_Pnt p3(100,100,0);
+//   gp_Pnt p4(100,0,0);
+//   
+//   BRepBuilderAPI_MakePolygon Wire(p1,p2,p3,p4, Standard_True); 
+//   BRepBuilderAPI_MakeFace Face(Wire,Standard_True);
+//   const TopoDS_Shape& S = Face.Shape();
+//   Handle(AIS_TexturedShape) anAIS = new AIS_TexturedShape(S);
+//   if (!theImgFileName.isEmpty())
+//   {
+//     MESSAGE("filename is not empty")
+//     anAIS->SetTextureFileName(TCollection_AsciiString(theImgFileName.toStdString().c_str()));
+//     anAIS->SetTextureMapOn();
+//     activeView()->SetSurfaceDetail(V3d_TEX_ALL);
+// //     anAIS->SetDisplayMode(AIS_Shaded); 
+//   }
+//   else
+//     anAIS->SetTextureMapOff();
+//   //creation of the presentable object
+//   aContext->SetDisplayMode(anAIS,3);
+//   aContext->SetMaterial(anAIS,Graphic3d_NOM_SATIN);
+//   aContext->Display(anAIS);
+//   aContext->UpdateCurrentViewer();
+//   }
 }
 
 /*!
index 7eccb6c43cd396ca5ca3bc281c08868fb41dab0a..72fc74de2ae6142a308950868a3232e1f8143e1f 100755 (executable)
@@ -59,6 +59,9 @@ public:
 
   virtual QString       backgroundImageFilename() const;
   virtual void          setBackgroundImage( const QString& fileName , const Aspect_FillMethod& theFillMethod);
+  
+  virtual int           getBgImgHeight(){return myBgImgHeight; };
+  virtual int           getBgImgWidth() {return myBgImgWidth;  };
 
 //   void         setActive( V3d_TypeOfView );
   virtual bool syncronize( const OCCViewer_ViewPort3d* );
@@ -111,6 +114,8 @@ private:
   double                myScale;
   bool                  myIsAdvancedZoomingEnabled;
   QString               myBackgroundImageFilename;
+  int                   myBgImgHeight;
+  int                   myBgImgWidth;
 };
 
 #ifdef WIN32
index 2388b95dedd91d2ed67adef337b0de9f555313a8..c5e8d1833d321c78b8ce1e180ef6d456e165c738 100755 (executable)
 #include <AIS_ListOfInteractive.hxx>
 #include <AIS_ListIteratorOfListOfInteractive.hxx>
 #include <AIS_Shape.hxx>
+#include <AIS_TexturedShape.hxx>
+
+#include <BRepBuilderAPI_MakeVertex.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
+#include <BRepBuilderAPI_MakePolygon.hxx>
+#include <BRepBuilderAPI_Transform.hxx>
+
+#include <TCollection_AsciiString.hxx>
+#include <Graphic3d_MaterialAspect.hxx>
 
 #include <BRep_Tool.hxx>
 #include <BRepBndLib.hxx>
 #include <TopoDS.hxx>
+#include <TopoDS_Wire.hxx>
 
 #include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
 #include <Graphic3d_MapOfStructure.hxx>
 
 #include <Standard_Version.hxx>
 
+#include "utilities.h"
+
+// OpenCV includes
+#include <cv.h>
+#include <highgui.h>
+
 static QEvent* l_mbPressEvent = 0;
 
 #ifdef WIN32
@@ -820,6 +836,7 @@ void OCCViewer_ViewWindow::vpMouseMoveEvent( QMouseEvent* theEvent )
             myViewPort->setCursor( handCursor );
           }
         }
+        emit mouseMoving( this, theEvent );
       }
       else if ( anInteractionStyle == SUIT_ViewModel::STANDARD && 
                 aButton == Qt::RightButton && ( aState == Qt::NoModifier || Qt::ShiftModifier ) ) {
@@ -2248,6 +2265,7 @@ void OCCViewer_ViewWindow::onSketchingStarted()
 */
 void OCCViewer_ViewWindow::onSketchingFinished()
 {
+  MESSAGE("OCCViewer_ViewWindow::onSketchingFinished()")
   if ( mypSketcher && mypSketcher->result() == OCCViewer_ViewSketcher::Accept )
   {
     Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
@@ -2263,6 +2281,7 @@ void OCCViewer_ViewWindow::onSketchingFinished()
           int aRight = aRect->right();
           int aTop = aRect->top();
           int aBottom = aRect->bottom();
+//           myRect = aRect;
 
           if( append )
             ic->ShiftSelect( aLeft, aBottom, aRight, aTop, getViewPort()->getView(), Standard_False );
@@ -2398,7 +2417,48 @@ QString OCCViewer_ViewWindow::backgroundImageFilename() const
    
 void OCCViewer_ViewWindow::setBackgroundImage( const QString& theFileName,const Aspect_FillMethod& theFillMethod)
 {
-  if ( myViewPort ) myViewPort->setBackgroundImage( theFileName ,theFillMethod);
+  if ( myViewPort ) 
+  {
+    myViewPort->setBackgroundImage( theFileName ,theFillMethod);
+  //     set2dMode(XYPlane);
+  //     onTopView();
+      //TEST
+    OCCViewer_Viewer*           anOCCViewer = ((OCCViewer_ViewManager*)getViewManager())->getOCCViewer();
+  //   QString                theImgFileName   = backgroundImageFilename();
+    Handle(AIS_InteractiveContext) aContext = anOCCViewer->getAISContext(); 
+    
+    IplImage* img = cvLoadImage( theFileName.toStdString().c_str(),CV_LOAD_IMAGE_GRAYSCALE);
+    int height = img->height;
+    int width  = img->width;
+    
+    gp_Pnt p1(0,0,0);
+    gp_Pnt p2(0,height,0);
+    gp_Pnt p3(width,height,0);
+    gp_Pnt p4(width,0,0);
+    
+    BRepBuilderAPI_MakePolygon Wire(p1,p2,p3,p4, Standard_True); 
+    BRepBuilderAPI_MakeFace Face(Wire,Standard_True);
+    const TopoDS_Shape& S = Face.Shape();
+    Handle(AIS_TexturedShape) anAIS = new AIS_TexturedShape(S);
+    if (!theFileName.isEmpty())
+    {
+      MESSAGE("filename is not empty")
+      anAIS->SetTextureFileName(TCollection_AsciiString(theFileName.toStdString().c_str()));
+      anAIS->SetTextureMapOn();
+      anAIS->DisableTextureModulate();
+      myViewPort->getView()->SetSurfaceDetail(V3d_TEX_ALL);
+  //     anAIS->SetDisplayMode(AIS_Shaded); 
+    }
+    else
+      anAIS->SetTextureMapOff();
+    //creation of the presentable object
+    aContext->SetDisplayMode(anAIS,3);
+    aContext->SetMaterial(anAIS,Graphic3d_NOM_SATIN);
+    aContext->Display(anAIS);
+    onTopView();
+    aContext->UpdateCurrentViewer();
+    
+  }
 }
 
 /*!