More suggestions for float->double move from Gui subdirectory
This commit is contained in:
parent
c3bd10430b
commit
bcdc353375
|
@ -30,7 +30,7 @@
|
|||
|
||||
#include "DlgDisplayPropertiesImp.h"
|
||||
#include "DlgMaterialPropertiesImp.h"
|
||||
#include "DockWindowManager.h"
|
||||
#include "DockWindowManager.h"
|
||||
#include "View3DInventorViewer.h"
|
||||
#include "View3DInventor.h"
|
||||
#include "Command.h"
|
||||
|
@ -84,14 +84,14 @@ DlgDisplayPropertiesImp::DlgDisplayPropertiesImp( QWidget* parent, Qt::WFlags fl
|
|||
setLineWidth(views);
|
||||
setTransparency(views);
|
||||
setLineTransparency(views);
|
||||
|
||||
// embed this dialog into a dockable widget container
|
||||
Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance();
|
||||
QDockWidget* dw = pDockMgr->addDockWindow("Display properties", this, Qt::AllDockWidgetAreas);
|
||||
dw->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable);
|
||||
dw->setAllowedAreas(Qt::DockWidgetAreas());
|
||||
dw->setFloating(true);
|
||||
dw->show();
|
||||
|
||||
// embed this dialog into a dockable widget container
|
||||
Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance();
|
||||
QDockWidget* dw = pDockMgr->addDockWindow("Display properties", this, Qt::AllDockWidgetAreas);
|
||||
dw->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable);
|
||||
dw->setAllowedAreas(Qt::DockWidgetAreas());
|
||||
dw->setFloating(true);
|
||||
dw->show();
|
||||
|
||||
Gui::Selection().Attach(this);
|
||||
|
||||
|
@ -189,7 +189,7 @@ void DlgDisplayPropertiesImp::slotChangedObject(const Gui::ViewProvider& obj,
|
|||
}
|
||||
}
|
||||
else if (prop.getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) {
|
||||
float value = static_cast<const App::PropertyFloat&>(prop).getValue();
|
||||
double value = static_cast<const App::PropertyFloat&>(prop).getValue();
|
||||
if (prop_name == "PointSize") {
|
||||
bool blocked = spinPointSize->blockSignals(true);
|
||||
spinPointSize->setValue((int)value);
|
||||
|
@ -203,17 +203,17 @@ void DlgDisplayPropertiesImp::slotChangedObject(const Gui::ViewProvider& obj,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the dock window this object is embedded into without destroying itself.
|
||||
*/
|
||||
void DlgDisplayPropertiesImp::reject()
|
||||
{
|
||||
// closes the dock window
|
||||
Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance();
|
||||
pDockMgr->removeDockWindow(this);
|
||||
QDialog::reject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the dock window this object is embedded into without destroying itself.
|
||||
*/
|
||||
void DlgDisplayPropertiesImp::reject()
|
||||
{
|
||||
// closes the dock window
|
||||
Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance();
|
||||
pDockMgr->removeDockWindow(this);
|
||||
QDialog::reject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a dialog that allows to modify the 'ShapeMaterial' property of all selected view providers.
|
||||
|
@ -325,7 +325,7 @@ void DlgDisplayPropertiesImp::on_spinPointSize_valueChanged(int pointsize)
|
|||
App::Property* prop = (*It)->getPropertyByName("PointSize");
|
||||
if (prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) {
|
||||
App::PropertyFloat* PointSize = (App::PropertyFloat*)prop;
|
||||
PointSize->setValue((float)pointsize);
|
||||
PointSize->setValue((double)pointsize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -340,7 +340,7 @@ void DlgDisplayPropertiesImp::on_spinLineWidth_valueChanged(int linewidth)
|
|||
App::Property* prop = (*It)->getPropertyByName("LineWidth");
|
||||
if (prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) {
|
||||
App::PropertyFloat* LineWidth = (App::PropertyFloat*)prop;
|
||||
LineWidth->setValue((float)linewidth);
|
||||
LineWidth->setValue((double)linewidth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -373,75 +373,75 @@ void DlgDisplayPropertiesImp::on_spinLineTransparency_valueChanged(int transpare
|
|||
|
||||
void DlgDisplayPropertiesImp::setDisplayModes(const std::vector<Gui::ViewProvider*>& views)
|
||||
{
|
||||
QStringList commonModes, modes;
|
||||
for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
|
||||
App::Property* prop = (*it)->getPropertyByName("DisplayMode");
|
||||
QStringList commonModes, modes;
|
||||
for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
|
||||
App::Property* prop = (*it)->getPropertyByName("DisplayMode");
|
||||
if (prop && prop->getTypeId() == App::PropertyEnumeration::getClassTypeId()) {
|
||||
App::PropertyEnumeration* display = static_cast<App::PropertyEnumeration*>(prop);
|
||||
if (!display->getEnums()) return;
|
||||
const std::vector<std::string>& value = display->getEnumVector();
|
||||
if (it == views.begin()) {
|
||||
for (std::vector<std::string>::const_iterator jt = value.begin(); jt != value.end(); ++jt)
|
||||
commonModes << QLatin1String(jt->c_str());
|
||||
}
|
||||
else {
|
||||
for (std::vector<std::string>::const_iterator jt = value.begin(); jt != value.end(); ++jt) {
|
||||
if (commonModes.contains(QLatin1String(jt->c_str())))
|
||||
modes << QLatin1String(jt->c_str());
|
||||
}
|
||||
|
||||
commonModes = modes;
|
||||
modes.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
changeMode->clear();
|
||||
changeMode->addItems(commonModes);
|
||||
changeMode->setDisabled(commonModes.isEmpty());
|
||||
|
||||
// find the display mode to activate
|
||||
for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
|
||||
App::Property* prop = (*it)->getPropertyByName("DisplayMode");
|
||||
App::PropertyEnumeration* display = static_cast<App::PropertyEnumeration*>(prop);
|
||||
if (!display->getEnums()) return;
|
||||
const std::vector<std::string>& value = display->getEnumVector();
|
||||
if (it == views.begin()) {
|
||||
for (std::vector<std::string>::const_iterator jt = value.begin(); jt != value.end(); ++jt)
|
||||
commonModes << QLatin1String(jt->c_str());
|
||||
}
|
||||
else {
|
||||
for (std::vector<std::string>::const_iterator jt = value.begin(); jt != value.end(); ++jt) {
|
||||
if (commonModes.contains(QLatin1String(jt->c_str())))
|
||||
modes << QLatin1String(jt->c_str());
|
||||
}
|
||||
|
||||
commonModes = modes;
|
||||
modes.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
changeMode->clear();
|
||||
changeMode->addItems(commonModes);
|
||||
changeMode->setDisabled(commonModes.isEmpty());
|
||||
|
||||
// find the display mode to activate
|
||||
for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
|
||||
App::Property* prop = (*it)->getPropertyByName("DisplayMode");
|
||||
if (prop && prop->getTypeId() == App::PropertyEnumeration::getClassTypeId()) {
|
||||
App::PropertyEnumeration* display = static_cast<App::PropertyEnumeration*>(prop);
|
||||
QString activeMode = QString::fromAscii(display->getValueAsString());
|
||||
int index = changeMode->findText(activeMode);
|
||||
if (index != -1) {
|
||||
changeMode->setCurrentIndex(index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
App::PropertyEnumeration* display = static_cast<App::PropertyEnumeration*>(prop);
|
||||
QString activeMode = QString::fromAscii(display->getValueAsString());
|
||||
int index = changeMode->findText(activeMode);
|
||||
if (index != -1) {
|
||||
changeMode->setCurrentIndex(index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DlgDisplayPropertiesImp::setMaterial(const std::vector<Gui::ViewProvider*>& views)
|
||||
{
|
||||
bool material = false;
|
||||
for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
|
||||
App::Property* prop = (*it)->getPropertyByName("ShapeMaterial");
|
||||
for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
|
||||
App::Property* prop = (*it)->getPropertyByName("ShapeMaterial");
|
||||
if (prop && prop->getTypeId() == App::PropertyMaterial::getClassTypeId()) {
|
||||
material = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
changeMaterial->setEnabled(material);
|
||||
buttonUserDefinedMaterial->setEnabled(material);
|
||||
}
|
||||
|
||||
changeMaterial->setEnabled(material);
|
||||
buttonUserDefinedMaterial->setEnabled(material);
|
||||
}
|
||||
|
||||
void DlgDisplayPropertiesImp::setColorPlot(const std::vector<Gui::ViewProvider*>& views)
|
||||
{
|
||||
bool material = false;
|
||||
for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
|
||||
App::Property* prop = (*it)->getPropertyByName("TextureMaterial");
|
||||
for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
|
||||
App::Property* prop = (*it)->getPropertyByName("TextureMaterial");
|
||||
if (prop && prop->getTypeId() == App::PropertyMaterial::getClassTypeId()) {
|
||||
material = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
buttonColorPlot->setEnabled(material);
|
||||
}
|
||||
|
||||
buttonColorPlot->setEnabled(material);
|
||||
}
|
||||
|
||||
void DlgDisplayPropertiesImp::fillupMaterials()
|
||||
|
@ -478,8 +478,8 @@ void DlgDisplayPropertiesImp::fillupMaterials()
|
|||
void DlgDisplayPropertiesImp::setShapeColor(const std::vector<Gui::ViewProvider*>& views)
|
||||
{
|
||||
bool shapeColor = false;
|
||||
for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
|
||||
App::Property* prop = (*it)->getPropertyByName("ShapeColor");
|
||||
for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
|
||||
App::Property* prop = (*it)->getPropertyByName("ShapeColor");
|
||||
if (prop && prop->getTypeId() == App::PropertyColor::getClassTypeId()) {
|
||||
App::Color c = static_cast<App::PropertyColor*>(prop)->getValue();
|
||||
QColor shape;
|
||||
|
@ -490,9 +490,9 @@ void DlgDisplayPropertiesImp::setShapeColor(const std::vector<Gui::ViewProvider*
|
|||
shapeColor = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
buttonColor->setEnabled(shapeColor);
|
||||
}
|
||||
|
||||
buttonColor->setEnabled(shapeColor);
|
||||
}
|
||||
|
||||
void DlgDisplayPropertiesImp::setLineColor(const std::vector<Gui::ViewProvider*>& views)
|
||||
|
@ -518,8 +518,8 @@ void DlgDisplayPropertiesImp::setLineColor(const std::vector<Gui::ViewProvider*>
|
|||
void DlgDisplayPropertiesImp::setPointSize(const std::vector<Gui::ViewProvider*>& views)
|
||||
{
|
||||
bool pointSize = false;
|
||||
for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
|
||||
App::Property* prop = (*it)->getPropertyByName("PointSize");
|
||||
for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
|
||||
App::Property* prop = (*it)->getPropertyByName("PointSize");
|
||||
if (prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) {
|
||||
bool blocked = spinPointSize->blockSignals(true);
|
||||
spinPointSize->setValue((int)static_cast<App::PropertyFloat*>(prop)->getValue());
|
||||
|
@ -527,16 +527,16 @@ void DlgDisplayPropertiesImp::setPointSize(const std::vector<Gui::ViewProvider*>
|
|||
pointSize = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
spinPointSize->setEnabled(pointSize);
|
||||
}
|
||||
|
||||
spinPointSize->setEnabled(pointSize);
|
||||
}
|
||||
|
||||
void DlgDisplayPropertiesImp::setLineWidth(const std::vector<Gui::ViewProvider*>& views)
|
||||
{
|
||||
bool lineWidth = false;
|
||||
for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
|
||||
App::Property* prop = (*it)->getPropertyByName("LineWidth");
|
||||
for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
|
||||
App::Property* prop = (*it)->getPropertyByName("LineWidth");
|
||||
if (prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) {
|
||||
bool blocked = spinLineWidth->blockSignals(true);
|
||||
spinLineWidth->setValue((int)static_cast<App::PropertyFloat*>(prop)->getValue());
|
||||
|
@ -544,16 +544,16 @@ void DlgDisplayPropertiesImp::setLineWidth(const std::vector<Gui::ViewProvider*>
|
|||
lineWidth = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
spinLineWidth->setEnabled(lineWidth);
|
||||
}
|
||||
|
||||
spinLineWidth->setEnabled(lineWidth);
|
||||
}
|
||||
|
||||
void DlgDisplayPropertiesImp::setTransparency(const std::vector<Gui::ViewProvider*>& views)
|
||||
{
|
||||
bool transparency = false;
|
||||
for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
|
||||
App::Property* prop = (*it)->getPropertyByName("Transparency");
|
||||
for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
|
||||
App::Property* prop = (*it)->getPropertyByName("Transparency");
|
||||
if (prop && prop->getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())) {
|
||||
bool blocked = spinTransparency->blockSignals(true);
|
||||
spinTransparency->setValue(static_cast<App::PropertyInteger*>(prop)->getValue());
|
||||
|
@ -565,10 +565,10 @@ void DlgDisplayPropertiesImp::setTransparency(const std::vector<Gui::ViewProvide
|
|||
transparency = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
spinTransparency->setEnabled(transparency);
|
||||
horizontalSlider->setEnabled(transparency);
|
||||
}
|
||||
|
||||
spinTransparency->setEnabled(transparency);
|
||||
horizontalSlider->setEnabled(transparency);
|
||||
}
|
||||
|
||||
void DlgDisplayPropertiesImp::setLineTransparency(const std::vector<Gui::ViewProvider*>& views)
|
||||
|
|
|
@ -882,7 +882,7 @@ QVariant PropertyVectorItem::value(const App::Property* prop) const
|
|||
|
||||
void PropertyVectorItem::setValue(const QVariant& value)
|
||||
{
|
||||
if (!value.canConvert<Base::Vector3f>())
|
||||
if (!value.canConvert<Base::Vector3d>())
|
||||
return;
|
||||
const Base::Vector3d& val = value.value<Base::Vector3d>();
|
||||
QString data = QString::fromAscii("(%1, %2, %3)")
|
||||
|
@ -919,32 +919,32 @@ QVariant PropertyVectorItem::editorData(QWidget *editor) const
|
|||
|
||||
double PropertyVectorItem::x() const
|
||||
{
|
||||
return data(1,Qt::EditRole).value<Base::Vector3f>().x;
|
||||
return data(1,Qt::EditRole).value<Base::Vector3d>().x;
|
||||
}
|
||||
|
||||
void PropertyVectorItem::setX(double x)
|
||||
{
|
||||
setData(QVariant::fromValue(Base::Vector3f(x, y(), z())));
|
||||
setData(QVariant::fromValue(Base::Vector3d(x, y(), z())));
|
||||
}
|
||||
|
||||
double PropertyVectorItem::y() const
|
||||
{
|
||||
return data(1,Qt::EditRole).value<Base::Vector3f>().y;
|
||||
return data(1,Qt::EditRole).value<Base::Vector3d>().y;
|
||||
}
|
||||
|
||||
void PropertyVectorItem::setY(double y)
|
||||
{
|
||||
setData(QVariant::fromValue(Base::Vector3f(x(), y, z())));
|
||||
setData(QVariant::fromValue(Base::Vector3d(x(), y, z())));
|
||||
}
|
||||
|
||||
double PropertyVectorItem::z() const
|
||||
{
|
||||
return data(1,Qt::EditRole).value<Base::Vector3f>().z;
|
||||
return data(1,Qt::EditRole).value<Base::Vector3d>().z;
|
||||
}
|
||||
|
||||
void PropertyVectorItem::setZ(double z)
|
||||
{
|
||||
setData(QVariant::fromValue(Base::Vector3f(x(), y(), z)));
|
||||
setData(QVariant::fromValue(Base::Vector3d(x(), y(), z)));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
|
|
|
@ -83,6 +83,7 @@ bool PropertyModel::setData(const QModelIndex& index, const QVariant & value, in
|
|||
if (data.type() == QVariant::Double && value.type() == QVariant::Double) {
|
||||
// since we store some properties as floats we get some round-off
|
||||
// errors here. Thus, we use an epsilon here.
|
||||
// NOTE: Since 0.14 PropertyFloat uses double precision, so this is maybe unnecessary now?
|
||||
double d = data.toDouble();
|
||||
double v = value.toDouble();
|
||||
if (fabs(d-v) > FLT_EPSILON)
|
||||
|
|
Loading…
Reference in New Issue
Block a user