]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp
*** empty log message ***
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / manualPaint / ManualPaintModel.cpp
index a9a84e0b074fb23248bd587d133f58e635732beb..d6b0d5ba1f2eb8b6e004e261a56147df45330240 100644 (file)
@@ -4,8 +4,11 @@
 
 ManualPaintModel::ManualPaintModel()
 {
-    _graylevel=0.0;
-    _brushsize=1;
+    _graylevel  =   0.0;
+    _brushsize  =   1;
+    _brushform  =   0;      // 0 rectangle-box  ,   1 circle-sphere
+    _2D3D       =   0;      // 0 2D             ,   1 true 3D
+    _brushtool  =   0;      // 0 pensil         ,   1 fill
 }
 
 //---------------------------------------------------------------------------
@@ -20,6 +23,8 @@ void ManualPaintModel::SetImage(vtkImageData *image)
 
 void ManualPaintModel::PaintImage(int px,int py, int pz)
 {
+
+    printf("EED ManualPaintModel::PaintImage %d %d %d\n", px,py,pz);
     if (_image!=NULL)
     {
         float value=(float)_graylevel;
@@ -32,37 +37,69 @@ void ManualPaintModel::PaintImage(int px,int py, int pz)
         int minZ=pz-size;
         int maxZ=pz+size;
 
+        double xx,yy,zz,rr=size*size;
+
+        printf("EED bbcreaMaracasvisu::vtkInteractorManualPaint::PaintImage brushForm=%d\n",_brushform);
         for (i=minX; i<=maxX; i++)
         {
+            xx=px-i;
+            xx=xx*xx;
             for (j=minY; j<=maxY; j++)
             {
+                yy=py-j;
+                yy=yy*yy;
                 for (k=minZ; k<=maxZ; k++)
                 {
-                    _image->SetScalarComponentFromFloat (i,j,k, 0, value );
-                }
-            }
-        }
+                    zz=pz-k;
+                    zz=zz*zz;
+                    if (_brushform==0)
+                    {
+                        _image->SetScalarComponentFromFloat (i,j,k, 0, value );
+                    } else if (_brushform==1)
+                    {
+                        if ((xx+yy+zz)<=rr)
+                        {
+                            _image->SetScalarComponentFromFloat (i,j,k, 0, value );
+                        }
+                    } // _brushform
+
+                }//k
+            }//j
+        }//i
         _image->Modified();
-        _image->UpdateInformation();
-        _image->Update();
-        _image->UpdateData();
     } else  {
         printf("ERROR : bbcreaMaracasvisu::vtkInteractorManualPaint::PaintImage :  Image not set. \n");
-    }
+    } // _image
 }
 
 
 //---------------------------------------------------------------------------
 void ManualPaintModel::SetBrushSize( int brushsize )
 {
-    printf("EED %p ManualPaintModel::SetBrushSize \n", this);
     _brushsize = brushsize;
 }
 
 //---------------------------------------------------------------------------
 void ManualPaintModel::SetGrayLevel( double graylevel )
 {
-    printf("EED %p ManualPaintModel::SetGrayLevel \n", this);
     _graylevel = graylevel;
 }
 
+//---------------------------------------------------------------------------
+void ManualPaintModel::SetBrushForm( int brushform )
+{
+    _brushform = brushform;
+}
+
+//---------------------------------------------------------------------------
+void ManualPaintModel::SetBrushTool( int brushtool )
+{
+    _brushtool = brushtool;
+}
+
+//---------------------------------------------------------------------------
+void ManualPaintModel::Set2D3D( int dim2D3D )
+{
+    _2D3D = dim2D3D;
+}
+