57 style->setCameraStyle(mCameraStyle);
58 mViews.push_back(style);
73 if (mCameraStyle == style)
76 for (
unsigned i=0; i<mViews.size(); ++i)
89 mCameraStyleGroup(NULL)
96 disconnect(mStyle.get(), SIGNAL(cameraStyleChanged()),
this, SLOT(updateActionGroup()));
99 connect(mStyle.get(), SIGNAL(cameraStyleChanged()),
this, SLOT(updateActionGroup()));
100 this->updateActionGroup();
105 if (mCameraStyleGroup)
106 return mCameraStyleGroup;
108 mCameraStyleGroup =
new QActionGroup(
this);
109 mCameraStyleGroup->setExclusive(
true);
111 this->addInteractorStyleAction(
"Normal Camera", mCameraStyleGroup,
113 QIcon(
":/icons/camera-n.png"),
114 "Set 3D interaction to the normal camera-oriented style.");
115 this->addInteractorStyleAction(
"Tool", mCameraStyleGroup,
117 QIcon(
":/icons/camera-t.png"),
118 "Camera following tool.");
119 this->addInteractorStyleAction(
"Angled Tool", mCameraStyleGroup,
121 QIcon(
":/icons/camera-at.png"),
122 "Camera following tool (Placed at an angle of 20 degrees).");
123 this->addInteractorStyleAction(
"Unicam", mCameraStyleGroup,
125 QIcon(
":/icons/camera-u.png"),
126 "Set 3D interaction to a single-button style, useful for touch screens.");
127 return mCameraStyleGroup;
130 void CameraStyleInteractor::addInteractorStyleAction(QString caption, QActionGroup* group, QString uid, QIcon icon,
133 QAction* action =
new QAction(caption, group);
134 action->setIcon(icon);
135 action->setCheckable(
true);
136 action->setData(uid);
137 action->setToolTip(helptext);
138 action->setWhatsThis(helptext);
139 connect(action, SIGNAL(triggered(
bool)),
this, SLOT(setInteractionStyleActionSlot()));
142 void CameraStyleInteractor::updateActionGroup()
144 QString currentStyle;
146 currentStyle =
enum2string(mStyle->getCameraStyle());
148 if(mCameraStyleGroup)
150 QList<QAction*> actions = mCameraStyleGroup->actions();
151 for (
int i=0; i<actions.size(); ++i)
153 actions[i]->setEnabled(mStyle!=0);
154 bool check = actions[i]->data().toString() == currentStyle;
155 if(actions[i]->isChecked() != check)
156 actions[i]->setChecked(check);
161 void CameraStyleInteractor::setInteractionStyleActionSlot()
163 QAction* theAction =
static_cast<QAction*
>(sender());
167 QString uid = theAction->data().toString();
168 CAMERA_STYLE_TYPE newStyle = string2enum<cx::CAMERA_STYLE_TYPE>(uid);
169 if (newStyle==cstCOUNT)
173 mStyle->setCameraStyle(newStyle);
void setCameraStyle(CAMERA_STYLE_TYPE style)
Select tool style. This replaces the vtkInteractor Style.
CAMERA_STYLE_TYPE getCameraStyle() const
void addView(ViewPtr view)
boost::shared_ptr< class CameraStyle > CameraStylePtr
boost::shared_ptr< class View > ViewPtr
QActionGroup * getInteractorStyleActionGroup()
CameraStyle(CoreServicesPtr backend)
boost::shared_ptr< class CameraStyleForView > CameraStyleForViewPtr
void cameraStyleChanged()
boost::shared_ptr< class CoreServices > CoreServicesPtr
void connectCameraStyle(CameraStylePtr style)
QString enum2string(const ENUM &val)