From 259055020c95a7189e2421c5034c90e22f1368e0 Mon Sep 17 00:00:00 2001
From: Cyrille Valladeau <cyrille.valladeau@c-s.fr>
Date: Fri, 16 Oct 2009 10:30:33 +0200
Subject: [PATCH] ENH : change circle center representation solution

---
 Code/Visualization/otbCircleGlComponent.cxx | 15 ++++++++++++++-
 Code/Visualization/otbCircleGlComponent.h   |  9 +++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/Code/Visualization/otbCircleGlComponent.cxx b/Code/Visualization/otbCircleGlComponent.cxx
index 822934029a..32deb34895 100644
--- a/Code/Visualization/otbCircleGlComponent.cxx
+++ b/Code/Visualization/otbCircleGlComponent.cxx
@@ -36,6 +36,8 @@ CircleGlComponent
   m_Radius = 10;
   // Create the tesselator
   m_GluTesselator = gluNewTess(); 
+  // Center representation
+  m_CenterRepresentation = CROSS;
 }
 
 CircleGlComponent
@@ -113,7 +115,7 @@ CircleGlComponent
 
   // Draw the center
   //glColor4d(m_ColorList[id][0],m_ColorList[id][1],m_ColorList[id][2],1)
-  if(m_Radius>4)
+  if( m_CenterRepresentation == CIRCLE && m_Radius>4 )
     {
       glColor4d(0, 0, 0, 1);
       glEnable(GL_BLEND);
@@ -122,6 +124,17 @@ CircleGlComponent
       glVertex2d(screenPoint[0],screenPoint[1]);
       glEnd();
     }
+  else if( m_CenterRepresentation == CROSS )
+    {
+      glColor4d(0, 0, 0, 1);
+      glBegin(GL_LINES);
+      // Draw a cross
+      glVertex2d(screenPoint[0]-m_Radius,screenPoint[1]);
+      glVertex2d(screenPoint[0]+m_Radius,screenPoint[1]);
+      glVertex2d(screenPoint[0],screenPoint[1]-m_Radius);
+      glVertex2d(screenPoint[0],screenPoint[1]+m_Radius);
+      glEnd();
+    }
 }
 
 }
diff --git a/Code/Visualization/otbCircleGlComponent.h b/Code/Visualization/otbCircleGlComponent.h
index 4c2ded1e77..199ffe2422 100644
--- a/Code/Visualization/otbCircleGlComponent.h
+++ b/Code/Visualization/otbCircleGlComponent.h
@@ -69,6 +69,8 @@ public:
   typedef std::vector<IndexType> IndexListType;
   typedef std::vector<ColorType> ColorListType;
 
+  typedef enum { CIRCLE, CROSS } CenterRepresentationEnumType;
+
   /** Runtime information */
   itkTypeMacro(CircleGlComponent,GlComponent);
 
@@ -132,6 +134,10 @@ public:
   itkSetMacro(Radius,double);
   itkGetMacro(Radius,double);
 
+  /** Set/Get the center circle radius. */
+  itkSetMacro(CenterRepresentation,CenterRepresentationEnumType);
+  itkGetMacro(CenterRepresentation,CenterRepresentationEnumType);
+
 protected:
   /** Constructor */
   CircleGlComponent();
@@ -175,6 +181,9 @@ private:
   /** Default color : red*/
   ColorType m_RedColor;
 
+  /** Center representation */ 
+  CenterRepresentationEnumType m_CenterRepresentation;
+
 }; // end class
 } // end namespace otb
 
-- 
GitLab