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
Container Registry
Model registry
Operate
Environments
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
Antoine Belvire
otb
Commits
a6415036
Commit
a6415036
authored
16 years ago
by
Julien Michel
Browse files
Options
Downloads
Patches
Plain Diff
ENH: (Visu Refactoring) Several enhancements in the Model part
parent
4a98e3fb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Code/VisuRefac/otbImageViewerModel.h
+25
-5
25 additions, 5 deletions
Code/VisuRefac/otbImageViewerModel.h
Code/VisuRefac/otbImageViewerModel.txx
+100
-7
100 additions, 7 deletions
Code/VisuRefac/otbImageViewerModel.txx
with
125 additions
and
12 deletions
Code/VisuRefac/otbImageViewerModel.h
+
25
−
5
View file @
a6415036
...
...
@@ -62,6 +62,7 @@ public:
/** Layer typedef */
typedef
otb
::
Layer
<
OutputImageType
>
LayerType
;
typedef
typename
LayerType
::
RegionType
RegionType
;
typedef
typename
RegionType
::
IndexType
IndexType
;
/** Layer list typedef */
typedef
otb
::
ObjectList
<
LayerType
>
LayerListType
;
...
...
@@ -122,9 +123,12 @@ public:
itkGetObjectMacro
(
RasterizedExtract
,
OutputImageType
);
itkGetObjectMacro
(
RasterizedScaledExtract
,
OutputImageType
);
/** Set/Get the Extract Region */
itkSetMacro
(
ExtractRegion
,
RegionType
);
itkGetConstReferenceMacro
(
ExtractRegion
,
RegionType
);
/** Get the extract region in the quicklook space */
itkGetConstReferenceMacro
(
SubsampledExtractRegion
,
RegionType
);
/** Set/Get the Scaled Extract Region */
itkSetMacro
(
ScaledExtractRegion
,
RegionType
);
...
...
@@ -137,7 +141,16 @@ public:
/** Update will render all visible layers, rasterize all visible
* layers and notify all listeners. */
virtual
void
Update
(
void
);
void
Update
(
void
);
/** Change the Scaled extract region by giving the center of the
* region */
void
SetScaledExtractRegionCenter
(
const
IndexType
&
index
);
/** Change the extract region by giving the center of the
* region */
void
SetExtractRegionCenter
(
const
IndexType
&
index
);
protected:
/** Constructor */
...
...
@@ -146,16 +159,19 @@ protected:
~
ImageViewerModel
();
/** Printself method */
void
PrintSelf
(
std
::
ostream
&
os
,
itk
::
Indent
indent
)
const
;
void
PrintSelf
(
std
::
ostream
&
os
,
itk
::
Indent
indent
)
const
;
/** Renders all visible layers */
virtual
void
RenderVisibleLayers
(
void
);
void
RenderVisibleLayers
(
void
);
/** Rasterize visible layers */
virtual
void
RasterizeVisibleLayers
(
void
);
void
RasterizeVisibleLayers
(
void
);
/** Notify a registered listener */
virtual
void
Notify
(
ListenerType
*
listener
);
void
Notify
(
ListenerType
*
listener
);
/** Constrains the given region to the largest possible one. */
RegionType
ConstrainRegion
(
const
RegionType
&
region
,
const
RegionType
&
largest
);
private:
ImageViewerModel
(
const
Self
&
);
// purposely not implemented
...
...
@@ -175,11 +191,15 @@ private:
OutputImagePointerType
m_RasterizedExtract
;
bool
m_HasExtract
;
RegionType
m_ExtractRegion
;
RegionType
m_SubsampledExtractRegion
;
/** Rendered scaled extract */
OutputImagePointerType
m_RasterizedScaledExtract
;
bool
m_HasScaledExtract
;
RegionType
m_ScaledExtractRegion
;
/** Wether the model is currently updating or not */
bool
m_Updating
;
};
// end class
}
// end namespace otb
...
...
This diff is collapsed.
Click to expand it.
Code/VisuRefac/otbImageViewerModel.txx
+
100
−
7
View file @
a6415036
...
...
@@ -27,7 +27,7 @@ template <class TOutputImage>
ImageViewerModel<TOutputImage>
::ImageViewerModel() : m_Name("Default"), m_Layers(), m_RasterizedQuicklook(),
m_HasQuicklook(false),m_RasterizedExtract(),m_HasExtract(false),
m_ExtractRegion(), m_RasterizedScaledExtract(), m_HasScaledExtract(false),
m_ExtractRegion(),
m_SubsampledExtractRegion(),
m_RasterizedScaledExtract(), m_HasScaledExtract(false),
m_ScaledExtractRegion()
{
...
...
@@ -159,12 +159,18 @@ void
ImageViewerModel<TOutputImage>
::Update()
{
// Render all visible layers
this->RenderVisibleLayers();
// Rasterize all visible layers
this->RasterizeVisibleLayers();
// Notify all listeners
this->NotifyAll();
// Multiple concurrent update guards
if(!m_Updating)
{
m_Updating = true;
// Render all visible layers
this->RenderVisibleLayers();
// Rasterize all visible layers
this->RasterizeVisibleLayers();
// Notify all listeners
this->NotifyAll();
m_Updating = false;
}
}
template <class TOutputImage>
...
...
@@ -216,6 +222,17 @@ ImageViewerModel<TOutputImage>
{
m_HasQuicklook = true;
m_RasterizedQuicklook = baseLayer->GetRenderedQuicklook();
// Update the subsampled extract region
m_SubsampledExtractRegion = m_ExtractRegion;
typename RegionType::SizeType size = m_SubsampledExtractRegion.GetSize();
typename RegionType::IndexType index = m_SubsampledExtractRegion.GetIndex();
size[0]/=baseLayer->GetQuicklookSubsamplingRate();
size[1]/=baseLayer->GetQuicklookSubsamplingRate();
index[0]/=baseLayer->GetQuicklookSubsamplingRate();
index[1]/=baseLayer->GetQuicklookSubsamplingRate();
m_SubsampledExtractRegion.SetIndex(index);
m_SubsampledExtractRegion.SetSize(size);
}
if(baseLayer->GetHasExtract())
...
...
@@ -229,6 +246,9 @@ ImageViewerModel<TOutputImage>
m_HasScaledExtract = true;
m_RasterizedScaledExtract = baseLayer->GetRenderedScaledExtract();
}
// Move to the next layer
++it;
// Walk the remaining layers
while(it!=m_Layers->End())
...
...
@@ -287,9 +307,82 @@ void
ImageViewerModel<TOutputImage>
::Notify(ListenerType * listener)
{
// Notify the listener
listener->ImageViewerNotify();
}
template <class TOutputImage>
void
ImageViewerModel<TOutputImage>
::SetScaledExtractRegionCenter(const IndexType & index)
{
// Set the center of the scaled extract region
IndexType newIndex = index;
newIndex[0]-=m_ScaledExtractRegion.GetSize()[0]/2;
newIndex[1]-=m_ScaledExtractRegion.GetSize()[1]/2;
m_ScaledExtractRegion.SetIndex(newIndex);
}
template <class TOutputImage>
void
ImageViewerModel<TOutputImage>
::SetExtractRegionCenter(const IndexType & index)
{
// Set the center of the extract region
IndexType newIndex = index;
newIndex[0]-=m_ExtractRegion.GetSize()[0]/2;
newIndex[1]-=m_ExtractRegion.GetSize()[1]/2;
m_ExtractRegion.SetIndex(newIndex);
}
template <class TOutputImage>
typename ImageViewerModel<TOutputImage>
::RegionType
ImageViewerModel<TOutputImage>
::ConstrainRegion(const RegionType & region, const RegionType & largest)
{
// First check if the case is trivial
if(region.GetNumberOfPixels() == 0 || largest.IsInside(region))
{
return region;
}
RegionType resp = region;
typename RegionType::IndexType index = resp.GetIndex();
typename RegionType::SizeType size = resp.GetSize();
for(unsigned int dim = 0; dim<RegionType::ImageDimension;++dim)
{
const int offset = index[dim]+size[dim] - largest.GetIndex()[dim] + largest.GetSize()[dim];
// If the region is not larger than the largest, wen can constrain
if(largest.GetSize()[dim] > size[dim])
{
// If the region is to the left, push left
if(index[dim] < largest.GetIndex()[dim])
{
index[dim] = largest.GetIndex()[dim];
}
// If the region is to the right, push right
else if(offset > 0)
{
index[dim]-=offset;
}
}
else
{
// else crop
index[dim] = largest.GetIndex()[dim];
size[dim] = largest.GetSize()[dim];
}
}
resp.SetIndex(index);
resp.SetSize(size);
return resp;
}
template <class TOutputImage>
void
ImageViewerModel<TOutputImage>
...
...
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