1 /* This file is part of Step. 2 Copyright (C) 2007 Vladimir Kuznetsov <ks.vladimir@gmail.com> 3 Copyright (C) 2014 Inge Wallin <inge@lysator.liu.se> 4 5 Step is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 2 of the License, or 8 (at your option) any later version. 9 10 Step is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with Step; if not, write to the Free Software 17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 */ 19 20 #ifndef STEP_GASGRAPHICS_H 21 #define STEP_GASGRAPHICS_H 22 23 #include "worldgraphics.h" 24 #include "stepgraphicsitem.h" 25 #include "gascreationdialog.h" 26 27 28 namespace StepCore { 29 class Gas; 30 } 31 32 class GasCreator: public ItemCreator 33 { 34 public: GasCreator(const QString & className,WorldModel * worldModel,WorldScene * worldScene)35 GasCreator(const QString& className, WorldModel* worldModel, WorldScene* worldScene) 36 : ItemCreator(className, worldModel, worldScene) {} 37 38 bool sceneEvent(QEvent* event) override; 39 void start() override; 40 41 protected: 42 StepCore::Vector2d _topLeft; 43 44 public: 45 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 46 }; 47 48 class GasVertexHandlerGraphicsItem: public OnHoverHandlerGraphicsItem 49 { 50 Q_OBJECT 51 52 public: GasVertexHandlerGraphicsItem(StepCore::Item * item,WorldModel * worldModel,QGraphicsItem * parent,int vertexNum)53 GasVertexHandlerGraphicsItem(StepCore::Item* item, WorldModel* worldModel, 54 QGraphicsItem* parent, int vertexNum) 55 : OnHoverHandlerGraphicsItem(item, worldModel, parent, NULL, NULL, vertexNum) {} 56 57 protected: 58 StepCore::Gas* gas() const; 59 StepCore::Vector2d value() override; 60 void setValue(const StepCore::Vector2d& value) override; 61 }; 62 63 class GasGraphicsItem: public StepGraphicsItem { 64 public: 65 GasGraphicsItem(StepCore::Item* item, WorldModel* worldModel); 66 67 QPainterPath shape() const override; 68 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; 69 70 void viewScaleChanged() override; 71 void stateChanged() override; 72 void worldDataChanged(bool) override; 73 74 protected: 75 void mouseSetPos(const QPointF& pos, const QPointF&, MovingState) override; 76 OnHoverHandlerGraphicsItem* createOnHoverHandler(const QPointF& pos) override; 77 StepCore::Gas* gas() const; 78 79 //ArrowHandlerGraphicsItem *_centerHandler; 80 }; 81 82 namespace Ui { 83 class WidgetCreateGasParticles; 84 } 85 86 class GasCreationDialog; 87 88 89 class GasMenuHandler: public ItemMenuHandler 90 { 91 Q_OBJECT 92 93 public: GasMenuHandler(StepCore::Object * object,WorldModel * worldModel,QObject * parent)94 GasMenuHandler(StepCore::Object* object, WorldModel* worldModel, QObject* parent) 95 : ItemMenuHandler(object, worldModel, parent) {} 96 97 void populateMenu(QMenu* menu, KActionCollection* actions) override; 98 99 public slots: 100 void createGasParticles(); 101 102 protected slots: 103 bool createGasParticlesApply(); 104 void createGasParticlesCountChanged(); 105 void createGasParticlesConcentrationChanged(); 106 void clearGas(); 107 108 protected: 109 StepCore::Gas* gas() const; 110 Ui::WidgetCreateGasParticles* _createGasParticlesUi; 111 GasCreationDialog *_creationDialog; 112 113 friend class GasCreationDialog; 114 static const int MAX_PARTICLES = 200; 115 // bool _confChanged; 116 }; 117 118 #endif 119 120