Commit d54c2fe0 authored by lealv's avatar lealv
Browse files

FIXED - Frames - MoveFrame action: implement a special usecase of move frame...

FIXED - Frames - MoveFrame action: implement a special usecase of move frame action SetParent. If a frame is a SingleImageComponent frame, it cannot be a parent of a frame itself, its parent becomes the parent of the new frame.
The SingleImageComponents frames are not displayed in the list of potential parents.

git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@1843 ec899d31-69d1-42ba-9299-647d76f65fb3
parent 6619c23c
......@@ -31,6 +31,7 @@
#include <Log.h>
#include <Application.h>
#include <Component.h>
#include <SingleImageComponent.h>
using namespace camitk;
// Qt
......@@ -111,11 +112,11 @@ QWidget * MoveFrame::getWidget() {
inputFrame = dynamic_cast<Component *> (getTargets().last());
vtkSmartPointer<vtkTransform> initialTransform = inputFrame->getTransformFromParent();
initialPosition.setX(initialTransform->GetPosition()[0]);
initialPosition.setY(initialTransform->GetPosition()[1]);
initialPosition.setZ(initialTransform->GetPosition()[2]);
initialOrientation.setX(initialTransform->GetOrientation()[0]);
initialOrientation.setY(initialTransform->GetOrientation()[1]);
initialOrientation.setZ(initialTransform->GetOrientation()[2]);
......@@ -139,7 +140,7 @@ void MoveFrame::changeParent() {
if (i < existingComponents.size()) {
newParent = existingComponents.at(i);
}
inputFrame->setParentFrame(newParent);
}
InteractiveViewer::get3DViewer()->refresh();
......@@ -152,7 +153,7 @@ void MoveFrame::reset() {
transformation->RotateX(initialOrientation.x());
transformation->RotateY(initialOrientation.y());
transformation->RotateZ(initialOrientation.z());
transformation->Translate(initialPosition.x(), initialPosition.y(), initialPosition.z());
transformation->Translate(initialPosition.x(), initialPosition.y(), initialPosition.z());
//-- init values
double bounds[6];
......@@ -174,13 +175,25 @@ void MoveFrame::reset() {
const ComponentList existingComponents = Application::getAllComponents();
for (int i = 0; i < existingComponents.size(); i++) {
Component * c = existingComponents.at(i);
possibleParentFrames << c->getName();
if( c )
{
SingleImageComponent * csi = dynamic_cast<SingleImageComponent *>( c );
if( csi )
{
//do nothing
//A singleImageComponent cannot be a parent frame, it is always a frame child of another frame.
}
else
{
possibleParentFrames << c->getName();
}
}
}
ui.parentFrameComboBox->addItems(possibleParentFrames);
if (inputFrame != NULL) {
Component * currentParentComponent = dynamic_cast<Component *> (inputFrame->getParentFrame());
if (currentParentComponent == NULL) {
ui.parentFrameComboBox->setCurrentIndex(0);
}
......@@ -219,10 +232,10 @@ void MoveFrame::translate() {
trans.setX(double (ui.tX->getValue()));
trans.setY(double (ui.tY->getValue()));
trans.setZ(double (ui.tZ->getValue()));
inputFrame->translate(trans.x(), trans.y(), trans.z());
}
void MoveFrame::setTranslation() {
QVector3D trans;
trans.setX(double (ui.tX->getValue()));
......@@ -262,7 +275,7 @@ void MoveFrame::save() {
//-- Set the Translation
transformation->Translate(double(ui.tX->getValue()), double(ui.tY->getValue()), double(ui.tZ->getValue()));
QString filename = QFileDialog::getSaveFileName(NULL, "Save file");
QFile file(filename);
if (file.open(QIODevice::WriteOnly)) {
......@@ -303,14 +316,14 @@ void MoveFrame::save() {
QDomText t = doc.createTextNode(QString::number(tVal));
tElmt.appendChild(t);
line.appendChild(tElmt);
transform.appendChild(line);
}
transform.appendChild(line);
}
root.appendChild(transform);
doc.appendChild(root);
doc.save(stream, 0);
file.close();
}
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment