| 1 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 2 |
/*************************************************************************** |
| 3 |
* Copyright (c) 2004 Werner Mayer <wmayer[at]users.sourceforge.net> * |
| 4 |
* * |
| 5 |
* This file is part of the FreeCAD CAx development system. * |
| 6 |
* * |
| 7 |
* This library is free software; you can redistribute it and/or * |
| 8 |
* modify it under the terms of the GNU Library General Public * |
| 9 |
* License as published by the Free Software Foundation; either * |
| 10 |
* version 2 of the License, or (at your option) any later version. * |
| 11 |
* * |
| 12 |
* This library is distributed in the hope that it will be useful, * |
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 15 |
* GNU Library General Public License for more details. * |
| 16 |
* * |
| 17 |
* You should have received a copy of the GNU Library General Public * |
| 18 |
* License along with this library; see the file COPYING.LIB. If not, * |
| 19 |
* write to the Free Software Foundation, Inc., 59 Temple Place, * |
| 20 |
* Suite 330, Boston, MA 02111-1307, USA * |
| 21 |
* * |
| 22 |
***************************************************************************/ |
| 23 |
|
| 24 |
|
| 25 |
#ifndef PROPERTYEDITORITEM_H |
| 26 |
#define PROPERTYEDITORITEM_H |
| 27 |
|
| 28 |
#include <QItemEditorFactory> |
| 29 |
#include <QObject> |
| 30 |
#include <QPointer> |
| 31 |
#include <QPushButton> |
| 32 |
#include <QItemEditorFactory> |
| 33 |
#include <vector> |
| 34 |
|
| 35 |
#include <App/PropertyStandard.h> |
| 36 |
#include <Base/Factory.h> |
| 37 |
#include <Base/Matrix.h> |
| 38 |
#include <Base/Placement.h> |
| 39 |
#include <Base/Quantity.h> |
| 40 |
#include <Base/Vector3D.h> |
| 41 |
#include <Base/UnitsApi.h> |
| 42 |
#include <Gui/ExpressionBinding.h> |
| 43 |
#include <Gui/MetaTypes.h> |
| 44 |
#include <Gui/Widgets.h> |
| 45 |
|
| 46 |
#include <FCGlobal.h> |
| 47 |
|
| 48 |
#ifdef Q_MOC_RUN |
| 49 |
Q_DECLARE_METATYPE(Base::Vector3f) |
| 50 |
Q_DECLARE_METATYPE(Base::Vector3d) |
| 51 |
Q_DECLARE_METATYPE(QList<Base::Vector3d>) |
| 52 |
Q_DECLARE_METATYPE(Base::Matrix4D) |
| 53 |
Q_DECLARE_METATYPE(Base::Placement) |
| 54 |
Q_DECLARE_METATYPE(Base::Rotation) |
| 55 |
Q_DECLARE_METATYPE(Base::Quantity) |
| 56 |
Q_DECLARE_METATYPE(QList<Base::Quantity>) |
| 57 |
#endif |
| 58 |
|
| 59 |
|
| 60 |
#define PROPERTYITEM_HEADER \ |
| 61 |
public: \ |
| 62 |
static void* create(void); \ |
| 63 |
static void init(void); |
| 64 |
|
| 65 |
#define PROPERTYITEM_SOURCE(_class_) \ |
| 66 |
void* _class_::create(void) \ |
| 67 |
{ \ |
| 68 |
return new _class_(); \ |
| 69 |
} \ |
| 70 |
void _class_::init(void) \ |
| 71 |
{ \ |
| 72 |
(void)new Gui::PropertyEditor::PropertyItemProducer<_class_>(#_class_); \ |
| 73 |
} |
| 74 |
|
| 75 |
namespace Gui |
| 76 |
{ |
| 77 |
|
| 78 |
namespace Dialog |
| 79 |
{ |
| 80 |
class TaskPlacement; |
| 81 |
class DlgPropertyLink; |
| 82 |
} // namespace Dialog |
| 83 |
|
| 84 |
namespace PropertyEditor |
| 85 |
{ |
| 86 |
|
| 87 |
class PropertyItem; |
| 88 |
class PropertyModel; |
| 89 |
class PropertyEditorWidget; |
| 90 |
|
| 91 |
enum class FrameOption : bool |
| 92 |
{ |
| 93 |
NoFrame = false, |
| 94 |
WithFrame = true |
| 95 |
}; |
| 96 |
/** |
| 97 |
* The PropertyItemFactory provides methods for the dynamic creation of property items. |
| 98 |
* \author Werner Mayer |
| 99 |
*/ |
| 100 |
class GuiExport PropertyItemFactory: public Base::Factory |
| 101 |
{ |
| 102 |
public: |
| 103 |
static PropertyItemFactory& instance(); |
| 104 |
|
| 105 |
PropertyItem* createPropertyItem(const char* sName) const; |
| 106 |
|
| 107 |
private: |
| 108 |
PropertyItemFactory() = default; |
| 109 |
~PropertyItemFactory() override = default; |
| 110 |
}; |
| 111 |
|
| 112 |
template<class CLASS> |
| 113 |
class PropertyItemProducer: public Base::AbstractProducer |
| 114 |
{ |
| 115 |
public: |
| 116 |
explicit PropertyItemProducer(const char* className) |
| 117 |
{ |
| 118 |
PropertyItemFactory::instance().AddProducer(className, this); |
| 119 |
} |
| 120 |
~PropertyItemProducer() override = default; |
| 121 |
void* Produce() const override |
| 122 |
{ |
| 123 |
return CLASS::create(); |
| 124 |
} |
| 125 |
}; |
| 126 |
|
| 127 |
class PropertyItemAttorney |
| 128 |
{ |
| 129 |
public: |
| 130 |
static QString toString(PropertyItem* item, const QVariant& v); |
| 131 |
}; |
| 132 |
|
| 133 |
class GuiExport PropertyItem: public QObject, public ExpressionBinding |
| 134 |
{ |
| 135 |
Q_OBJECT |
| 136 |
PROPERTYITEM_HEADER |
| 137 |
|
| 138 |
public: |
| 139 |
enum Column |
| 140 |
{ |
| 141 |
NameColumn = 0, |
| 142 |
ValueColumn = 1, |
| 143 |
ColumnCount |
| 144 |
}; |
| 145 |
|
| 146 |
~PropertyItem() override; |
| 147 |
|
| 148 |
/** Sets the current property objects. */ |
| 149 |
void setPropertyData(const std::vector<App::Property*>&); |
| 150 |
void updateData(); |
| 151 |
const std::vector<App::Property*>& getPropertyData() const; |
| 152 |
bool hasProperty(const App::Property*) const; |
| 153 |
virtual void assignProperty(const App::Property*); |
| 154 |
bool removeProperty(const App::Property*); |
| 155 |
bool renameProperty(const App::Property*); |
| 156 |
App::Property* getFirstProperty(); |
| 157 |
const App::Property* getFirstProperty() const; |
| 158 |
|
| 159 |
/** Creates the appropriate editor for this item and sets the editor to the value of |
| 160 |
* overrideValue(). */ |
| 161 |
virtual QWidget* createEditor( |
| 162 |
QWidget* parent, |
| 163 |
const std::function<void()>& method, |
| 164 |
FrameOption frameOption = FrameOption::NoFrame |
| 165 |
) const; |
| 166 |
virtual void setEditorData(QWidget* editor, const QVariant& data) const; |
| 167 |
virtual QVariant editorData(QWidget* editor) const; |
| 168 |
virtual bool isSeparator() const |
| 169 |
{ |
| 170 |
return false; |
| 171 |
} |
| 172 |
|
| 173 |
QWidget* createExpressionEditor(QWidget* parent, const std::function<void()>& method) const; |
| 174 |
void setExpressionEditorData(QWidget* editor, const QVariant& data) const; |
| 175 |
QVariant expressionEditorData(QWidget* editor) const; |
| 176 |
|
| 177 |
PropertyEditorWidget* createPropertyEditorWidget(QWidget* parent) const; |
| 178 |
|
| 179 |
/**override the bind functions to ensure we issue the propertyBound() call, which is then |
| 180 |
overloaded by childs which like to be informed of a binding*/ |
| 181 |
void bind(const App::Property& prop) override; |
| 182 |
void bind(const App::ObjectIdentifier& _path) override; |
| 183 |
virtual void propertyBound() |
| 184 |
{} |
| 185 |
QString expressionAsString() const; |
| 186 |
|
| 187 |
void setParent(PropertyItem* parent); |
| 188 |
PropertyItem* parent() const; |
| 189 |
void appendChild(PropertyItem* child); |
| 190 |
void insertChild(int, PropertyItem* child); |
| 191 |
void moveChild(int from, int to); |
| 192 |
void removeChildren(int from, int to); |
| 193 |
PropertyItem* takeChild(int); |
| 194 |
|
| 195 |
void setReadOnly(bool); |
| 196 |
bool isReadOnly() const; |
| 197 |
bool testStatus(App::Property::Status pos) const; |
| 198 |
void setDecimals(int); |
| 199 |
int decimals() const; |
| 200 |
|
| 201 |
void setLinked(bool); |
| 202 |
bool isLinked() const; |
| 203 |
|
| 204 |
bool isExpanded() const; |
| 205 |
void setExpanded(bool e); |
| 206 |
|
| 207 |
PropertyItem* child(int row); |
| 208 |
int childCount() const; |
| 209 |
int columnCount() const; |
| 210 |
QString propertyName() const; |
| 211 |
void setPropertyName(const QString& name, const QString& realName = QString()); |
| 212 |
void setPropertyValue(const QString&); |
| 213 |
virtual QVariant data(int column, int role) const; |
| 214 |
bool setData(const QVariant& value); |
| 215 |
Qt::ItemFlags flags(int column) const; |
| 216 |
virtual int row() const; |
| 217 |
void reset(); |
| 218 |
|
| 219 |
bool hasAnyExpression() const; |
| 220 |
|
| 221 |
protected: |
| 222 |
PropertyItem(); |
| 223 |
|
| 224 |
void setPropertyValue(const std::string& value); |
| 225 |
virtual QVariant displayName() const; |
| 226 |
virtual QVariant decoration(const QVariant&) const; |
| 227 |
virtual QVariant toolTip(const App::Property*) const; |
| 228 |
virtual QString toString(const QVariant&) const; |
| 229 |
virtual QVariant value(const App::Property*) const; |
| 230 |
virtual void setValue(const QVariant&); |
| 231 |
virtual void initialize(); |
| 232 |
|
| 233 |
// gets called when the bound expression is changed |
| 234 |
void onChange() override; |
| 235 |
|
| 236 |
private: |
| 237 |
QVariant dataPropertyName(int role) const; |
| 238 |
QVariant dataValue(int role) const; |
| 239 |
QString toString(const Py::Object&) const; |
| 240 |
QString asNone(const Py::Object&) const; |
| 241 |
QString asString(const Py::Object&) const; |
| 242 |
QString asSequence(const Py::Object&) const; |
| 243 |
QString asMapping(const Py::Object&) const; |
| 244 |
|
| 245 |
protected: |
| 246 |
QString propName; |
| 247 |
QString displayText; |
| 248 |
std::vector<App::Property*> propertyItems; |
| 249 |
PropertyItem* parentItem; |
| 250 |
QList<PropertyItem*> childItems; |
| 251 |
bool readonly; |
| 252 |
int precision; |
| 253 |
bool linked; |
| 254 |
bool expanded; |
| 255 |
|
| 256 |
friend class PropertyItemAttorney; |
| 257 |
}; |
| 258 |
|
| 259 |
/** |
| 260 |
* Change a string property. |
| 261 |
* \author Werner Mayer |
| 262 |
*/ |
| 263 |
class GuiExport PropertyStringItem: public PropertyItem |
| 264 |
{ |
| 265 |
Q_OBJECT |
| 266 |
PROPERTYITEM_HEADER |
| 267 |
|
| 268 |
QWidget* createEditor( |
| 269 |
QWidget* parent, |
| 270 |
const std::function<void()>& method, |
| 271 |
FrameOption frameOption = FrameOption::NoFrame |
| 272 |
) const override; |
| 273 |
void setEditorData(QWidget* editor, const QVariant& data) const override; |
| 274 |
QVariant editorData(QWidget* editor) const override; |
| 275 |
|
| 276 |
protected: |
| 277 |
QVariant value(const App::Property*) const override; |
| 278 |
void setValue(const QVariant&) override; |
| 279 |
|
| 280 |
protected: |
| 281 |
PropertyStringItem(); |
| 282 |
}; |
| 283 |
|
| 284 |
/** |
| 285 |
* Change a font property. |
| 286 |
* \author Werner Mayer |
| 287 |
*/ |
| 288 |
class GuiExport PropertyFontItem: public PropertyItem |
| 289 |
{ |
| 290 |
Q_OBJECT |
| 291 |
PROPERTYITEM_HEADER |
| 292 |
|
| 293 |
QWidget* createEditor( |
| 294 |
QWidget* parent, |
| 295 |
const std::function<void()>& method, |
| 296 |
FrameOption frameOption = FrameOption::NoFrame |
| 297 |
) const override; |
| 298 |
void setEditorData(QWidget* editor, const QVariant& data) const override; |
| 299 |
QVariant editorData(QWidget* editor) const override; |
| 300 |
|
| 301 |
protected: |
| 302 |
QVariant value(const App::Property*) const override; |
| 303 |
void setValue(const QVariant&) override; |
| 304 |
|
| 305 |
protected: |
| 306 |
PropertyFontItem(); |
| 307 |
}; |
| 308 |
|
| 309 |
/** |
| 310 |
* Dummy property to separate groups of properties. |
| 311 |
* \author Werner Mayer |
| 312 |
*/ |
| 313 |
class GuiExport PropertySeparatorItem: public PropertyItem |
| 314 |
{ |
| 315 |
Q_OBJECT |
| 316 |
PROPERTYITEM_HEADER |
| 317 |
|
| 318 |
bool isSeparator() const override |
| 319 |
{ |
| 320 |
return true; |
| 321 |
} |
| 322 |
QWidget* createEditor( |
| 323 |
QWidget* parent, |
| 324 |
const std::function<void()>& method, |
| 325 |
FrameOption frameOption = FrameOption::NoFrame |
| 326 |
) const override; |
| 327 |
|
| 328 |
int row() const override |
| 329 |
{ |
| 330 |
return _row < 0 ? PropertyItem::row() : _row; |
| 331 |
} |
| 332 |
|
| 333 |
private: |
| 334 |
friend PropertyModel; |
| 335 |
int _row = -1; |
| 336 |
}; |
| 337 |
|
| 338 |
/** |
| 339 |
* Change a number. |
| 340 |
* \author Werner Mayer |
| 341 |
*/ |
| 342 |
class GuiExport PropertyIntegerItem: public PropertyItem |
| 343 |
{ |
| 344 |
Q_OBJECT |
| 345 |
PROPERTYITEM_HEADER |
| 346 |
|
| 347 |
QWidget* createEditor( |
| 348 |
QWidget* parent, |
| 349 |
const std::function<void()>& method, |
| 350 |
FrameOption frameOption = FrameOption::NoFrame |
| 351 |
) const override; |
| 352 |
void setEditorData(QWidget* editor, const QVariant& data) const override; |
| 353 |
QVariant editorData(QWidget* editor) const override; |
| 354 |
|
| 355 |
protected: |
| 356 |
QString toString(const QVariant&) const override; |
| 357 |
QVariant value(const App::Property*) const override; |
| 358 |
void setValue(const QVariant&) override; |
| 359 |
|
| 360 |
protected: |
| 361 |
PropertyIntegerItem(); |
| 362 |
}; |
| 363 |
|
| 364 |
/** |
| 365 |
* Change a number with constraints. |
| 366 |
* \author Werner Mayer |
| 367 |
*/ |
| 368 |
class GuiExport PropertyIntegerConstraintItem: public PropertyItem |
| 369 |
{ |
| 370 |
Q_OBJECT |
| 371 |
PROPERTYITEM_HEADER |
| 372 |
|
| 373 |
QWidget* createEditor( |
| 374 |
QWidget* parent, |
| 375 |
const std::function<void()>& method, |
| 376 |
FrameOption frameOption = FrameOption::NoFrame |
| 377 |
) const override; |
| 378 |
void setEditorData(QWidget* editor, const QVariant& data) const override; |
| 379 |
QVariant editorData(QWidget* editor) const override; |
| 380 |
|
| 381 |
void setRange(int min, int max) |
| 382 |
{ |
| 383 |
this->min = min; |
| 384 |
this->max = max; |
| 385 |
} |
| 386 |
|
| 387 |
void setStepSize(int steps) |
| 388 |
{ |
| 389 |
this->steps = steps; |
| 390 |
} |
| 391 |
|
| 392 |
protected: |
| 393 |
QString toString(const QVariant&) const override; |
| 394 |
QVariant value(const App::Property*) const override; |
| 395 |
void setValue(const QVariant&) override; |
| 396 |
|
| 397 |
protected: |
| 398 |
PropertyIntegerConstraintItem(); |
| 399 |
|
| 400 |
private: |
| 401 |
int min = std::numeric_limits<int>::min(); |
| 402 |
int max = std::numeric_limits<int>::max(); |
| 403 |
int steps = 1; |
| 404 |
}; |
| 405 |
|
| 406 |
/** |
| 407 |
* Change a floating point number. |
| 408 |
* \author Werner Mayer |
| 409 |
*/ |
| 410 |
class GuiExport PropertyFloatItem: public PropertyItem |
| 411 |
{ |
| 412 |
Q_OBJECT |
| 413 |
PROPERTYITEM_HEADER |
| 414 |
|
| 415 |
QWidget* createEditor( |
| 416 |
QWidget* parent, |
| 417 |
const std::function<void()>& method, |
| 418 |
FrameOption frameOption = FrameOption::NoFrame |
| 419 |
) const override; |
| 420 |
void setEditorData(QWidget* editor, const QVariant& data) const override; |
| 421 |
QVariant editorData(QWidget* editor) const override; |
| 422 |
|
| 423 |
protected: |
| 424 |
QString toString(const QVariant&) const override; |
| 425 |
QVariant value(const App::Property*) const override; |
| 426 |
void setValue(const QVariant&) override; |
| 427 |
|
| 428 |
protected: |
| 429 |
PropertyFloatItem(); |
| 430 |
}; |
| 431 |
|
| 432 |
/** |
| 433 |
* Change a Unit based floating point number. |
| 434 |
* \author Juergen Riegel |
| 435 |
*/ |
| 436 |
class GuiExport PropertyUnitItem: public PropertyItem |
| 437 |
{ |
| 438 |
Q_OBJECT |
| 439 |
PROPERTYITEM_HEADER |
| 440 |
|
| 441 |
QWidget* createEditor( |
| 442 |
QWidget* parent, |
| 443 |
const std::function<void()>& method, |
| 444 |
FrameOption frameOption = FrameOption::NoFrame |
| 445 |
) const override; |
| 446 |
void setEditorData(QWidget* editor, const QVariant& data) const override; |
| 447 |
QVariant editorData(QWidget* editor) const override; |
| 448 |
|
| 449 |
protected: |
| 450 |
QString toString(const QVariant&) const override; |
| 451 |
QVariant value(const App::Property*) const override; |
| 452 |
void setValue(const QVariant&) override; |
| 453 |
|
| 454 |
PropertyUnitItem(); |
| 455 |
}; |
| 456 |
|
| 457 |
/** |
| 458 |
* Change a Unit based floating point number within constraints. |
| 459 |
* \author Stefan Troeger |
| 460 |
*/ |
| 461 |
class GuiExport PropertyUnitConstraintItem: public PropertyUnitItem |
| 462 |
{ |
| 463 |
Q_OBJECT |
| 464 |
PROPERTYITEM_HEADER |
| 465 |
|
| 466 |
void setEditorData(QWidget* editor, const QVariant& data) const override; |
| 467 |
|
| 468 |
void setRange(double min, double max) |
| 469 |
{ |
| 470 |
this->min = min; |
| 471 |
this->max = max; |
| 472 |
} |
| 473 |
|
| 474 |
void setStepSize(double steps) |
| 475 |
{ |
| 476 |
this->steps = steps; |
| 477 |
} |
| 478 |
|
| 479 |
protected: |
| 480 |
PropertyUnitConstraintItem(); |
| 481 |
|
| 482 |
private: |
| 483 |
double min = static_cast<double>(std::numeric_limits<int>::min()); |
| 484 |
double max = static_cast<double>(std::numeric_limits<int>::max()); |
| 485 |
double steps = 0.1; |
| 486 |
}; |
| 487 |
|
| 488 |
/** |
| 489 |
* Change a floating point number with constraints. |
| 490 |
* \author Werner Mayer |
| 491 |
*/ |
| 492 |
class GuiExport PropertyFloatConstraintItem: public PropertyItem |
| 493 |
{ |
| 494 |
Q_OBJECT |
| 495 |
PROPERTYITEM_HEADER |
| 496 |
|
| 497 |
QWidget* createEditor( |
| 498 |
QWidget* parent, |
| 499 |
const std::function<void()>& method, |
| 500 |
FrameOption frameOption = FrameOption::NoFrame |
| 501 |
) const override; |
| 502 |
void setEditorData(QWidget* editor, const QVariant& data) const override; |
| 503 |
QVariant editorData(QWidget* editor) const override; |
| 504 |
|
| 505 |
void setRange(double min, double max) |
| 506 |
{ |
| 507 |
this->min = min; |
| 508 |
this->max = max; |
| 509 |
} |
| 510 |
|
| 511 |
void setStepSize(double steps) |
| 512 |
{ |
| 513 |
this->steps = steps; |
| 514 |
} |
| 515 |
|
| 516 |
protected: |
| 517 |
QString toString(const QVariant&) const override; |
| 518 |
QVariant value(const App::Property*) const override; |
| 519 |
void setValue(const QVariant&) override; |
| 520 |
|
| 521 |
protected: |
| 522 |
PropertyFloatConstraintItem(); |
| 523 |
|
| 524 |
private: |
| 525 |
double min = static_cast<double>(std::numeric_limits<int>::min()); |
| 526 |
double max = static_cast<double>(std::numeric_limits<int>::max()); |
| 527 |
double steps = 0.1; |
| 528 |
}; |
| 529 |
|
| 530 |
/** |
| 531 |
* Change a floating point number with many decimal points (hard coded as 16) |
| 532 |
*/ |
| 533 |
class GuiExport PropertyPrecisionItem: public PropertyFloatConstraintItem |
| 534 |
{ |
| 535 |
Q_OBJECT |
| 536 |
PROPERTYITEM_HEADER |
| 537 |
protected: |
| 538 |
PropertyPrecisionItem(); |
| 539 |
}; |
| 540 |
|
| 541 |
/** |
| 542 |
* Change a floating point number. |
| 543 |
* \author Werner Mayer |
| 544 |
*/ |
| 545 |
class GuiExport PropertyAngleItem: public PropertyUnitConstraintItem |
| 546 |
{ |
| 547 |
Q_OBJECT |
| 548 |
PROPERTYITEM_HEADER |
| 549 |
|
| 550 |
protected: |
| 551 |
void setEditorData(QWidget* editor, const QVariant& data) const override; |
| 552 |
QString toString(const QVariant&) const override; |
| 553 |
|
| 554 |
protected: |
| 555 |
PropertyAngleItem(); |
| 556 |
}; |
| 557 |
|
| 558 |
/** |
| 559 |
* Edit properties of boolean type. |
| 560 |
* \author Werner Mayer |
| 561 |
*/ |
| 562 |
class GuiExport PropertyBoolItem: public PropertyItem |
| 563 |
{ |
| 564 |
Q_OBJECT |
| 565 |
PROPERTYITEM_HEADER |
| 566 |
|
| 567 |
QWidget* createEditor( |
| 568 |
QWidget* parent, |
| 569 |
const std::function<void()>& method, |
| 570 |
FrameOption frameOption = FrameOption::NoFrame |
| 571 |
) const override; |
| 572 |
void setEditorData(QWidget* editor, const QVariant& data) const override; |
| 573 |
QVariant editorData(QWidget* editor) const override; |
| 574 |
|
| 575 |
protected: |
| 576 |
QVariant value(const App::Property*) const override; |
| 577 |
void setValue(const QVariant&) override; |
| 578 |
|
| 579 |
protected: |
| 580 |
PropertyBoolItem(); |
| 581 |
}; |
| 582 |
|
| 583 |
/** |
| 584 |
* Edit properties of vector type. |
| 585 |
* \author Werner Mayer |
| 586 |
*/ |
| 587 |
class PropertyFloatItem; |
| 588 |
class GuiExport PropertyVectorItem: public PropertyItem |
| 589 |
{ |
| 590 |
// clang-format off |
| 591 |
Q_OBJECT |
| 592 |
Q_PROPERTY(double x READ x WRITE setX DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 593 |
Q_PROPERTY(double y READ y WRITE setY DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 594 |
Q_PROPERTY(double z READ z WRITE setZ DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 595 |
PROPERTYITEM_HEADER |
| 596 |
// clang-format on |
| 597 |
|
| 598 |
QWidget* createEditor( |
| 599 |
QWidget* parent, |
| 600 |
const std::function<void()>& method, |
| 601 |
FrameOption frameOption = FrameOption::NoFrame |
| 602 |
) const override; |
| 603 |
void setEditorData(QWidget* editor, const QVariant& data) const override; |
| 604 |
QVariant editorData(QWidget* editor) const override; |
| 605 |
|
| 606 |
double x() const; |
| 607 |
void setX(double x); |
| 608 |
double y() const; |
| 609 |
void setY(double y); |
| 610 |
double z() const; |
| 611 |
void setZ(double z); |
| 612 |
|
| 613 |
protected: |
| 614 |
QString toString(const QVariant&) const override; |
| 615 |
QVariant value(const App::Property*) const override; |
| 616 |
void setValue(const QVariant&) override; |
| 617 |
|
| 618 |
protected: |
| 619 |
PropertyVectorItem(); |
| 620 |
void propertyBound() override; |
| 621 |
|
| 622 |
private: |
| 623 |
PropertyFloatItem* m_x; |
| 624 |
PropertyFloatItem* m_y; |
| 625 |
PropertyFloatItem* m_z; |
| 626 |
}; |
| 627 |
|
| 628 |
class PropertyEditorWidget: public QWidget |
| 629 |
{ |
| 630 |
Q_OBJECT |
| 631 |
|
| 632 |
public: |
| 633 |
explicit PropertyEditorWidget(QWidget* parent = nullptr); |
| 634 |
~PropertyEditorWidget() override; |
| 635 |
|
| 636 |
QVariant value() const; |
| 637 |
|
| 638 |
public Q_SLOTS: |
| 639 |
void setValue(const QVariant&); |
| 640 |
|
| 641 |
protected: |
| 642 |
virtual void showValue(const QVariant& data); |
| 643 |
void resizeEvent(QResizeEvent*) override; |
| 644 |
|
| 645 |
Q_SIGNALS: |
| 646 |
void buttonClick(); |
| 647 |
void valueChanged(const QVariant&); |
| 648 |
|
| 649 |
protected: |
| 650 |
QVariant variant; |
| 651 |
QLineEdit* lineEdit; |
| 652 |
QPushButton* button; |
| 653 |
}; |
| 654 |
|
| 655 |
class VectorListWidget: public PropertyEditorWidget |
| 656 |
{ |
| 657 |
Q_OBJECT |
| 658 |
|
| 659 |
public: |
| 660 |
explicit VectorListWidget(int decimals, QWidget* parent = nullptr); |
| 661 |
|
| 662 |
protected: |
| 663 |
void showValue(const QVariant& data) override; |
| 664 |
|
| 665 |
private Q_SLOTS: |
| 666 |
void buttonClicked(); |
| 667 |
|
| 668 |
private: |
| 669 |
int decimals; |
| 670 |
}; |
| 671 |
|
| 672 |
/** |
| 673 |
* Edit properties of vector list type. |
| 674 |
* \author Werner Mayer |
| 675 |
*/ |
| 676 |
class GuiExport PropertyVectorListItem: public PropertyItem |
| 677 |
{ |
| 678 |
Q_OBJECT |
| 679 |
PROPERTYITEM_HEADER |
| 680 |
|
| 681 |
QWidget* createEditor( |
| 682 |
QWidget* parent, |
| 683 |
const std::function<void()>& method, |
| 684 |
FrameOption frameOption = FrameOption::NoFrame |
| 685 |
) const override; |
| 686 |
void setEditorData(QWidget* editor, const QVariant& data) const override; |
| 687 |
QVariant editorData(QWidget* editor) const override; |
| 688 |
|
| 689 |
protected: |
| 690 |
QString toString(const QVariant&) const override; |
| 691 |
QVariant value(const App::Property*) const override; |
| 692 |
void setValue(const QVariant&) override; |
| 693 |
|
| 694 |
protected: |
| 695 |
PropertyVectorListItem(); |
| 696 |
}; |
| 697 |
|
| 698 |
/** |
| 699 |
* Edit properties of vector type which hold distances. |
| 700 |
* \author Stefan Troeger |
| 701 |
*/ |
| 702 |
class PropertyUnitItem; |
| 703 |
class GuiExport PropertyVectorDistanceItem: public PropertyItem |
| 704 |
{ |
| 705 |
// clang-format off |
| 706 |
Q_OBJECT |
| 707 |
Q_PROPERTY(Base::Quantity x READ x WRITE setX DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 708 |
Q_PROPERTY(Base::Quantity y READ y WRITE setY DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 709 |
Q_PROPERTY(Base::Quantity z READ z WRITE setZ DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 710 |
PROPERTYITEM_HEADER |
| 711 |
// clang-format on |
| 712 |
|
| 713 |
QWidget* createEditor( |
| 714 |
QWidget* parent, |
| 715 |
const std::function<void()>& method, |
| 716 |
FrameOption frameOption = FrameOption::NoFrame |
| 717 |
) const override; |
| 718 |
void setEditorData(QWidget* editor, const QVariant& data) const override; |
| 719 |
QVariant editorData(QWidget* editor) const override; |
| 720 |
|
| 721 |
void propertyBound() override; |
| 722 |
|
| 723 |
Base::Quantity x() const; |
| 724 |
void setX(Base::Quantity x); |
| 725 |
Base::Quantity y() const; |
| 726 |
void setY(Base::Quantity y); |
| 727 |
Base::Quantity z() const; |
| 728 |
void setZ(Base::Quantity z); |
| 729 |
|
| 730 |
protected: |
| 731 |
QString toString(const QVariant&) const override; |
| 732 |
QVariant value(const App::Property*) const override; |
| 733 |
void setValue(const QVariant&) override; |
| 734 |
|
| 735 |
PropertyVectorDistanceItem(); |
| 736 |
|
| 737 |
private: |
| 738 |
PropertyUnitItem* m_x; |
| 739 |
PropertyUnitItem* m_y; |
| 740 |
PropertyUnitItem* m_z; |
| 741 |
}; |
| 742 |
|
| 743 |
class GuiExport PropertyPositionItem: public PropertyVectorDistanceItem |
| 744 |
{ |
| 745 |
Q_OBJECT |
| 746 |
PROPERTYITEM_HEADER |
| 747 |
}; |
| 748 |
|
| 749 |
class GuiExport PropertyDirectionItem: public PropertyVectorDistanceItem |
| 750 |
{ |
| 751 |
Q_OBJECT |
| 752 |
PROPERTYITEM_HEADER |
| 753 |
}; |
| 754 |
|
| 755 |
class GuiExport PropertyMatrixItem: public PropertyItem |
| 756 |
{ |
| 757 |
// clang-format off |
| 758 |
Q_OBJECT |
| 759 |
Q_PROPERTY(double A11 READ getA11 WRITE setA11 DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 760 |
Q_PROPERTY(double A12 READ getA12 WRITE setA12 DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 761 |
Q_PROPERTY(double A13 READ getA13 WRITE setA13 DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 762 |
Q_PROPERTY(double A14 READ getA14 WRITE setA14 DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 763 |
Q_PROPERTY(double A21 READ getA21 WRITE setA21 DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 764 |
Q_PROPERTY(double A22 READ getA22 WRITE setA22 DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 765 |
Q_PROPERTY(double A23 READ getA23 WRITE setA23 DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 766 |
Q_PROPERTY(double A24 READ getA24 WRITE setA24 DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 767 |
Q_PROPERTY(double A31 READ getA31 WRITE setA31 DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 768 |
Q_PROPERTY(double A32 READ getA32 WRITE setA32 DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 769 |
Q_PROPERTY(double A33 READ getA33 WRITE setA33 DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 770 |
Q_PROPERTY(double A34 READ getA34 WRITE setA34 DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 771 |
Q_PROPERTY(double A41 READ getA41 WRITE setA41 DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 772 |
Q_PROPERTY(double A42 READ getA42 WRITE setA42 DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 773 |
Q_PROPERTY(double A43 READ getA43 WRITE setA43 DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 774 |
Q_PROPERTY(double A44 READ getA44 WRITE setA44 DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 775 |
PROPERTYITEM_HEADER |
| 776 |
// clang-format on |
| 777 |
|
| 778 |
QWidget* createEditor( |
| 779 |
QWidget* parent, |
| 780 |
const std::function<void()>& method, |
| 781 |
FrameOption frameOption = FrameOption::NoFrame |
| 782 |
) const override; |
| 783 |
void setEditorData(QWidget* editor, const QVariant& data) const override; |
| 784 |
QVariant editorData(QWidget* editor) const override; |
| 785 |
|
| 786 |
double getA11() const; |
| 787 |
void setA11(double A11); |
| 788 |
double getA12() const; |
| 789 |
void setA12(double A12); |
| 790 |
double getA13() const; |
| 791 |
void setA13(double A13); |
| 792 |
double getA14() const; |
| 793 |
void setA14(double A14); |
| 794 |
double getA21() const; |
| 795 |
void setA21(double A21); |
| 796 |
double getA22() const; |
| 797 |
void setA22(double A22); |
| 798 |
double getA23() const; |
| 799 |
void setA23(double A23); |
| 800 |
double getA24() const; |
| 801 |
void setA24(double A24); |
| 802 |
double getA31() const; |
| 803 |
void setA31(double A31); |
| 804 |
double getA32() const; |
| 805 |
void setA32(double A32); |
| 806 |
double getA33() const; |
| 807 |
void setA33(double A33); |
| 808 |
double getA34() const; |
| 809 |
void setA34(double A34); |
| 810 |
double getA41() const; |
| 811 |
void setA41(double A41); |
| 812 |
double getA42() const; |
| 813 |
void setA42(double A42); |
| 814 |
double getA43() const; |
| 815 |
void setA43(double A43); |
| 816 |
double getA44() const; |
| 817 |
void setA44(double A44); |
| 818 |
|
| 819 |
protected: |
| 820 |
QString toString(const QVariant&) const override; |
| 821 |
QVariant value(const App::Property*) const override; |
| 822 |
void setValue(const QVariant&) override; |
| 823 |
|
| 824 |
protected: |
| 825 |
PropertyMatrixItem(); |
| 826 |
QVariant toolTip(const App::Property*) const override; |
| 827 |
|
| 828 |
private: |
| 829 |
PropertyFloatItem* m_a11; |
| 830 |
PropertyFloatItem* m_a12; |
| 831 |
PropertyFloatItem* m_a13; |
| 832 |
PropertyFloatItem* m_a14; |
| 833 |
PropertyFloatItem* m_a21; |
| 834 |
PropertyFloatItem* m_a22; |
| 835 |
PropertyFloatItem* m_a23; |
| 836 |
PropertyFloatItem* m_a24; |
| 837 |
PropertyFloatItem* m_a31; |
| 838 |
PropertyFloatItem* m_a32; |
| 839 |
PropertyFloatItem* m_a33; |
| 840 |
PropertyFloatItem* m_a34; |
| 841 |
PropertyFloatItem* m_a41; |
| 842 |
PropertyFloatItem* m_a42; |
| 843 |
PropertyFloatItem* m_a43; |
| 844 |
PropertyFloatItem* m_a44; |
| 845 |
}; |
| 846 |
|
| 847 |
class RotationHelper |
| 848 |
{ |
| 849 |
public: |
| 850 |
RotationHelper(); |
| 851 |
void setChanged(bool); |
| 852 |
bool hasChangedAndReset(); |
| 853 |
bool isAxisInitialized() const; |
| 854 |
void setValue(const Base::Vector3d& axis, double angle); |
| 855 |
void getValue(Base::Vector3d& axis, double& angle) const; |
| 856 |
double getAngle(const Base::Rotation& val) const; |
| 857 |
Base::Rotation setAngle(double); |
| 858 |
Base::Vector3d getAxis() const; |
| 859 |
Base::Rotation setAxis(const Base::Rotation& value, const Base::Vector3d& axis); |
| 860 |
void assignProperty(const Base::Rotation& value, double eps); |
| 861 |
|
| 862 |
private: |
| 863 |
bool init_axis; |
| 864 |
bool changed_value; |
| 865 |
double rot_angle; |
| 866 |
Base::Vector3d rot_axis; |
| 867 |
}; |
| 868 |
|
| 869 |
/** |
| 870 |
* Edit properties of rotation type. |
| 871 |
* \author Werner Mayer |
| 872 |
*/ |
| 873 |
class GuiExport PropertyRotationItem: public PropertyItem |
| 874 |
{ |
| 875 |
// clang-format off |
| 876 |
Q_OBJECT |
| 877 |
Q_PROPERTY(Base::Quantity Angle READ getAngle WRITE setAngle DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 878 |
Q_PROPERTY(Base::Vector3d Axis READ getAxis WRITE setAxis DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 879 |
PROPERTYITEM_HEADER |
| 880 |
// clang-format on |
| 881 |
|
| 882 |
QWidget* createEditor( |
| 883 |
QWidget* parent, |
| 884 |
const std::function<void()>& method, |
| 885 |
FrameOption frameOption = FrameOption::NoFrame |
| 886 |
) const override; |
| 887 |
void setEditorData(QWidget* editor, const QVariant& data) const override; |
| 888 |
QVariant editorData(QWidget* editor) const override; |
| 889 |
|
| 890 |
void propertyBound() override; |
| 891 |
void assignProperty(const App::Property*) override; |
| 892 |
|
| 893 |
Base::Quantity getAngle() const; |
| 894 |
void setAngle(Base::Quantity); |
| 895 |
Base::Vector3d getAxis() const; |
| 896 |
void setAxis(const Base::Vector3d&); |
| 897 |
|
| 898 |
protected: |
| 899 |
PropertyRotationItem(); |
| 900 |
~PropertyRotationItem() override; |
| 901 |
QVariant toolTip(const App::Property*) const override; |
| 902 |
QString toString(const QVariant&) const override; |
| 903 |
QVariant value(const App::Property*) const override; |
| 904 |
void setValue(const QVariant&) override; |
| 905 |
|
| 906 |
private: |
| 907 |
mutable RotationHelper h; |
| 908 |
PropertyUnitItem* m_a; |
| 909 |
PropertyVectorItem* m_d; |
| 910 |
}; |
| 911 |
|
| 912 |
class PlacementEditor: public Gui::LabelButton |
| 913 |
{ |
| 914 |
Q_OBJECT |
| 915 |
|
| 916 |
public: |
| 917 |
explicit PlacementEditor(QString name, QWidget* parent = nullptr); |
| 918 |
~PlacementEditor() override; |
| 919 |
|
| 920 |
private Q_SLOTS: |
| 921 |
void updateValue(const QVariant& v, bool, bool); |
| 922 |
|
| 923 |
private: |
| 924 |
void browse() override; |
| 925 |
void showValue(const QVariant& d) override; |
| 926 |
|
| 927 |
private: |
| 928 |
QPointer<Gui::Dialog::TaskPlacement> _task; |
| 929 |
QString propertyname; |
| 930 |
}; |
| 931 |
|
| 932 |
/** |
| 933 |
* Edit properties of placement type. |
| 934 |
* \author Werner Mayer |
| 935 |
*/ |
| 936 |
class GuiExport PropertyPlacementItem: public PropertyItem |
| 937 |
{ |
| 938 |
// clang-format off |
| 939 |
Q_OBJECT |
| 940 |
Q_PROPERTY(Base::Quantity Angle READ getAngle WRITE setAngle DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 941 |
Q_PROPERTY(Base::Vector3d Axis READ getAxis WRITE setAxis DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 942 |
Q_PROPERTY(Base::Vector3d Position READ getPosition WRITE setPosition DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 943 |
PROPERTYITEM_HEADER |
| 944 |
// clang-format on |
| 945 |
|
| 946 |
QWidget* createEditor( |
| 947 |
QWidget* parent, |
| 948 |
const std::function<void()>& method, |
| 949 |
FrameOption frameOption = FrameOption::NoFrame |
| 950 |
) const override; |
| 951 |
void setEditorData(QWidget* editor, const QVariant& data) const override; |
| 952 |
QVariant editorData(QWidget* editor) const override; |
| 953 |
|
| 954 |
void propertyBound() override; |
| 955 |
void assignProperty(const App::Property*) override; |
| 956 |
|
| 957 |
Base::Quantity getAngle() const; |
| 958 |
void setAngle(Base::Quantity); |
| 959 |
Base::Vector3d getAxis() const; |
| 960 |
void setAxis(const Base::Vector3d&); |
| 961 |
Base::Vector3d getPosition() const; |
| 962 |
void setPosition(const Base::Vector3d&); |
| 963 |
|
| 964 |
protected: |
| 965 |
PropertyPlacementItem(); |
| 966 |
~PropertyPlacementItem() override; |
| 967 |
QVariant toolTip(const App::Property*) const override; |
| 968 |
QString toString(const QVariant&) const override; |
| 969 |
QVariant value(const App::Property*) const override; |
| 970 |
void setValue(const QVariant&) override; |
| 971 |
|
| 972 |
private: |
| 973 |
mutable RotationHelper h; |
| 974 |
PropertyUnitItem* m_a; |
| 975 |
PropertyVectorItem* m_d; |
| 976 |
PropertyVectorDistanceItem* m_p; |
| 977 |
}; |
| 978 |
|
| 979 |
class PropertyStringListItem; |
| 980 |
|
| 981 |
/** |
| 982 |
* Edit properties of enum type. |
| 983 |
* \author Werner Mayer |
| 984 |
*/ |
| 985 |
class GuiExport PropertyEnumItem: public PropertyItem |
| 986 |
{ |
| 987 |
// clang-format off |
| 988 |
Q_OBJECT |
| 989 |
Q_PROPERTY(QStringList Enum READ getEnum WRITE setEnum DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 990 |
PROPERTYITEM_HEADER |
| 991 |
// clang-format on |
| 992 |
|
| 993 |
QWidget* createEditor( |
| 994 |
QWidget* parent, |
| 995 |
const std::function<void()>& method, |
| 996 |
FrameOption frameOption = FrameOption::NoFrame |
| 997 |
) const override; |
| 998 |
void setEditorData(QWidget* editor, const QVariant& data) const override; |
| 999 |
QVariant editorData(QWidget* editor) const override; |
| 1000 |
|
| 1001 |
QStringList getEnum() const; |
| 1002 |
void setEnum(const QStringList&); |
| 1003 |
|
| 1004 |
private: |
| 1005 |
QStringList getCommonModes() const; |
| 1006 |
|
| 1007 |
protected: |
| 1008 |
QVariant value(const App::Property*) const override; |
| 1009 |
void setValue(const QVariant&) override; |
| 1010 |
void propertyBound() override; |
| 1011 |
|
| 1012 |
protected: |
| 1013 |
PropertyEnumItem(); |
| 1014 |
|
| 1015 |
private: |
| 1016 |
PropertyStringListItem* m_enum; |
| 1017 |
}; |
| 1018 |
|
| 1019 |
class PropertyEnumButton: public QPushButton |
| 1020 |
{ |
| 1021 |
Q_OBJECT |
| 1022 |
public: |
| 1023 |
explicit PropertyEnumButton(QWidget* parent = nullptr) |
| 1024 |
: QPushButton(parent) |
| 1025 |
{} |
| 1026 |
|
| 1027 |
Q_SIGNALS: |
| 1028 |
void picked(); |
| 1029 |
}; |
| 1030 |
|
| 1031 |
/** |
| 1032 |
* Edit properties of string list type. |
| 1033 |
* \author Werner Mayer |
| 1034 |
*/ |
| 1035 |
class GuiExport PropertyStringListItem: public PropertyItem |
| 1036 |
{ |
| 1037 |
Q_OBJECT |
| 1038 |
PROPERTYITEM_HEADER |
| 1039 |
|
| 1040 |
QWidget* createEditor( |
| 1041 |
QWidget* parent, |
| 1042 |
const std::function<void()>& method, |
| 1043 |
FrameOption frameOption = FrameOption::NoFrame |
| 1044 |
) const override; |
| 1045 |
void setEditorData(QWidget* editor, const QVariant& data) const override; |
| 1046 |
QVariant editorData(QWidget* editor) const override; |
| 1047 |
|
| 1048 |
protected: |
| 1049 |
QString toString(const QVariant&) const override; |
| 1050 |
QVariant value(const App::Property*) const override; |
| 1051 |
void setValue(const QVariant&) override; |
| 1052 |
|
| 1053 |
protected: |
| 1054 |
PropertyStringListItem(); |
| 1055 |
}; |
| 1056 |
|
| 1057 |
/** |
| 1058 |
* Edit properties of float list type. |
| 1059 |
* \author Werner Mayer |
| 1060 |
*/ |
| 1061 |
class GuiExport PropertyFloatListItem: public PropertyItem |
| 1062 |
{ |
| 1063 |
Q_OBJECT |
| 1064 |
PROPERTYITEM_HEADER |
| 1065 |
|
| 1066 |
QWidget* createEditor( |
| 1067 |
QWidget* parent, |
| 1068 |
const std::function<void()>& method, |
| 1069 |
FrameOption frameOption = FrameOption::NoFrame |
| 1070 |
) const override; |
| 1071 |
void setEditorData(QWidget* editor, const QVariant& data) const override; |
| 1072 |
QVariant editorData(QWidget* editor) const override; |
| 1073 |
|
| 1074 |
protected: |
| 1075 |
QString toString(const QVariant&) const override; |
| 1076 |
QVariant value(const App::Property*) const override; |
| 1077 |
void setValue(const QVariant&) override; |
| 1078 |
|
| 1079 |
protected: |
| 1080 |
PropertyFloatListItem(); |
| 1081 |
}; |
| 1082 |
|
| 1083 |
/** |
| 1084 |
* Edit properties of float list type. |
| 1085 |
* \author Werner Mayer |
| 1086 |
*/ |
| 1087 |
class GuiExport PropertyIntegerListItem: public PropertyItem |
| 1088 |
{ |
| 1089 |
Q_OBJECT |
| 1090 |
PROPERTYITEM_HEADER |
| 1091 |
|
| 1092 |
QWidget* createEditor( |
| 1093 |
QWidget* parent, |
| 1094 |
const std::function<void()>& method, |
| 1095 |
FrameOption frameOption = FrameOption::NoFrame |
| 1096 |
) const override; |
| 1097 |
void setEditorData(QWidget* editor, const QVariant& data) const override; |
| 1098 |
QVariant editorData(QWidget* editor) const override; |
| 1099 |
|
| 1100 |
protected: |
| 1101 |
QString toString(const QVariant&) const override; |
| 1102 |
QVariant value(const App::Property*) const override; |
| 1103 |
void setValue(const QVariant&) override; |
| 1104 |
|
| 1105 |
protected: |
| 1106 |
PropertyIntegerListItem(); |
| 1107 |
}; |
| 1108 |
|
| 1109 |
/** |
| 1110 |
* Change a color property. |
| 1111 |
* \author Werner Mayer |
| 1112 |
*/ |
| 1113 |
class GuiExport PropertyColorItem: public PropertyItem |
| 1114 |
{ |
| 1115 |
Q_OBJECT |
| 1116 |
PROPERTYITEM_HEADER |
| 1117 |
|
| 1118 |
QWidget* createEditor( |
| 1119 |
QWidget* parent, |
| 1120 |
const std::function<void()>& method, |
| 1121 |
FrameOption frameOption = FrameOption::NoFrame |
| 1122 |
) const override; |
| 1123 |
void setEditorData(QWidget* editor, const QVariant& data) const override; |
| 1124 |
QVariant editorData(QWidget* editor) const override; |
| 1125 |
|
| 1126 |
protected: |
| 1127 |
QVariant decoration(const QVariant&) const override; |
| 1128 |
QString toString(const QVariant&) const override; |
| 1129 |
QVariant value(const App::Property*) const override; |
| 1130 |
void setValue(const QVariant&) override; |
| 1131 |
|
| 1132 |
protected: |
| 1133 |
PropertyColorItem(); |
| 1134 |
}; |
| 1135 |
|
| 1136 |
/** |
| 1137 |
* Change a material property. |
| 1138 |
* \author Werner Mayer |
| 1139 |
*/ |
| 1140 |
class GuiExport PropertyMaterialItem: public PropertyItem |
| 1141 |
{ |
| 1142 |
// clang-format off |
| 1143 |
Q_OBJECT |
| 1144 |
Q_PROPERTY(QColor AmbientColor READ getAmbientColor WRITE setAmbientColor DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 1145 |
Q_PROPERTY(QColor DiffuseColor READ getDiffuseColor WRITE setDiffuseColor DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 1146 |
Q_PROPERTY(QColor SpecularColor READ getSpecularColor WRITE setSpecularColor DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 1147 |
Q_PROPERTY(QColor EmissiveColor READ getEmissiveColor WRITE setEmissiveColor DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 1148 |
Q_PROPERTY(float Shininess READ getShininess WRITE setShininess DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 1149 |
Q_PROPERTY(float Transparency READ getTransparency WRITE setTransparency DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 1150 |
PROPERTYITEM_HEADER |
| 1151 |
// clang-format on |
| 1152 |
|
| 1153 |
QWidget* createEditor( |
| 1154 |
QWidget* parent, |
| 1155 |
const std::function<void()>& method, |
| 1156 |
FrameOption frameOption = FrameOption::NoFrame |
| 1157 |
) const override; |
| 1158 |
void setEditorData(QWidget* editor, const QVariant& data) const override; |
| 1159 |
QVariant editorData(QWidget* editor) const override; |
| 1160 |
|
| 1161 |
void propertyBound() override; |
| 1162 |
|
| 1163 |
QColor getAmbientColor() const; |
| 1164 |
void setAmbientColor(const QColor&); |
| 1165 |
QColor getDiffuseColor() const; |
| 1166 |
void setDiffuseColor(const QColor&); |
| 1167 |
QColor getSpecularColor() const; |
| 1168 |
void setSpecularColor(const QColor&); |
| 1169 |
QColor getEmissiveColor() const; |
| 1170 |
void setEmissiveColor(const QColor&); |
| 1171 |
int getShininess() const; |
| 1172 |
void setShininess(int); |
| 1173 |
int getTransparency() const; |
| 1174 |
void setTransparency(int); |
| 1175 |
|
| 1176 |
protected: |
| 1177 |
PropertyMaterialItem(); |
| 1178 |
~PropertyMaterialItem() override; |
| 1179 |
|
| 1180 |
QVariant decoration(const QVariant&) const override; |
| 1181 |
QVariant toolTip(const App::Property*) const override; |
| 1182 |
QString toString(const QVariant&) const override; |
| 1183 |
QVariant value(const App::Property*) const override; |
| 1184 |
void setValue(const QVariant&) override; |
| 1185 |
|
| 1186 |
private: |
| 1187 |
PropertyColorItem* ambient; |
| 1188 |
PropertyColorItem* diffuse; |
| 1189 |
PropertyColorItem* specular; |
| 1190 |
PropertyColorItem* emissive; |
| 1191 |
PropertyIntegerConstraintItem* shininess; |
| 1192 |
PropertyIntegerConstraintItem* transparency; |
| 1193 |
}; |
| 1194 |
|
| 1195 |
class GuiExport PropertyMaterialListItem: public PropertyItem |
| 1196 |
{ |
| 1197 |
// clang-format off |
| 1198 |
Q_OBJECT |
| 1199 |
Q_PROPERTY(QColor AmbientColor READ getAmbientColor WRITE setAmbientColor DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 1200 |
Q_PROPERTY(QColor DiffuseColor READ getDiffuseColor WRITE setDiffuseColor DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 1201 |
Q_PROPERTY(QColor SpecularColor READ getSpecularColor WRITE setSpecularColor DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 1202 |
Q_PROPERTY(QColor EmissiveColor READ getEmissiveColor WRITE setEmissiveColor DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 1203 |
Q_PROPERTY(float Shininess READ getShininess WRITE setShininess DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 1204 |
Q_PROPERTY(float Transparency READ getTransparency WRITE setTransparency DESIGNABLE true USER true) // clazy:exclude=qproperty-without-notify |
| 1205 |
PROPERTYITEM_HEADER |
| 1206 |
// clang-format on |
| 1207 |
|
| 1208 |
QWidget* createEditor( |
| 1209 |
QWidget* parent, |
| 1210 |
const std::function<void()>& method, |
| 1211 |
FrameOption frameOption = FrameOption::NoFrame |
| 1212 |
) const override; |
| 1213 |
void setEditorData(QWidget* editor, const QVariant& data) const override; |
| 1214 |
QVariant editorData(QWidget* editor) const override; |
| 1215 |
|
| 1216 |
void propertyBound() override; |
| 1217 |
|
| 1218 |
QColor getAmbientColor() const; |
| 1219 |
void setAmbientColor(const QColor&); |
| 1220 |
QColor getDiffuseColor() const; |
| 1221 |
void setDiffuseColor(const QColor&); |
| 1222 |
QColor getSpecularColor() const; |
| 1223 |
void setSpecularColor(const QColor&); |
| 1224 |
QColor getEmissiveColor() const; |
| 1225 |
void setEmissiveColor(const QColor&); |
| 1226 |
int getShininess() const; |
| 1227 |
void setShininess(int); |
| 1228 |
int getTransparency() const; |
| 1229 |
void setTransparency(int); |
| 1230 |
|
| 1231 |
protected: |
| 1232 |
PropertyMaterialListItem(); |
| 1233 |
~PropertyMaterialListItem() override; |
| 1234 |
|
| 1235 |
QVariant decoration(const QVariant&) const override; |
| 1236 |
QVariant toolTip(const App::Property*) const override; |
| 1237 |
QString toString(const QVariant&) const override; |
| 1238 |
QVariant value(const App::Property*) const override; |
| 1239 |
void setValue(const QVariant&) override; |
| 1240 |
|
| 1241 |
private: |
| 1242 |
PropertyColorItem* ambient; |
| 1243 |
PropertyColorItem* diffuse; |
| 1244 |
PropertyColorItem* specular; |
| 1245 |
PropertyColorItem* emissive; |
| 1246 |
PropertyIntegerConstraintItem* shininess; |
| 1247 |
PropertyIntegerConstraintItem* transparency; |
| 1248 |
}; |
| 1249 |
|
| 1250 |
/** |
| 1251 |
* Change a file. |
| 1252 |
* \author Werner Mayer |
| 1253 |
*/ |
| 1254 |
class GuiExport PropertyFileItem: public PropertyItem |
| 1255 |
{ |
| 1256 |
Q_OBJECT |
| 1257 |
PROPERTYITEM_HEADER |
| 1258 |
|
| 1259 |
QWidget* createEditor( |
| 1260 |
QWidget* parent, |
| 1261 |
const std::function<void()>& method, |
| 1262 |
FrameOption frameOption = FrameOption::NoFrame |
| 1263 |
) const override; |
| 1264 |
void setEditorData(QWidget* editor, const QVariant& data) const override; |
| 1265 |
QVariant editorData(QWidget* editor) const override; |
| 1266 |
|
| 1267 |
protected: |
| 1268 |
QVariant value(const App::Property*) const override; |
| 1269 |
void setValue(const QVariant&) override; |
| 1270 |
|
| 1271 |
protected: |
| 1272 |
PropertyFileItem(); |
| 1273 |
QVariant toolTip(const App::Property*) const override; |
| 1274 |
}; |
| 1275 |
|
| 1276 |
/** |
| 1277 |
* Change a path. |
| 1278 |
* \author Werner Mayer |
| 1279 |
*/ |
| 1280 |
class GuiExport PropertyPathItem: public PropertyItem |
| 1281 |
{ |
| 1282 |
Q_OBJECT |
| 1283 |
PROPERTYITEM_HEADER |
| 1284 |
|
| 1285 |
QWidget* createEditor( |
| 1286 |
QWidget* parent, |
| 1287 |
const std::function<void()>& method, |
| 1288 |
FrameOption frameOption = FrameOption::NoFrame |
| 1289 |
) const override; |
| 1290 |
void setEditorData(QWidget* editor, const QVariant& data) const override; |
| 1291 |
QVariant editorData(QWidget* editor) const override; |
| 1292 |
|
| 1293 |
protected: |
| 1294 |
QVariant value(const App::Property*) const override; |
| 1295 |
void setValue(const QVariant&) override; |
| 1296 |
|
| 1297 |
protected: |
| 1298 |
PropertyPathItem(); |
| 1299 |
QVariant toolTip(const App::Property*) const override; |
| 1300 |
}; |
| 1301 |
|
| 1302 |
/** |
| 1303 |
* Show path of included file. |
| 1304 |
* \author Werner Mayer |
| 1305 |
*/ |
| 1306 |
class GuiExport PropertyTransientFileItem: public PropertyItem |
| 1307 |
{ |
| 1308 |
Q_OBJECT |
| 1309 |
PROPERTYITEM_HEADER |
| 1310 |
|
| 1311 |
QWidget* createEditor( |
| 1312 |
QWidget* parent, |
| 1313 |
const std::function<void()>& method, |
| 1314 |
FrameOption frameOption = FrameOption::NoFrame |
| 1315 |
) const override; |
| 1316 |
void setEditorData(QWidget* editor, const QVariant& data) const override; |
| 1317 |
QVariant editorData(QWidget* editor) const override; |
| 1318 |
|
| 1319 |
protected: |
| 1320 |
QVariant value(const App::Property*) const override; |
| 1321 |
void setValue(const QVariant&) override; |
| 1322 |
|
| 1323 |
protected: |
| 1324 |
PropertyTransientFileItem(); |
| 1325 |
QVariant toolTip(const App::Property*) const override; |
| 1326 |
}; |
| 1327 |
|
| 1328 |
class LinkSelection: public QObject |
| 1329 |
{ |
| 1330 |
Q_OBJECT |
| 1331 |
|
| 1332 |
public: |
| 1333 |
explicit LinkSelection(App::SubObjectT); |
| 1334 |
~LinkSelection() override; |
| 1335 |
|
| 1336 |
public Q_SLOTS: |
| 1337 |
void select(); |
| 1338 |
|
| 1339 |
private: |
| 1340 |
App::SubObjectT link; |
| 1341 |
}; |
| 1342 |
|
| 1343 |
|
| 1344 |
class LinkLabel: public QWidget |
| 1345 |
{ |
| 1346 |
Q_OBJECT |
| 1347 |
|
| 1348 |
public: |
| 1349 |
LinkLabel(QWidget* parent, const App::Property* prop); |
| 1350 |
~LinkLabel() override; |
| 1351 |
void updatePropertyLink(); |
| 1352 |
QVariant propertyLink() const; |
| 1353 |
|
| 1354 |
protected: |
| 1355 |
void resizeEvent(QResizeEvent*) override; |
| 1356 |
|
| 1357 |
protected Q_SLOTS: |
| 1358 |
void onLinkActivated(const QString&); |
| 1359 |
void onEditClicked(); |
| 1360 |
void onLinkChanged(); |
| 1361 |
|
| 1362 |
Q_SIGNALS: |
| 1363 |
void linkChanged(const QVariant&); |
| 1364 |
|
| 1365 |
private: |
| 1366 |
QLabel* label; |
| 1367 |
QPushButton* editButton; |
| 1368 |
QVariant link; |
| 1369 |
App::DocumentObjectT objProp; |
| 1370 |
|
| 1371 |
Gui::Dialog::DlgPropertyLink* dlg; |
| 1372 |
}; |
| 1373 |
|
| 1374 |
/** |
| 1375 |
* Edit properties of link type. |
| 1376 |
* \author Werner Mayer |
| 1377 |
*/ |
| 1378 |
class GuiExport PropertyLinkItem: public PropertyItem |
| 1379 |
{ |
| 1380 |
Q_OBJECT |
| 1381 |
PROPERTYITEM_HEADER |
| 1382 |
|
| 1383 |
QWidget* createEditor( |
| 1384 |
QWidget* parent, |
| 1385 |
const std::function<void()>& method, |
| 1386 |
FrameOption frameOption = FrameOption::NoFrame |
| 1387 |
) const override; |
| 1388 |
void setEditorData(QWidget* editor, const QVariant& data) const override; |
| 1389 |
QVariant editorData(QWidget* editor) const override; |
| 1390 |
|
| 1391 |
protected: |
| 1392 |
QString toString(const QVariant&) const override; |
| 1393 |
QVariant value(const App::Property*) const override; |
| 1394 |
void setValue(const QVariant&) override; |
| 1395 |
QVariant data(int column, int role) const override; |
| 1396 |
|
| 1397 |
protected: |
| 1398 |
PropertyLinkItem(); |
| 1399 |
}; |
| 1400 |
|
| 1401 |
/** |
| 1402 |
* Edit properties of link list type. |
| 1403 |
* \author Werner Mayer |
| 1404 |
*/ |
| 1405 |
class GuiExport PropertyLinkListItem: public PropertyLinkItem |
| 1406 |
{ |
| 1407 |
Q_OBJECT |
| 1408 |
PROPERTYITEM_HEADER |
| 1409 |
|
| 1410 |
protected: |
| 1411 |
PropertyLinkListItem(); |
| 1412 |
}; |
| 1413 |
|
| 1414 |
class PropertyItemEditorFactory: public QItemEditorFactory |
| 1415 |
{ |
| 1416 |
public: |
| 1417 |
PropertyItemEditorFactory(); |
| 1418 |
~PropertyItemEditorFactory() override; |
| 1419 |
|
| 1420 |
QWidget* createEditor(int userType, QWidget* parent) const override; |
| 1421 |
QByteArray valuePropertyName(int userType) const override; |
| 1422 |
}; |
| 1423 |
|
| 1424 |
} // namespace PropertyEditor |
| 1425 |
} // namespace Gui |
| 1426 |
|
| 1427 |
#endif // PROPERTYEDITORITEM_H |