File indexing completed on 2024-04-28 03:51:15
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_GASGRAPHICS_H 0009 #define STEP_GASGRAPHICS_H 0010 0011 #include "worldgraphics.h" 0012 #include "stepgraphicsitem.h" 0013 #include "gascreationdialog.h" 0014 0015 0016 namespace StepCore { 0017 class Gas; 0018 } 0019 0020 class GasCreator: public ItemCreator 0021 { 0022 public: 0023 GasCreator(const QString& className, WorldModel* worldModel, WorldScene* worldScene) 0024 : ItemCreator(className, worldModel, worldScene) {} 0025 0026 bool sceneEvent(QEvent* event) override; 0027 void start() override; 0028 0029 protected: 0030 StepCore::Vector2d _topLeft; 0031 0032 public: 0033 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 0034 }; 0035 0036 class GasVertexHandlerGraphicsItem: public OnHoverHandlerGraphicsItem 0037 { 0038 Q_OBJECT 0039 0040 public: 0041 GasVertexHandlerGraphicsItem(StepCore::Item* item, WorldModel* worldModel, 0042 QGraphicsItem* parent, int vertexNum) 0043 : OnHoverHandlerGraphicsItem(item, worldModel, parent, nullptr, nullptr, vertexNum) {} 0044 0045 protected: 0046 StepCore::Gas* gas() const; 0047 StepCore::Vector2d value() override; 0048 void setValue(const StepCore::Vector2d& value) override; 0049 }; 0050 0051 class GasGraphicsItem: public StepGraphicsItem { 0052 public: 0053 GasGraphicsItem(StepCore::Item* item, WorldModel* worldModel); 0054 0055 QPainterPath shape() const override; 0056 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; 0057 0058 void viewScaleChanged() override; 0059 void stateChanged() override; 0060 void worldDataChanged(bool) override; 0061 0062 protected: 0063 void mouseSetPos(const QPointF& pos, const QPointF&, MovingState) override; 0064 OnHoverHandlerGraphicsItem* createOnHoverHandler(const QPointF& pos) override; 0065 StepCore::Gas* gas() const; 0066 0067 //ArrowHandlerGraphicsItem *_centerHandler; 0068 }; 0069 0070 namespace Ui { 0071 class WidgetCreateGasParticles; 0072 } 0073 0074 class GasCreationDialog; 0075 0076 0077 class GasMenuHandler: public ItemMenuHandler 0078 { 0079 Q_OBJECT 0080 0081 public: 0082 GasMenuHandler(StepCore::Object* object, WorldModel* worldModel, QObject* parent) 0083 : ItemMenuHandler(object, worldModel, parent) {} 0084 0085 void populateMenu(QMenu* menu, KActionCollection* actions) override; 0086 0087 public slots: 0088 void createGasParticles(); 0089 0090 protected slots: 0091 bool createGasParticlesApply(); 0092 void createGasParticlesCountChanged(); 0093 void createGasParticlesConcentrationChanged(); 0094 void clearGas(); 0095 0096 protected: 0097 StepCore::Gas* gas() const; 0098 Ui::WidgetCreateGasParticles* _createGasParticlesUi; 0099 GasCreationDialog *_creationDialog; 0100 0101 friend class GasCreationDialog; 0102 static const int MAX_PARTICLES = 200; 0103 // bool _confChanged; 0104 }; 0105 0106 #endif 0107