File indexing completed on 2024-04-28 07:39:39
0001 /*. 0002 SPDX-FileCopyrightText: 2007 Vladimir Kuznetsov <ks.vladimir@gmail.com> 0003 SPDX-FileCopyrightText: 2014 Inge Wallin <inge@lysator.liu.se> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef STEP_SOFTBODYGRAPHICS_H 0009 #define STEP_SOFTBODYGRAPHICS_H 0010 0011 #include "worldgraphics.h" 0012 #include "particlegraphics.h" 0013 #include "springgraphics.h" 0014 0015 namespace Ui { 0016 class WidgetCreateSoftBodyItems; 0017 } 0018 0019 namespace StepCore{ 0020 class SoftBody; 0021 } 0022 0023 class SoftBodyCreator: public ItemCreator 0024 { 0025 public: 0026 SoftBodyCreator(const QString& className, WorldModel* worldModel, WorldScene* worldScene) 0027 : ItemCreator(className, worldModel, worldScene) {} 0028 0029 bool sceneEvent(QEvent* event) override; 0030 void start() override; 0031 0032 public: 0033 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 0034 }; 0035 0036 class QDialog; 0037 class SoftBodyMenuHandler: public ItemMenuHandler 0038 { 0039 Q_OBJECT 0040 0041 public: 0042 SoftBodyMenuHandler(StepCore::Object* object, WorldModel* worldModel, QObject* parent) 0043 : ItemMenuHandler(object, worldModel, parent), _applied(false) {} 0044 0045 void populateMenu(QMenu* menu, KActionCollection* actions) override; 0046 0047 bool applied() const { return _applied; } 0048 0049 public slots: 0050 void createSoftBodyItems(const StepCore::Vector2d& pos); 0051 0052 protected slots: 0053 void createSoftBodyItemsApply(); 0054 void clearSoftBody(); 0055 0056 protected: 0057 StepCore::SoftBody* softBody() const; 0058 Ui::WidgetCreateSoftBodyItems* _createSoftBodyItemsUi; 0059 QDialog* _createSoftBodyItemsDialog; 0060 bool _applied; 0061 // bool _confChanged; 0062 }; 0063 0064 class SoftBodyGraphicsItem: public StepGraphicsItem 0065 { 0066 public: 0067 SoftBodyGraphicsItem(StepCore::Item* item, WorldModel* worldModel); 0068 0069 QPainterPath shape() const override; 0070 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; 0071 0072 void viewScaleChanged() override; 0073 void stateChanged() override; 0074 void worldDataChanged(bool dynamicOnly) override; 0075 0076 protected: 0077 void mouseSetPos(const QPointF& pos, const QPointF& diff, MovingState) override; 0078 StepCore::SoftBody* softBody() const; 0079 QPainterPath _painterPath; 0080 0081 ArrowHandlerGraphicsItem *_velocityHandler; 0082 0083 static const int RADIUS = 7; 0084 }; 0085 0086 class SoftBodyParticleGraphicsItem: public ParticleGraphicsItem 0087 { 0088 public: 0089 SoftBodyParticleGraphicsItem(StepCore::Item* item, WorldModel* worldModel) 0090 : ParticleGraphicsItem(item, worldModel) {} 0091 0092 void worldDataChanged(bool dynamicOnly) override; 0093 }; 0094 0095 class SoftBodySpringGraphicsItem: public SpringGraphicsItem 0096 { 0097 public: 0098 SoftBodySpringGraphicsItem(StepCore::Item* item, WorldModel* worldModel) 0099 : SpringGraphicsItem(item, worldModel) {} 0100 0101 void worldDataChanged(bool dynamicOnly) override; 0102 }; 0103 0104 #endif 0105