Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
otb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Youssefi
otb
Commits
6a0c3541
Commit
6a0c3541
authored
15 years ago
by
Cyrille Valladeau
Browse files
Options
Downloads
Patches
Plain Diff
ENH : add cross gl component representation
parent
71d6b93f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Code/Visualization/otbCrossGlComponent.cxx
+122
-0
122 additions, 0 deletions
Code/Visualization/otbCrossGlComponent.cxx
Code/Visualization/otbCrossGlComponent.h
+184
-0
184 additions, 0 deletions
Code/Visualization/otbCrossGlComponent.h
with
306 additions
and
0 deletions
Code/Visualization/otbCrossGlComponent.cxx
0 → 100644
+
122
−
0
View file @
6a0c3541
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __otbCrossGlComponent_cxx
#define __otbCrossGlComponent_cxx
#include
"otbCrossGlComponent.h"
namespace
otb
{
CrossGlComponent
::
CrossGlComponent
()
:
m_IndexList
(),
m_Spacing
(),
m_Origin
(),
m_GluTesselator
(),
m_ColorList
(),
m_LineWidth
(
1.5
),
m_CrossWidth
(
10
),
m_RedColor
()
{
// Default color is red
m_RedColor
.
Fill
(
0
);
m_RedColor
[
0
]
=
1.
;
m_RedColor
[
3
]
=
0.75
;
// Intialize origin and spacing
m_Origin
.
Fill
(
0.
);
m_Spacing
.
Fill
(
1.
);
// Create the tesselator
m_GluTesselator
=
gluNewTess
();
}
CrossGlComponent
::~
CrossGlComponent
()
{
// Delete the tesselator
gluDeleteTess
(
m_GluTesselator
);
}
void
CrossGlComponent
::
Render
(
const
RegionType
&
extent
,
const
AffineTransformType
*
space2ScreenTransform
)
{
if
(
m_IndexList
.
size
()
==
0
)
{
// nothing to render, return
return
;
}
// Set up blending and color
glEnable
(
GL_BLEND
);
glBlendFunc
(
GL_SRC_ALPHA
,
GL_ONE_MINUS_SRC_ALPHA
);
glColor4d
(
m_RedColor
[
0
],
m_RedColor
[
1
],
m_RedColor
[
2
],
m_RedColor
[
3
]);
// Set up line width
double
previousWidth
=
0.
;
glGetDoublev
(
GL_LINE_WIDTH
,
&
previousWidth
);
// convert line width to screen line width
VectorType
imageLineWidth
;
imageLineWidth
.
Fill
(
m_LineWidth
);
VectorType
screenLineWidth
=
space2ScreenTransform
->
TransformVector
(
imageLineWidth
);
glLineWidth
(
screenLineWidth
[
0
]);
// Do we need to render boundaries only (for polygons)
gluTessProperty
(
m_GluTesselator
,
GLU_TESS_BOUNDARY_ONLY
,
false
);
//m_RenderPolygonBoundariesOnly);
// Enabling line antialiasing
glEnable
(
GL_LINE_SMOOTH
);
for
(
unsigned
int
i
=
0
;
i
<
m_IndexList
.
size
();
i
++
)
{
this
->
Render
(
i
,
extent
,
space2ScreenTransform
);
}
glDisable
(
GL_LINE_SMOOTH
);
glDisable
(
GL_BLEND
);
glLineWidth
(
previousWidth
);
}
void
CrossGlComponent
::
Render
(
unsigned
int
id
,
const
RegionType
&
extent
,
const
AffineTransformType
*
space2ScreenTransform
)
{
glColor4d
(
m_ColorList
[
id
][
0
],
m_ColorList
[
id
][
1
],
m_ColorList
[
id
][
2
],
m_ColorList
[
id
][
3
]);
// Take into account pixel spacing and origin
//PointType spacePoint = dataNode->GetPoint();
PointType
spacePoint
;
spacePoint
[
0
]
*=
m_Spacing
[
0
];
spacePoint
[
1
]
*=
m_Spacing
[
1
];
spacePoint
[
0
]
=
m_IndexList
[
id
][
0
]
+
m_Origin
[
0
];
spacePoint
[
1
]
=
m_IndexList
[
id
][
1
]
+
m_Origin
[
1
];
// Transform to a screen point
PointType
screenPoint
=
space2ScreenTransform
->
TransformPoint
(
spacePoint
);
glBegin
(
GL_LINES
);
// Draw a cross
glVertex2d
(
screenPoint
[
0
]
-
m_CrossWidth
,
screenPoint
[
1
]);
glVertex2d
(
screenPoint
[
0
]
+
m_CrossWidth
,
screenPoint
[
1
]);
glVertex2d
(
screenPoint
[
0
],
screenPoint
[
1
]
-
m_CrossWidth
);
glVertex2d
(
screenPoint
[
0
],
screenPoint
[
1
]
+
m_CrossWidth
);
glEnd
();
}
}
#endif
This diff is collapsed.
Click to expand it.
Code/Visualization/otbCrossGlComponent.h
0 → 100644
+
184
−
0
View file @
6a0c3541
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __otbCrossGlComponent_h
#define __otbCrossGlComponent_h
#include
"otbGlComponent.h"
#include
"itkPreOrderTreeIterator.h"
# ifdef __APPLE__
# include <OpenGL/glu.h>
# else
# include <GL/glu.h>
# endif
// There are function prototype conflits under cygwin between standard w32 API
// and standard C ones
#ifndef CALLBACK
#if defined(_WINDOWS) || defined(__CYGWIN__)
#define CALLBACK __stdcall
#else
#define CALLBACK
#endif
#endif
namespace
otb
{
/** \class CrossGlComponent
* \brief This Gl Component to render a Cross.
* No checking is done upon the adequation between the Cross
* projection and the underlying image projection.
*
* Origin and Spacing allows to fit to the image axis.
* \ingroup Visualization
*/
class
CrossGlComponent
:
public
GlComponent
{
public:
/** Standard class typedefs */
typedef
CrossGlComponent
Self
;
typedef
GlComponent
Superclass
;
typedef
itk
::
SmartPointer
<
Self
>
Pointer
;
typedef
itk
::
SmartPointer
<
const
Self
>
ConstPointer
;
typedef
Superclass
::
RegionType
RegionType
;
// affine transform
typedef
Superclass
::
AffineTransformType
AffineTransformType
;
typedef
AffineTransformType
::
InputPointType
PointType
;
typedef
AffineTransformType
::
InputVectorType
VectorType
;
typedef
Superclass
::
ColorType
ColorType
;
typedef
itk
::
Index
<>
IndexType
;
typedef
std
::
vector
<
IndexType
>
IndexListType
;
typedef
std
::
vector
<
ColorType
>
ColorListType
;
/** Runtime information */
itkTypeMacro
(
CrossGlComponent
,
GlComponent
);
/** New macro */
itkNewMacro
(
Self
);
/// Render the vector data
virtual
void
Render
(
const
RegionType
&
extent
,
const
AffineTransformType
*
space2ScreenTransform
);
/** Set/Get the grid spacing */
itkSetMacro
(
Spacing
,
VectorType
);
itkGetConstReferenceMacro
(
Spacing
,
VectorType
);
/** Set/Get the grid origin */
itkSetMacro
(
Origin
,
PointType
);
itkGetConstReferenceMacro
(
Origin
,
PointType
);
/** Set/Get the index to render */
void
SetIndexList
(
IndexListType
idList
)
{
m_IndexList
=
idList
;
};
IndexListType
GetIndexList
()
{
return
m_IndexList
;
};
void
AddIndex
(
IndexType
id
)
{
m_IndexList
.
push_back
(
id
);
m_ColorList
.
push_back
(
m_RedColor
);
};
void
RemoveIndex
(
unsigned
int
id
)
{
if
(
id
>=
m_IndexList
.
size
()
)
itkExceptionMacro
(
<<
"Index out of size "
);
m_IndexList
.
erase
(
m_IndexList
.
begin
()
+
id
);
};
/** Set/Get the color */
void
SetColorList
(
ColorListType
colorList
)
{
m_ColorList
=
colorList
;
};
ColorListType
GetColorList
()
{
return
m_ColorList
;
};
void
ChangeColor
(
ColorType
color
,
unsigned
int
id
)
{
if
(
id
>=
m_ColorList
.
size
()
)
itkExceptionMacro
(
<<
"Index out of size "
);
m_ColorList
[
id
]
=
color
;
};
void
RemoveColor
(
unsigned
int
id
)
{
if
(
id
>=
m_ColorList
.
size
()
)
itkExceptionMacro
(
<<
"Index out of size "
);
m_ColorList
.
erase
(
m_ColorList
.
begin
()
+
id
);
};
/** Clear all*/
void
Clear
()
{
m_IndexList
.
clear
();
m_ColorList
.
clear
();
};
void
ClearIndex
(
unsigned
int
id
)
{
this
->
RemoveIndex
(
id
);
this
->
RemoveColor
(
id
);
};
/** Set/Get the line width */
itkSetMacro
(
LineWidth
,
double
);
itkGetMacro
(
LineWidth
,
double
);
/** Set/Get the cross width */
itkSetMacro
(
CrossWidth
,
double
);
itkGetMacro
(
CrossWidth
,
double
);
protected
:
/** Constructor */
CrossGlComponent
();
/** Destructor */
virtual
~
CrossGlComponent
();
/** Printself method */
virtual
void
PrintSelf
(
std
::
ostream
&
os
,
itk
::
Indent
indent
)
const
{
Superclass
::
PrintSelf
(
os
,
indent
);
}
// Recursive rendering method
virtual
void
Render
(
unsigned
int
id
,
const
RegionType
&
extent
,
const
AffineTransformType
*
space2ScreenTransform
);
private
:
CrossGlComponent
(
const
Self
&
);
// purposely not implemented
void
operator
=
(
const
Self
&
);
// purposely not implemented
/// Index point to render
IndexListType
m_IndexList
;
/// Spacing of the image grid
VectorType
m_Spacing
;
/// Origin of the image
PointType
m_Origin
;
/// The GluTesselator object to render complex polygons
GLUtesselator
*
m_GluTesselator
;
/// Color of the vector layer
ColorListType
m_ColorList
;
/** The line width */
double
m_LineWidth
;
/** The cross width for points */
double
m_CrossWidth
;
/** Default color : red*/
ColorType
m_RedColor
;
};
// end class
}
// end namespace otb
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment