From 50c9ea219d8552f809a7c7846ed8f7c3ee6c29a7 Mon Sep 17 00:00:00 2001 From: jrheinlaender Date: Mon, 25 Mar 2013 19:45:37 +0430 Subject: [PATCH] Moved Gui/InputVector,Placement,Transform from float to double --- src/Gui/InputVector.cpp | 56 +++++++++---------- src/Gui/InputVector.h | 86 +++++++++++++++--------------- src/Gui/Placement.cpp | 32 +++++------ src/Gui/Placement.h | 2 +- src/Gui/Transform.cpp | 8 +-- src/Gui/Transform.h | 2 +- src/Mod/Part/Gui/CommandSimple.cpp | 6 +-- src/Mod/Part/Gui/DlgPrimitives.cpp | 8 +-- src/Mod/Part/Gui/DlgRevolution.cpp | 8 +-- src/Mod/Part/Gui/DlgRevolution.h | 2 +- 10 files changed, 105 insertions(+), 105 deletions(-) diff --git a/src/Gui/InputVector.cpp b/src/Gui/InputVector.cpp index de8683dfc..58359f988 100644 --- a/src/Gui/InputVector.cpp +++ b/src/Gui/InputVector.cpp @@ -105,10 +105,10 @@ void LocationWidget::retranslateUi() dValue->setCurrentIndex(2); - // Vector3f declared to use with QVariant see Gui/propertyeditor/PropertyItem.h - dValue->setItemData(0, QVariant::fromValue(Base::Vector3f(1,0,0))); - dValue->setItemData(1, QVariant::fromValue(Base::Vector3f(0,1,0))); - dValue->setItemData(2, QVariant::fromValue(Base::Vector3f(0,0,1))); + // Vector3d declared to use with QVariant see Gui/propertyeditor/PropertyItem.h + dValue->setItemData(0, QVariant::fromValue(Base::Vector3d(1,0,0))); + dValue->setItemData(1, QVariant::fromValue(Base::Vector3d(0,1,0))); + dValue->setItemData(2, QVariant::fromValue(Base::Vector3d(0,0,1))); } else { dValue->setItemText(0, QApplication::translate("Gui::LocationDialog", "X")); @@ -119,21 +119,21 @@ void LocationWidget::retranslateUi() } } -Base::Vector3f LocationWidget::getPosition() const +Base::Vector3d LocationWidget::getPosition() const { - return Base::Vector3f((float)this->xValue->value(), - (float)this->yValue->value(), - (float)this->zValue->value()); + return Base::Vector3d(this->xValue->value(), + this->yValue->value(), + this->zValue->value()); } -void LocationWidget::setPosition(const Base::Vector3f& v) +void LocationWidget::setPosition(const Base::Vector3d& v) { this->xValue->setValue(v.x); this->yValue->setValue(v.y); this->zValue->setValue(v.z); } -void LocationWidget::setDirection(const Base::Vector3f& dir) +void LocationWidget::setDirection(const Base::Vector3d& dir) { if (dir.Length() < FLT_EPSILON) { return; @@ -142,8 +142,8 @@ void LocationWidget::setDirection(const Base::Vector3f& dir) // check if the user-defined direction is already there for (int i=0; icount()-1; i++) { QVariant data = dValue->itemData (i); - if (data.canConvert()) { - const Base::Vector3f val = data.value(); + if (data.canConvert()) { + const Base::Vector3d val = data.value(); if (val == dir) { dValue->setCurrentIndex(i); return; @@ -157,31 +157,31 @@ void LocationWidget::setDirection(const Base::Vector3f& dir) .arg(dir.y) .arg(dir.z); dValue->insertItem(dValue->count()-1, display, - QVariant::fromValue(dir)); + QVariant::fromValue(dir)); dValue->setCurrentIndex(dValue->count()-2); } -Base::Vector3f LocationWidget::getDirection() const +Base::Vector3d LocationWidget::getDirection() const { QVariant data = dValue->itemData (this->dValue->currentIndex()); - if (data.canConvert()) { - return data.value(); + if (data.canConvert()) { + return data.value(); } else { - return Base::Vector3f(0,0,1); + return Base::Vector3d(0,0,1); } } -Base::Vector3f LocationWidget::getUserDirection(bool* ok) const +Base::Vector3d LocationWidget::getUserDirection(bool* ok) const { Gui::Dialog::Ui_InputVector iv; QDialog dlg(const_cast(this)); iv.setupUi(&dlg); - Base::Vector3f dir; + Base::Vector3d dir; if (dlg.exec()) { - dir.x = (float)iv.vectorX->value(); - dir.y = (float)iv.vectorY->value(); - dir.z = (float)iv.vectorZ->value(); + dir.x = iv.vectorX->value(); + dir.y = iv.vectorY->value(); + dir.z = iv.vectorZ->value(); if (ok) *ok = true; } else { @@ -196,7 +196,7 @@ void LocationWidget::on_direction_activated(int index) // last item is selected to define direction by user if (index+1 == dValue->count()) { bool ok; - Base::Vector3f dir = this->getUserDirection(&ok); + Base::Vector3d dir = this->getUserDirection(&ok); if (ok) { if (dir.Length() < FLT_EPSILON) { QMessageBox::critical(this, LocationDialog::tr("Wrong direction"), @@ -220,16 +220,16 @@ LocationDialog::~LocationDialog() { } -Base::Vector3f LocationDialog::getUserDirection(bool* ok) const +Base::Vector3d LocationDialog::getUserDirection(bool* ok) const { Gui::Dialog::Ui_InputVector iv; QDialog dlg(const_cast(this)); iv.setupUi(&dlg); - Base::Vector3f dir; + Base::Vector3d dir; if (dlg.exec()) { - dir.x = (float)iv.vectorX->value(); - dir.y = (float)iv.vectorY->value(); - dir.z = (float)iv.vectorZ->value(); + dir.x = iv.vectorX->value(); + dir.y = iv.vectorY->value(); + dir.z = iv.vectorZ->value(); if (ok) *ok = true; } else { diff --git a/src/Gui/InputVector.h b/src/Gui/InputVector.h index bdb9036d9..bd9d41f99 100644 --- a/src/Gui/InputVector.h +++ b/src/Gui/InputVector.h @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include @@ -46,11 +46,11 @@ public: virtual ~LocationWidget(); QSize sizeHint() const; - Base::Vector3f getPosition() const; - void setPosition(const Base::Vector3f&); - void setDirection(const Base::Vector3f& dir); - Base::Vector3f getDirection() const; - Base::Vector3f getUserDirection(bool* ok=0) const; + Base::Vector3d getPosition() const; + void setPosition(const Base::Vector3d&); + void setDirection(const Base::Vector3d& dir); + Base::Vector3d getDirection() const; + Base::Vector3d getUserDirection(bool* ok=0) const; private Q_SLOTS: void on_direction_activated(int); @@ -90,8 +90,8 @@ private Q_SLOTS: void on_direction_activated(int); public: - virtual Base::Vector3f getDirection() const = 0; - Base::Vector3f getUserDirection(bool* ok=0) const; + virtual Base::Vector3d getDirection() const = 0; + Base::Vector3d getUserDirection(bool* ok=0) const; private: virtual void directionActivated(int) = 0; @@ -135,10 +135,10 @@ public: this->direction->setCurrentIndex(2); - // Vector3f declared to use with QVariant see Gui/propertyeditor/PropertyItem.h - this->direction->setItemData(0, QVariant::fromValue(Base::Vector3f(1,0,0))); - this->direction->setItemData(1, QVariant::fromValue(Base::Vector3f(0,1,0))); - this->direction->setItemData(2, QVariant::fromValue(Base::Vector3f(0,0,1))); + // Vector3d declared to use with QVariant see Gui/propertyeditor/PropertyItem.h + this->direction->setItemData(0, QVariant::fromValue(Base::Vector3d(1,0,0))); + this->direction->setItemData(1, QVariant::fromValue(Base::Vector3d(0,1,0))); + this->direction->setItemData(2, QVariant::fromValue(Base::Vector3d(0,0,1))); } else { this->direction->setItemText(0, QApplication::translate("Gui::LocationDialog", "X", 0, @@ -153,21 +153,21 @@ public: } } - Base::Vector3f getPosition() const + Base::Vector3d getPosition() const { - return Base::Vector3f((float)this->xPos->value(), - (float)this->yPos->value(), - (float)this->zPos->value()); + return Base::Vector3d(this->xPos->value(), + this->yPos->value(), + this->zPos->value()); } - Base::Vector3f getDirection() const + Base::Vector3d getDirection() const { QVariant data = this->direction->itemData (this->direction->currentIndex()); - if (data.canConvert()) { - return data.value(); + if (data.canConvert()) { + return data.value(); } else { - return Base::Vector3f(0,0,1); + return Base::Vector3d(0,0,1); } } @@ -188,7 +188,7 @@ private: // last item is selected to define direction by user if (index+1 == this->direction->count()) { bool ok; - Base::Vector3f dir = this->getUserDirection(&ok); + Base::Vector3d dir = this->getUserDirection(&ok); if (ok) { if (dir.Length() < FLT_EPSILON) { QMessageBox::critical(this, LocationDialog::tr("Wrong direction"), @@ -199,8 +199,8 @@ private: // check if the user-defined direction is already there for (int i=0; idirection->count()-1; i++) { QVariant data = this->direction->itemData (i); - if (data.canConvert()) { - const Base::Vector3f val = data.value(); + if (data.canConvert()) { + const Base::Vector3d val = data.value(); if (val == dir) { this->direction->setCurrentIndex(i); return; @@ -214,7 +214,7 @@ private: .arg(dir.y) .arg(dir.z); this->direction->insertItem(this->direction->count()-1, display, - QVariant::fromValue(dir)); + QVariant::fromValue(dir)); this->direction->setCurrentIndex(this->direction->count()-2); } } @@ -257,10 +257,10 @@ public: this->direction->setCurrentIndex(2); - // Vector3f declared to use with QVariant see Gui/propertyeditor/PropertyItem.h - this->direction->setItemData(0, QVariant::fromValue(Base::Vector3f(1,0,0))); - this->direction->setItemData(1, QVariant::fromValue(Base::Vector3f(0,1,0))); - this->direction->setItemData(2, QVariant::fromValue(Base::Vector3f(0,0,1))); + // Vector3d declared to use with QVariant see Gui/propertyeditor/PropertyItem.h + this->direction->setItemData(0, QVariant::fromValue(Base::Vector3d(1,0,0))); + this->direction->setItemData(1, QVariant::fromValue(Base::Vector3d(0,1,0))); + this->direction->setItemData(2, QVariant::fromValue(Base::Vector3d(0,0,1))); } else { this->direction->setItemText(0, QApplication::translate("Gui::LocationDialog", "X", 0, @@ -275,33 +275,33 @@ public: } } - void setPosition(const Base::Vector3f& v) + void setPosition(const Base::Vector3d& v) { this->xPos->setValue(v.x); this->yPos->setValue(v.y); this->zPos->setValue(v.z); } - Base::Vector3f getPosition() const + Base::Vector3d getPosition() const { - return Base::Vector3f((float)this->xPos->value(), - (float)this->yPos->value(), - (float)this->zPos->value()); + return Base::Vector3d(this->xPos->value(), + this->yPos->value(), + this->zPos->value()); } - Base::Vector3f getDirection() const + Base::Vector3d getDirection() const { QVariant data = this->direction->itemData (this->direction->currentIndex()); - if (data.canConvert()) { - return data.value(); + if (data.canConvert()) { + return data.value(); } else { - return Base::Vector3f(0,0,1); + return Base::Vector3d(0,0,1); } } public: - void setDirection(const Base::Vector3f& dir) + void setDirection(const Base::Vector3d& dir) { if (dir.Length() < FLT_EPSILON) { return; @@ -310,8 +310,8 @@ public: // check if the user-defined direction is already there for (int i=0; idirection->count()-1; i++) { QVariant data = this->direction->itemData (i); - if (data.canConvert()) { - const Base::Vector3f val = data.value(); + if (data.canConvert()) { + const Base::Vector3d val = data.value(); if (val == dir) { this->direction->setCurrentIndex(i); return; @@ -325,7 +325,7 @@ public: .arg(dir.y) .arg(dir.z); this->direction->insertItem(this->direction->count()-1, display, - QVariant::fromValue(dir)); + QVariant::fromValue(dir)); this->direction->setCurrentIndex(this->direction->count()-2); } bool directionActivated(LocationDialog* dlg, int index) @@ -333,7 +333,7 @@ public: // last item is selected to define direction by user if (index+1 == this->direction->count()) { bool ok; - Base::Vector3f dir = dlg->getUserDirection(&ok); + Base::Vector3d dir = dlg->getUserDirection(&ok); if (ok) { if (dir.Length() < FLT_EPSILON) { QMessageBox::critical(dlg, LocationDialog::tr("Wrong direction"), @@ -368,7 +368,7 @@ public: // no need to delete child widgets, Qt does it all for us } - Base::Vector3f getDirection() const + Base::Vector3d getDirection() const { return ui.getDirection(); } diff --git a/src/Gui/Placement.cpp b/src/Gui/Placement.cpp index 5697814e9..a6e2e9f0e 100644 --- a/src/Gui/Placement.cpp +++ b/src/Gui/Placement.cpp @@ -22,7 +22,7 @@ #include "PreCompiled.h" -#include +#include #include #include "Placement.h" @@ -314,7 +314,7 @@ void Placement::directionActivated(int index) } } -Base::Vector3f Placement::getDirection() const +Base::Vector3d Placement::getDirection() const { return ui->getDirection(); } @@ -343,11 +343,11 @@ void Placement::setPlacementData(const Base::Placement& p) Base::Vector3d axis; p.getRotation().getValue(axis, angle); ui->angle->setValue(angle*180.0/D_PI); - Base::Vector3f dir((float)axis.x,(float)axis.y,(float)axis.z); + Base::Vector3d dir(axis.x,axis.y,axis.z); for (int i=0; idirection->count()-1; i++) { QVariant data = ui->direction->itemData (i); - if (data.canConvert()) { - const Base::Vector3f val = data.value(); + if (data.canConvert()) { + const Base::Vector3d val = data.value(); if (val == dir) { ui->direction->setCurrentIndex(i); newitem = false; @@ -363,7 +363,7 @@ void Placement::setPlacementData(const Base::Placement& p) .arg(dir.y) .arg(dir.z); ui->direction->insertItem(ui->direction->count()-1, display, - QVariant::fromValue(dir)); + QVariant::fromValue(dir)); ui->direction->setCurrentIndex(ui->direction->count()-2); } signalMapper->blockSignals(false); @@ -386,7 +386,7 @@ Base::Placement Placement::getPlacementData() const cnt = Base::Vector3d(ui->xCnt->value(),ui->yCnt->value(),ui->zCnt->value()); if (index == 0) { - Base::Vector3f dir = getDirection(); + Base::Vector3d dir = getDirection(); rot.setValue(Base::Vector3d(dir.x,dir.y,dir.z),ui->angle->value()*D_PI/180.0); } else if (index == 1) { @@ -416,11 +416,11 @@ void Placement::changeEvent(QEvent *e) DockablePlacement::DockablePlacement(QWidget* parent, Qt::WFlags fl) : Placement(parent, fl) { - Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance(); + Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance(); QDockWidget* dw = pDockMgr->addDockWindow(QT_TR_NOOP("Placement"), this, Qt::BottomDockWidgetArea); - dw->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable); - dw->show(); + dw->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable); + dw->show(); } DockablePlacement::~DockablePlacement() @@ -429,17 +429,17 @@ DockablePlacement::~DockablePlacement() void DockablePlacement::accept() { - // closes the dock window - Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance(); - pDockMgr->removeDockWindow(this); + // closes the dock window + Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance(); + pDockMgr->removeDockWindow(this); Placement::accept(); } void DockablePlacement::reject() { - // closes the dock window - Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance(); - pDockMgr->removeDockWindow(this); + // closes the dock window + Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance(); + pDockMgr->removeDockWindow(this); Placement::reject(); } diff --git a/src/Gui/Placement.h b/src/Gui/Placement.h index 233284d1a..73fe656dd 100644 --- a/src/Gui/Placement.h +++ b/src/Gui/Placement.h @@ -50,7 +50,7 @@ public: void accept(); void reject(); - Base::Vector3f getDirection() const; + Base::Vector3d getDirection() const; void setPlacement(const Base::Placement&); Base::Placement getPlacement() const; void showDefaultButtons(bool); diff --git a/src/Gui/Transform.cpp b/src/Gui/Transform.cpp index d04cf9141..608e13e65 100644 --- a/src/Gui/Transform.cpp +++ b/src/Gui/Transform.cpp @@ -278,7 +278,7 @@ void DefaultTransformStrategy::onSelectionChanged(const Gui::SelectionChanges& m } if (!filter.empty()) { - std::set diff; + std::set diff; std::insert_iterator< std::set > biit(diff, diff.begin()); std::set_difference(update_selection.begin(), update_selection.end(), filter.begin(), filter.end(), biit); @@ -286,7 +286,7 @@ void DefaultTransformStrategy::onSelectionChanged(const Gui::SelectionChanges& m } // reset transform for all deselected objects - std::vector diff; + std::vector diff; std::back_insert_iterator< std::vector > biit(diff); std::set_difference(selection.begin(), selection.end(), update_selection.begin(), update_selection.end(), biit); @@ -408,7 +408,7 @@ void Transform::directionActivated(int index) } } -Base::Vector3f Transform::getDirection() const +Base::Vector3d Transform::getDirection() const { return ui->getDirection(); } @@ -424,7 +424,7 @@ Base::Placement Transform::getPlacementData() const cnt = Base::Vector3d(ui->xCnt->value(),ui->yCnt->value(),ui->zCnt->value()); if (index == 0) { - Base::Vector3f dir = getDirection(); + Base::Vector3d dir = getDirection(); rot.setValue(Base::Vector3d(dir.x,dir.y,dir.z),ui->angle->value()*D_PI/180.0); } else if (index == 1) { diff --git a/src/Gui/Transform.h b/src/Gui/Transform.h index d43eee0e4..042d4f691 100644 --- a/src/Gui/Transform.h +++ b/src/Gui/Transform.h @@ -79,7 +79,7 @@ public: void setTransformStrategy(TransformStrategy* ts); protected: - Base::Vector3f getDirection() const; + Base::Vector3d getDirection() const; void changeEvent(QEvent *e); public Q_SLOTS: diff --git a/src/Mod/Part/Gui/CommandSimple.cpp b/src/Mod/Part/Gui/CommandSimple.cpp index 252a3b1d0..23834e429 100644 --- a/src/Mod/Part/Gui/CommandSimple.cpp +++ b/src/Mod/Part/Gui/CommandSimple.cpp @@ -25,8 +25,8 @@ #ifndef _PreComp_ # include # include -# include -# include +# include +# include # include #endif @@ -66,7 +66,7 @@ void CmdPartSimpleCylinder::activated(int iMsg) { PartGui::DlgPartCylinderImp dlg(Gui::getMainWindow()); if (dlg.exec()== QDialog::Accepted) { - Base::Vector3f dir = dlg.getDirection(); + Base::Vector3d dir = dlg.getDirection(); openCommand("Create Part Cylinder"); doCommand(Doc,"from FreeCAD import Base"); doCommand(Doc,"import Part"); diff --git a/src/Mod/Part/Gui/DlgPrimitives.cpp b/src/Mod/Part/Gui/DlgPrimitives.cpp index 7ef822edf..daabaad51 100644 --- a/src/Mod/Part/Gui/DlgPrimitives.cpp +++ b/src/Mod/Part/Gui/DlgPrimitives.cpp @@ -641,8 +641,8 @@ void Location::pickCallback(void * ud, SoEventCallback * n) SbVec3f pnt = point->getPoint(); SbVec3f nor = point->getNormal(); Location* dlg = reinterpret_cast(ud); - dlg->ui.loc->setPosition(Base::Vector3f(pnt[0],pnt[1],pnt[2])); - dlg->ui.loc->setDirection(Base::Vector3f(nor[0],nor[1],nor[2])); + dlg->ui.loc->setPosition(Base::Vector3d(pnt[0],pnt[1],pnt[2])); + dlg->ui.loc->setDirection(Base::Vector3d(nor[0],nor[1],nor[2])); n->setHandled(); } } @@ -664,7 +664,7 @@ void Location::pickCallback(void * ud, SoEventCallback * n) QString Location::toPlacement() const { - Base::Vector3f d = ui.loc->getDirection(); + Base::Vector3d d = ui.loc->getDirection(); gp_Dir dir = gp_Dir(d.x,d.y,d.z); gp_Pnt pnt = gp_Pnt(0.0,0.0,0.0); gp_Ax3 ax3; @@ -707,7 +707,7 @@ QString Location::toPlacement() const Trf.GetRotation(theAxis,theAngle); Base::Rotation rot(Base::convertTo(theAxis), theAngle); - Base::Vector3f loc = ui.loc->getPosition(); + Base::Vector3d loc = ui.loc->getPosition(); return QString::fromAscii("Base.Placement(Base.Vector(%1,%2,%3),Base.Rotation(%4,%5,%6,%7))") .arg(loc.x,0,'f',2) diff --git a/src/Mod/Part/Gui/DlgRevolution.cpp b/src/Mod/Part/Gui/DlgRevolution.cpp index d0a04668d..221fdcb60 100644 --- a/src/Mod/Part/Gui/DlgRevolution.cpp +++ b/src/Mod/Part/Gui/DlgRevolution.cpp @@ -121,7 +121,7 @@ void DlgRevolution::directionActivated(int index) ui->directionActivated(this, index); } -Base::Vector3f DlgRevolution::getDirection() const +Base::Vector3d DlgRevolution::getDirection() const { return ui->getDirection(); } @@ -180,7 +180,7 @@ void DlgRevolution::accept() shape = (*it)->data(0, Qt::UserRole).toString(); type = QString::fromAscii("Part::Revolution"); name = QString::fromAscii(activeDoc->getUniqueObjectName("Revolve").c_str()); - Base::Vector3f axis = this->getDirection(); + Base::Vector3d axis = this->getDirection(); QString code = QString::fromAscii( "FreeCAD.ActiveDocument.addObject(\"%1\",\"%2\")\n" @@ -222,8 +222,8 @@ void DlgRevolution::onSelectionChanged(const Gui::SelectionChanges& msg) { if (msg.Type == Gui::SelectionChanges::AddSelection) { if (filter && filter->canSelect) { - ui->setPosition (Base::convertTo(filter->loc)); - ui->setDirection(Base::convertTo(filter->dir)); + ui->setPosition (Base::convertTo(filter->loc)); + ui->setDirection(Base::convertTo(filter->dir)); } } } diff --git a/src/Mod/Part/Gui/DlgRevolution.h b/src/Mod/Part/Gui/DlgRevolution.h index 8e4ebba50..7f3d648b8 100644 --- a/src/Mod/Part/Gui/DlgRevolution.h +++ b/src/Mod/Part/Gui/DlgRevolution.h @@ -40,7 +40,7 @@ public: ~DlgRevolution(); void accept(); - Base::Vector3f getDirection() const; + Base::Vector3d getDirection() const; protected: void changeEvent(QEvent *e);