File size: 5,384 Bytes
68ce2fc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
/*
Author(s): Balazs Vagvolgyi, Simon DiMaio, Anton Deguet
Created on: 2008-05-23
(C) Copyright 2008 Johns Hopkins University (JHU), All Rights
Reserved.
--- begin cisst license - do not edit ---
This software is provided "as is" under an open source license, with
no warranty. The complete license can be found in license.txt and
http://www.cisst.org/cisst/license.txt.
--- end cisst license ---
*/
#ifndef _ui3MenuButton_h
#define _ui3MenuButton_h
#include <cisstVector/vctFixedSizeVectorTypes.h>
#include <cisstMultiTask/mtsFunctionVoid.h>
#include <cisstMultiTask/mtsCommandVoid.h>
#include <cisst3DUserInterface/ui3ForwardDeclarations.h>
#include <cisst3DUserInterface/ui3VTKForwardDeclarations.h>
// Always include last!
#include <cisst3DUserInterface/ui3Export.h>
/*!
Typedef for pointer to member function for button callbacks.
*/
//typedef void(_classType::*ActionType)(void);
//typedef void* ui3ControlCallbackType;
/*!
Implements a button on the menu bar. For creating a button spacer, do not call
the Create function.
*/
class CISST_EXPORT ui3MenuButton
{
friend class ui3Manager;
public:
/*!
Constructor
*/
template <class _classType>
ui3MenuButton(const std::string & description, const std::string & iconFile,
void (_classType::*action)(void), _classType * classInstantiation,
double buttonSize):
Description(description),
CheckButton(false),
Position(0.0, 0.0, 0.0),
CheckState(false),
PushState(false),
HighlightState(false),
EnableState(false),
PNGReader(0),
Texture(0),
PlaneSource(0),
Mapper(0),
Actor(0),
ButtonSize(buttonSize),
IconFile(iconFile)
{
// Create a mtsFunction around the callback command
this->Callable = new mtsCallableVoidMethod<_classType>(action, classInstantiation);
this->CreateVTKObjects();
}
/*!
Destructor
*/
virtual ~ui3MenuButton();
/*!
Creates the button and the corresponding VTK actor.
The 3D model of the button is initialized to unit size. The menu bar
object will take care of the proper resizing of the model.
\param check Set whether check button: true=check button, false=click button
\param iconfile Image file storing all the button states on a singe bitmap.
If empty string, no texture will be added.
\return Button handle, 0=error
*/
bool CreateVTKObjects(void);
inline bool UpdateVTKObjects(void);
vtkProp3D * GetVTKProp(void);
/*!
Sets the checked state of the check button.
Have no effect on non-check buttons.
\param state Set check state: true=checked, false=unchecked
*/
virtual void SetCheck(bool state);
/*!
Sets the pushed state of the button.
\param state Set pushed state: true=down, false=up
*/
virtual void SetPush(bool state);
/*!
Sets the highlighted state of the button.
\param state Set highlight state: true=highlighted, false=default
*/
virtual void SetHighlight(bool state);
/*!
Sets the enabled state of the button.
\param state Set enable state: true=enabled, false=disabled
*/
virtual void SetEnable(bool state);
/*!
Returns the checked state of the check button.
Always returns false on non-check buttons.
\return Checked state: true=checked, false=unchecked
*/
virtual bool GetCheck();
/*!
Returns the pushed state of the button.
\return Pushed state: true=down, false=up
*/
virtual bool GetPush();
/*!
Returns the highlighted state of the button.
\return Highlighted state: true=highlighted, false=default
*/
virtual bool GetHighlight();
/*!
Returns the enabled state of the button.
\return Enabled state: true=enabled, false=disabled
*/
virtual bool GetEnable();
virtual vtkActor * VTKPointer(void);
virtual void SetPosition(vct3 & position);
virtual bool IsCursorOver(const vct2 & cursor2D);
protected:
std::string Description;
/*!
Flag indicates whether the button is a check button.
*/
bool CheckButton;
/*!
Vector specifies the 3D Cartesian position of the button.
*/
vctDouble3 Position;
/*!
Flag indicates check state: true=checked, false=unchecked.
*/
bool CheckState;
/*!
Flag indicates push state: true=down, false=up.
*/
bool PushState;
/*!
Flag indicates highlight state: true=highlighted, false=default.
*/
bool HighlightState;
/*!
Flag indicates enable state: true=enabled, false=disabled.
*/
bool EnableState;
vtkPNGReader * PNGReader;
vtkTexture * Texture;
vtkPlaneSource * PlaneSource;
vtkPolyDataMapper * Mapper;
vtkActor * Actor;
// corner of buttons in menu
vct2 BottomLeft2D, TopRight2D;
double ButtonSize;
mtsCallableVoidBase * Callable;
std::string IconFile;
};
#endif // _ui3MenuButton_h
|