]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
rnc : Finished a first demo prototype
authorgdd <gdd>
Fri, 7 Oct 2011 09:56:54 +0000 (09:56 +0000)
committergdd <gdd>
Fri, 7 Oct 2011 09:56:54 +0000 (09:56 +0000)
A textured shape can now be selected in the FeatureDetection dialog and the associated texture is used to detect contours and corners.

resources/GEOM_en.xml
src/EntityGUI/EntityGUI_FeatureDetectorDlg.cxx
src/EntityGUI/EntityGUI_FeatureDetectorDlg.h

index d664cfd5b947f7b2b036be079469e9b72f74e342..033ccbd860ab1bf0ee6defc331b1cd1cdb4ba41a 100644 (file)
    <submenu label-id="Display Mode" item-id="803" pos-id="6">
       <popup-item item-id="80311" pos-id="" label-id="Wireframe" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
       <popup-item item-id="80312" pos-id="" label-id="Shading" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+      <popup-item item-id="80312" pos-id="" label-id="Texture" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
    </submenu>
    <endsubmenu />
    <popup-item item-id="8032" pos-id="" label-id="Color" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
index a499cf8d612dedba842bb0c41981152dbabc385b..bf9346bcb843e4e2a3e68f0210a9e8b2185bc7ea 100644 (file)
@@ -32,6 +32,8 @@
 #include <OCCViewer_FeatureDetector.h>
 #include <OCCViewer_ViewManager.h>
 
+#include <SOCC_ViewModel.h>
+
 #include <DlgRef.h>
 #include <GeometryGUI.h>
 #include <EntityGUI.h>
@@ -46,6 +48,8 @@
 #include <LightApp_Application.h>
 #include <LightApp_SelectionMgr.h>
 
+#include <SALOME_ListIteratorOfListIO.hxx>
+
 #include <SalomeApp_Study.h>
 
 #include <utilities.h>
@@ -357,6 +361,12 @@ void EntityGUI_FeatureDetectorDlg::SelectionIntoArgument()
   LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
   SALOME_ListIO aSelList;
   aSelMgr->selectedObjects(aSelList);
+  SALOME_ListIteratorOfListIO anIt( aSelList );
+  for( ; anIt.More(); anIt.Next() )
+    if( !anIt.Value().IsNull() )
+    {
+      myFaceEntry = anIt.Value()->getEntry();
+    }
 
   if (aSelList.Extent() != 1) {
     if (myEditCurrentArgument == myLineEdit) 
@@ -558,7 +568,27 @@ bool EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects )
   bool res = false;
   SUIT_ViewWindow*       theViewWindow  = getDesktop()->activeWindow();
   OCCViewer_ViewPort3d*  vp             = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
-  QString                theImgFileName = vp->backgroundImageFilename();
+//   QString                theImgFileName = vp->backgroundImageFilename();
+  
+  MESSAGE("myFaceEntry = "<< myFaceEntry.toStdString());
+  std::map< std::string , std::vector<Handle(AIS_InteractiveObject)> >::iterator AISit;
+  SOCC_Viewer* soccViewer = (SOCC_Viewer*)(theViewWindow->getViewManager()->getViewModel());
+  
+  MESSAGE("repere1")
+  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;
+  
+  QString theImgFileName = QString::fromStdString( myAISShape->TextureFile() );
+   
   
   if ( theImgFileName.isEmpty() )
     return res;
@@ -637,9 +667,9 @@ bool EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects )
 //         double z = aCornerPnt.Z();
 
         // When using the new way with textures on shapes we just have to do the following
-        double x = corners[i].x;
-        double y = height - corners[i].y;
-        double z = 0;
+        double x = -0.5*width  + corners[i].x;
+        double y =  0.5*height - corners[i].y;
+        double z =  0;
         
         aGeomCorner = aBasicOperations->MakePointXYZ( x,y,z );
         
@@ -708,8 +738,8 @@ bool EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects )
 //         if (pnt_it.second == true)
 //         {
 //           MESSAGE("point absent du contour insere")
-        double x = it->x;
-        double y = height - it->y;
+        double x = -0.5*width  + it->x;
+        double y = 0.5 *height - it->y;
         double z = 0;
         aGeomContourPnt    = aBasicOperations->MakePointXYZ( x,y,z );
         geomContourPnts[j] = aGeomContourPnt;
index b9c371a5aa4474eb09aa95c0d7af3ffee5ef054e..949d237f162852987d81cd06dd4ee43f2c757823 100644 (file)
@@ -71,6 +71,7 @@ private slots:
   
 private:
   GEOM::GeomObjPtr                   myFace;
+  QString                            myFaceEntry;
   
   int                                myConstructorId;