+ Show orientation dialog when creating an image plane
This commit is contained in:
parent
ee77154e6a
commit
6a7d2dea17
|
@ -20,6 +20,7 @@ set(ImageGui_LIBS
|
|||
set(ImageGui_MOC_HDRS
|
||||
ImageView.h
|
||||
GLImageBox.h
|
||||
ImageOrientationDialog.h
|
||||
)
|
||||
|
||||
fc_wrap_cpp(ImageGui_MOC_SRCS ${ImageGui_MOC_HDRS})
|
||||
|
@ -32,12 +33,20 @@ SET(ImageGui_RES_SRCS
|
|||
fc_add_resources(ImageGui_QRC_SRCS ${ImageGui_RES_SRCS})
|
||||
#QT4_ADD_RESOURCES(ImageGui_QRC_SRCS ${ImageGui_RES_SRCS})
|
||||
|
||||
set(ImageGui_UIC_SRCS
|
||||
ImageOrientationDialog.ui
|
||||
)
|
||||
qt4_wrap_ui(ImageGui_UIC_HDRS ${ImageGui_UIC_SRCS})
|
||||
|
||||
SET(ImageGui_SRCS
|
||||
# ${ImageGui_MOC_SRCS}
|
||||
# ${ImageGui_QRC_SRCS}
|
||||
${ImageGui_UIC_HDRS}
|
||||
AppImageGui.cpp
|
||||
AppImageGuiPy.cpp
|
||||
Command.cpp
|
||||
ImageOrientationDialog.cpp
|
||||
ImageOrientationDialog.h
|
||||
ViewProviderImagePlane.cpp
|
||||
ViewProviderImagePlane.h
|
||||
GLImageBox.cpp
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include "ImageOrientationDialog.h"
|
||||
|
||||
//#include <Mod/Image/App/CaptureClass.h>
|
||||
|
||||
|
@ -120,6 +121,14 @@ void CmdCreateImagePlane::activated(int iMsg)
|
|||
return;
|
||||
}
|
||||
|
||||
// ask user for orientation
|
||||
ImageOrientationDialog Dlg;
|
||||
|
||||
if (Dlg.exec() != QDialog::Accepted)
|
||||
return; // canceled
|
||||
Base::Vector3d p = Dlg.Pos.getPosition();
|
||||
Base::Rotation r = Dlg.Pos.getRotation();
|
||||
|
||||
std::string FeatName = getUniqueObjectName("ImagePlane");
|
||||
|
||||
openCommand("Create ImagePlane");
|
||||
|
@ -127,6 +136,9 @@ void CmdCreateImagePlane::activated(int iMsg)
|
|||
doCommand(Doc,"App.activeDocument().%s.ImageFile = '%s'",FeatName.c_str(),(const char*)s.toUtf8());
|
||||
doCommand(Doc,"App.activeDocument().%s.XSize = %d",FeatName.c_str(),impQ.width () );
|
||||
doCommand(Doc,"App.activeDocument().%s.YSize = %d",FeatName.c_str(),impQ.height() );
|
||||
doCommand(Doc,"App.activeDocument().%s.Placement = App.Placement(App.Vector(%f,%f,%f),App.Rotation(%f,%f,%f,%f))"
|
||||
,FeatName.c_str(),p.x,p.y,p.z,r[0],r[1],r[2],r[3]);
|
||||
commitCommand();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
122
src/Mod/Image/Gui/ImageOrientationDialog.cpp
Normal file
122
src/Mod/Image/Gui/ImageOrientationDialog.cpp
Normal file
|
@ -0,0 +1,122 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2013 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <QPixmap>
|
||||
# include <QDialog>
|
||||
#endif
|
||||
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Base/Tools.h>
|
||||
|
||||
#include "ui_ImageOrientationDialog.h"
|
||||
#include "ImageOrientationDialog.h"
|
||||
|
||||
using namespace ImageGui;
|
||||
|
||||
ImageOrientationDialog::ImageOrientationDialog()
|
||||
: QDialog(Gui::getMainWindow()), ui(new Ui_ImageOrientationDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
onPreview();
|
||||
|
||||
connect(ui->Reverse_checkBox, SIGNAL(clicked(bool)), this, SLOT(onPreview()));
|
||||
connect(ui->XY_radioButton , SIGNAL(clicked(bool)), this, SLOT(onPreview()));
|
||||
connect(ui->XZ_radioButton , SIGNAL(clicked(bool)), this, SLOT(onPreview()));
|
||||
connect(ui->YZ_radioButton , SIGNAL(clicked(bool)), this, SLOT(onPreview()));
|
||||
}
|
||||
|
||||
ImageOrientationDialog::~ImageOrientationDialog()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ImageOrientationDialog::accept()
|
||||
{
|
||||
double offset = ui->Offset_doubleSpinBox->value();
|
||||
bool reverse = ui->Reverse_checkBox->isChecked();
|
||||
if (ui->XY_radioButton->isChecked()) {
|
||||
if (reverse) {
|
||||
Pos = Base::Placement(Base::Vector3d(0,0,offset),Base::Rotation(-1.0,0.0,0.0,0.0));
|
||||
DirType = 1;
|
||||
}
|
||||
else {
|
||||
Pos = Base::Placement(Base::Vector3d(0,0,offset),Base::Rotation());
|
||||
DirType = 0;
|
||||
}
|
||||
}
|
||||
else if (ui->XZ_radioButton->isChecked()) {
|
||||
if (reverse) {
|
||||
Pos = Base::Placement(Base::Vector3d(0,offset,0),Base::Rotation(Base::Vector3d(0,sqrt(2.0)/2.0,sqrt(2.0)/2.0),M_PI));
|
||||
DirType = 3;
|
||||
}
|
||||
else {
|
||||
Pos = Base::Placement(Base::Vector3d(0,offset,0),Base::Rotation(Base::Vector3d(-1,0,0),1.5*M_PI));
|
||||
DirType = 2;
|
||||
}
|
||||
}
|
||||
else if (ui->YZ_radioButton->isChecked()) {
|
||||
if (reverse) {
|
||||
Pos = Base::Placement(Base::Vector3d(offset,0,0),Base::Rotation(-0.5,0.5,0.5,-0.5));
|
||||
DirType = 5;
|
||||
}
|
||||
else {
|
||||
Pos = Base::Placement(Base::Vector3d(offset,0,0),Base::Rotation(0.5,0.5,0.5,0.5));
|
||||
DirType = 4;
|
||||
}
|
||||
}
|
||||
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void ImageOrientationDialog::onPreview()
|
||||
{
|
||||
std::string icon;
|
||||
bool reverse = ui->Reverse_checkBox->isChecked();
|
||||
if (ui->XY_radioButton->isChecked()) {
|
||||
if (reverse)
|
||||
icon = "view-bottom";
|
||||
else
|
||||
icon = "view-top";
|
||||
}
|
||||
else if (ui->XZ_radioButton->isChecked()) {
|
||||
if (reverse)
|
||||
icon = "view-rear";
|
||||
else
|
||||
icon = "view-front";
|
||||
}
|
||||
else if (ui->YZ_radioButton->isChecked()) {
|
||||
if (reverse)
|
||||
icon = "view-left";
|
||||
else
|
||||
icon = "view-right";
|
||||
}
|
||||
|
||||
ui->previewLabel->setPixmap(
|
||||
Gui::BitmapFactory().pixmapFromSvg(icon.c_str(),
|
||||
ui->previewLabel->size()));
|
||||
}
|
||||
|
||||
#include "moc_ImageOrientationDialog.cpp"
|
54
src/Mod/Image/Gui/ImageOrientationDialog.h
Normal file
54
src/Mod/Image/Gui/ImageOrientationDialog.h
Normal file
|
@ -0,0 +1,54 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2013 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef IMAGEGUI_IMAGEORIENTATIONDIALOG_H
|
||||
#define IMAGEGUI_IMAGEORIENTATIONDIALOG_H
|
||||
|
||||
#include <Base/Placement.h>
|
||||
#include <QDialog>
|
||||
|
||||
namespace ImageGui {
|
||||
|
||||
class Ui_ImageOrientationDialog;
|
||||
class ImageOrientationDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ImageOrientationDialog();
|
||||
~ImageOrientationDialog();
|
||||
|
||||
Base::Placement Pos;
|
||||
int DirType;
|
||||
|
||||
void accept();
|
||||
|
||||
protected Q_SLOTS:
|
||||
void onPreview();
|
||||
|
||||
private:
|
||||
Ui_ImageOrientationDialog* ui;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // IMAGEGUI_IMAGEORIENTATIONDIALOG_H
|
150
src/Mod/Image/Gui/ImageOrientationDialog.ui
Normal file
150
src/Mod/Image/Gui/ImageOrientationDialog.ui
Normal file
|
@ -0,0 +1,150 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ImageGui::ImageOrientationDialog</class>
|
||||
<widget class="QDialog" name="ImageGui::ImageOrientationDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>178</width>
|
||||
<height>201</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Choose orientation</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Image plane</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="XY_radioButton">
|
||||
<property name="text">
|
||||
<string>XY-Plane</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="XZ_radioButton">
|
||||
<property name="text">
|
||||
<string>XZ-Plane</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="YZ_radioButton">
|
||||
<property name="text">
|
||||
<string>YZ-Plane</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="previewLabel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>48</width>
|
||||
<height>48</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>48</width>
|
||||
<height>48</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Preview</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="Reverse_checkBox">
|
||||
<property name="text">
|
||||
<string>Reverse direction</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Offset:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="Offset_doubleSpinBox">
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-999999999.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>999999999.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>10.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>ImageGui::ImageOrientationDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>ImageGui::ImageOrientationDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
Loading…
Reference in New Issue
Block a user