Commit eee7ee5b authored by cfouard's avatar cfouard
Browse files

FIXED bug not even reported yet: Crash when setParent is called.

git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@1591 ec899d31-69d1-42ba-9299-647d76f65fb3
parent 5d54b06d
......@@ -92,9 +92,11 @@ void MoveFrame::init() {
connect(ui.resetButton, SIGNAL(clicked()), SLOT(reset()));
connect(ui.setTransformButton, SIGNAL(clicked()), SLOT(apply()));
connect(ui.savePushButton, SIGNAL(clicked()), SLOT(save()));
connect(ui.parentFramePushButton, SIGNAL(clicked()), SLOT(changeParent()));
}
// --------------- destructor -------------------
MoveFrame::~MoveFrame() {
if (dialog) {
......@@ -124,6 +126,25 @@ QWidget * MoveFrame::getWidget() {
return dialog;
}
void MoveFrame::changeParent() {
if (inputFrame != NULL) {
QString parentName = ui.parentFrameComboBox->currentText();
// Find the corresponding component:
const ComponentList existingComponents = Application::getAllComponents();
Component * newParent = NULL;
int i = 0;
while ((i < existingComponents.size()) && (parentName != existingComponents.at(i)->getName())) {
i++;
}
if (i < existingComponents.size()) {
newParent = existingComponents.at(i);
}
inputFrame->setParentFrame(newParent);
}
InteractiveViewer::get3DViewer()->refresh();
}
//--------------- reset -------------
void MoveFrame::reset() {
//-- initialize the transformation to Identity
......@@ -145,6 +166,27 @@ void MoveFrame::reset() {
ui.rX->init(-180.0, 180.0, initialOrientation.x());
ui.rY->init(-180.0, 180.0, initialOrientation.y());
ui.rZ->init(-180.0, 180.0, initialOrientation.z());
//-- Fill in the Possible Parent Frame Components ComboBox
ui.parentFrameComboBox->clear();
QStringList possibleParentFrames;
possibleParentFrames << "World Frame";
const ComponentList existingComponents = Application::getAllComponents();
for (Component * c: existingComponents) {
possibleParentFrames << c->getName();
}
ui.parentFrameComboBox->addItems(possibleParentFrames);
if (inputFrame != NULL) {
Component * currentParentComponent = dynamic_cast<Component *> (inputFrame->getParentFrame());
if (currentParentComponent == NULL) {
ui.parentFrameComboBox->setCurrentIndex(0);
}
else {
ui.parentFrameComboBox->setCurrentIndex(possibleParentFrames.indexOf(currentParentComponent->getName()));
}
}
}
......
......@@ -63,6 +63,7 @@ public slots:
virtual void rotate();
virtual void setRotation();
virtual void save();
virtual void changeParent();
private slots:
......
......@@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>477</width>
<height>230</height>
<width>652</width>
<height>315</height>
</rect>
</property>
<property name="sizePolicy">
......@@ -29,7 +29,7 @@
<bool>true</bool>
</property>
<layout class="QGridLayout">
<item row="0" column="0">
<item row="1" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="textSliders">
......@@ -199,7 +199,7 @@
</item>
</layout>
</item>
<item row="2" column="0">
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<spacer name="horizontalSpacer_4">
......@@ -236,6 +236,27 @@
</item>
</layout>
</item>
<item row="0" column="0">
<layout class="QHBoxLayout" name="parentFrameLayout">
<item>
<widget class="QLabel" name="parentFrameLabel">
<property name="text">
<string>Parent Frame Component</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="parentFrameComboBox"/>
</item>
<item>
<widget class="QPushButton" name="parentFramePushButton">
<property name="text">
<string>Set Parent Frame</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
......
......@@ -115,11 +115,11 @@ ReorientImage::ReorientImage(ActionExtension* extension) : Action(extension) {
// --------------- destructor -------------------
ReorientImage::~ReorientImage() {
internalViewer->getRendererWidget()->removeProp(femaleModel->getActor(InterfaceGeometry::Surface));
internalViewer->getRendererWidget()->removeProp(maleModel->getActor(InterfaceGeometry::Surface));
internalViewer->getRendererWidget()->removeProp(modelBoundingBox->getActor(InterfaceGeometry::Wireframe));
internalViewer->getRendererWidget()->removeProp(axes);
internalViewer->getRendererWidget()->removeProp(annotatedCube);
// internalViewer->getRendererWidget()->removeProp(femaleModel->getActor(InterfaceGeometry::Surface));
// internalViewer->getRendererWidget()->removeProp(maleModel->getActor(InterfaceGeometry::Surface));
// internalViewer->getRendererWidget()->removeProp(modelBoundingBox->getActor(InterfaceGeometry::Wireframe));
// internalViewer->getRendererWidget()->removeProp(axes);
// internalViewer->getRendererWidget()->removeProp(annotatedCube);
axes = NULL;
annotatedCube = NULL;
......
......@@ -42,7 +42,19 @@ Frame::Frame(vtkSmartPointer<vtkTransform> transform, Frame *parentFrame)
setTransformFromParent(transform);
}
setParentFrame(parentFrame);
// setParentFrame(parentFrame);
this->parentFrame = parentFrame;
this->transformWorldToMe->Identity();
this->transformWorldToMe->PostMultiply();
this->transformWorldToMe->Concatenate(transformParentToMe);
this->transformWorldToMe->Update();
if (this->parentFrame != NULL)
{
this->transformWorldToMe->Concatenate(this->parentFrame->getTransformFromWorld());
this->transformWorldToMe->Update();
this->parentFrame->addFrameChild(this);
}
}
......@@ -144,9 +156,19 @@ const vtkSmartPointer<vtkTransform> Frame::getTransformFromParent() {
// ------------------- getTransformFromFrame ----------------------------------
vtkSmartPointer<vtkTransform> Frame::getTransformFromFrame(InterfaceFrame * frame) {
// World -> Me
vtkSmartPointer<vtkMatrix4x4> worldToMeMatrix = transformParentToMe->GetConcatenatedTransform(transformParentToMe->GetNumberOfConcatenatedTransforms())->GetMatrix();
vtkSmartPointer<vtkMatrix4x4> worldToMeMatrix = transformWorldToMe->GetMatrix();
// World -> Frame
vtkSmartPointer<vtkMatrix4x4> worldToFrameMatrix = frame->getTransformFromParent()->GetConcatenatedTransform(frame->getTransformFromParent()->GetNumberOfConcatenatedTransforms())->GetMatrix();
vtkSmartPointer<vtkMatrix4x4> worldToFrameMatrix;
if (frame == NULL) { // Frame IS the world Frame !
worldToFrameMatrix = vtkSmartPointer<vtkMatrix4x4>::New();
worldToMeMatrix->Identity();
}
else {
worldToFrameMatrix = frame->getTransformFromWorld()->GetMatrix();
//frame->getTransformFromParent()->GetConcatenatedTransform(frame->getTransformFromParent()->GetNumberOfConcatenatedTransforms())->GetMatrix();
}
// Frame -> World
vtkSmartPointer<vtkMatrix4x4> frameToWorldMatrix = vtkSmartPointer<vtkMatrix4x4>::New();
vtkMatrix4x4::Invert(worldToFrameMatrix, frameToWorldMatrix);
......
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