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.");
128 return mCameraStyleGroup;
131 void CameraStyleInteractor::addInteractorStyleAction(QString caption, QActionGroup* group, QString uid, QIcon icon,
134 QAction* action =
new QAction(caption, group);
135 action->setIcon(icon);
136 action->setCheckable(
true);
137 action->setData(uid);
138 action->setToolTip(helptext);
139 action->setWhatsThis(helptext);
140 connect(action, SIGNAL(triggered(
bool)),
this, SLOT(setInteractionStyleActionSlot()));
143 void CameraStyleInteractor::updateActionGroup()
145 QString currentStyle;
147 currentStyle =
enum2string(mStyle->getCameraStyle());
149 QList<QAction*> actions = mCameraStyleGroup->actions();
150 for (
int i=0; i<actions.size(); ++i)
152 actions[i]->blockSignals(
true);
153 actions[i]->setChecked(actions[i]->data().toString() == currentStyle);
154 actions[i]->setEnabled(mStyle!=0);
155 actions[i]->blockSignals(
false);
160 void CameraStyleInteractor::setInteractionStyleActionSlot()
162 QAction* theAction =
static_cast<QAction*
>(sender());
166 QString uid = theAction->data().toString();
167 CAMERA_STYLE_TYPE newStyle = string2enum<cx::CAMERA_STYLE_TYPE>(uid);
168 if (newStyle==cstCOUNT)
172 mStyle->setCameraStyle(newStyle);
void setCameraStyle(CAMERA_STYLE_TYPE style)
Select tool style. This replaces the vtkInteractor Style.
QActionGroup * createInteractorStyleActionGroup()
CAMERA_STYLE_TYPE getCameraStyle() const
void addView(ViewPtr view)
boost::shared_ptr< class CameraStyle > CameraStylePtr
boost::shared_ptr< class View > ViewPtr
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)