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
fdd7383e
Commit
fdd7383e
authored
16 years ago
by
Julien Michel
Browse files
Options
Downloads
Patches
Plain Diff
ENH: (Visu Refactoring) Adding a widget controller
parent
73be1d0d
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/VisuRefac/otbImageWidgetController.cxx
+117
-0
117 additions, 0 deletions
Code/VisuRefac/otbImageWidgetController.cxx
Code/VisuRefac/otbImageWidgetController.h
+105
-0
105 additions, 0 deletions
Code/VisuRefac/otbImageWidgetController.h
with
222 additions
and
0 deletions
Code/VisuRefac/otbImageWidgetController.cxx
0 → 100644
+
117
−
0
View file @
fdd7383e
/*=========================================================================
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 __otbImageWidgetController_cxx
#define __otbImageWidgetController_cxx
#include
"otbImageWidgetController.h"
namespace
otb
{
ImageWidgetController
::
ImageWidgetController
()
{
// Instantiate action handlers list
m_ActionHandlersList
=
ActionHandlerListType
::
New
();
}
ImageWidgetController
::~
ImageWidgetController
()
{}
void
ImageWidgetController
::
AddActionHandler
(
ActionHandlerType
*
handler
)
{
// Add the handler to the list
m_ActionHandlersList
->
PushBack
(
handler
);
}
void
ImageWidgetController
::
RemoveActionHandler
(
unsigned
int
index
)
{
// Remove the given handler
m_ActionHandlersList
->
Erase
(
index
);
}
void
ImageWidgetController
::
ClearAllActionHandlers
()
{
// Clear the handlers list
m_ActionHandlersList
->
Clear
();
}
int
ImageWidgetController
::
HandleWidgetEvent
(
std
::
string
widgetId
,
int
event
)
{
// Define an iterator on the action handlers list
ActionHandlerListType
::
Iterator
it
=
m_ActionHandlersList
->
Begin
();
// Found indicates if a handler was found to respond to this event
bool
found
=
false
;
// The action handler found
ActionHandlerType
*
handler
;
while
(
!
found
&&
it
!=
m_ActionHandlersList
->
End
())
{
// Get the current handler
handler
=
it
.
Get
();
// Check if it listens to (widget,event)
found
=
handler
->
ListenToEvent
(
widgetId
,
event
);
++
it
;
}
// If an handler was found, use it
if
(
found
)
{
return
handler
->
HandleWidgetEvent
(
widgetId
,
event
);
}
else
{
return
0
;
}
}
void
ImageWidgetController
::
HandleWidgetResize
(
std
::
string
widgetId
,
int
x
,
int
y
,
int
w
,
int
h
)
{
// Define an iterator on the action handlers list
ActionHandlerListType
::
Iterator
it
=
m_ActionHandlersList
->
Begin
();
// Found indicates if a handler was found to respond to this event
bool
found
=
false
;
// The action handler found
ActionHandlerType
*
handler
;
while
(
!
found
&&
it
!=
m_ActionHandlersList
->
End
())
{
// Get the current handler
handler
=
it
.
Get
();
// Check if it listens to (widget,event)
found
=
handler
->
ListenToResize
(
widgetId
);
++
it
;
}
// If an handler was found, use it
if
(
found
)
{
handler
->
HandleWidgetResize
(
widgetId
,
x
,
y
,
w
,
h
);
}
}
void
ImageWidgetController
::
PrintSelf
(
std
::
ostream
&
os
,
itk
::
Indent
indent
)
const
{
Superclass
::
PrintSelf
(
os
,
indent
);
os
<<
indent
<<
"Number of action handlers: "
<<
m_ActionHandlersList
->
Size
()
<<
std
::
endl
;
}
}
// end namespace otb
#endif
This diff is collapsed.
Click to expand it.
Code/VisuRefac/otbImageWidgetController.h
0 → 100644
+
105
−
0
View file @
fdd7383e
/*=========================================================================
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 __otbImageWidgetController_h
#define __otbImageWidgetController_h
#include
"otbImageWidgetActionHandler.h"
#include
"otbObjectList.h"
namespace
otb
{
/** \class ImageWidgetController
* \brief This controller processes the events from a set of image
* widget.
* Events are procesed by instances of the ImageWidgetActionHandler
* class which are registered dynamically via the AddActionHandler
* method.
* \sa ImageWidget
* \sa ImageWidgetActionHandler
*/
class
ImageWidgetController
:
public
itk
::
Object
{
public:
/** Standard class typedefs */
typedef
ImageWidgetController
Self
;
typedef
itk
::
Object
Superclass
;
typedef
itk
::
SmartPointer
<
Self
>
Pointer
;
typedef
itk
::
SmartPointer
<
const
Self
>
ConstPointer
;
/** Method for creation through the object factory */
itkNewMacro
(
Self
);
/** Runtime information */
itkTypeMacro
(
ImageWidgetController
,
Object
);
/** Handler typedef */
typedef
otb
::
ImageWidgetActionHandler
ActionHandlerType
;
typedef
otb
::
ObjectList
<
ActionHandlerType
>
ActionHandlerListType
;
typedef
ActionHandlerListType
::
Pointer
ActionHandlerListPointerType
;
/** Add an action handler
* \param handler The action handler.
**/
virtual
void
AddActionHandler
(
ActionHandlerType
*
handler
);
/** Remove an action handler if it exists
* \param index The index of the action handler.
**/
virtual
void
RemoveActionHandler
(
unsigned
int
index
);
/** Remove all actions handler
*/
virtual
void
ClearAllActionHandlers
();
/** Handle an event from a widget
* \param widgetId The id of the widget the event comes from
* \param event The event code
*/
int
HandleWidgetEvent
(
std
::
string
widgetId
,
int
event
);
/** Handle widget resizing
* \param widgetId The id of the resized widget
* \param x new x location
* \param y new y location
* \param w new width
* \param h new height
*/
void
HandleWidgetResize
(
std
::
string
widgetId
,
int
x
,
int
y
,
int
w
,
int
h
);
protected:
/** Constructor */
ImageWidgetController
();
/** Destructor */
~
ImageWidgetController
();
/** Printself method */
void
PrintSelf
(
std
::
ostream
&
os
,
itk
::
Indent
indent
)
const
;
private:
ImageWidgetController
(
const
Self
&
);
// purposely not implemented
void
operator
=
(
const
Self
&
);
// purposely not implemented
/** Action handlers list */
ActionHandlerListPointerType
m_ActionHandlersList
;
};
// 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