File indexing completed on 2024-12-01 08:18:29

0001 /***************************************************************************
0002  *   Copyright (C) 2004 by David Saxton                                    *
0003  *   david@bluehaze.org                                                    *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  ***************************************************************************/
0010 
0011 #ifndef MECHANICSDOCUMENT_H
0012 #define MECHANICSDOCUMENT_H
0013 
0014 #include "itemdocument.h"
0015 
0016 class KTechlab;
0017 class MechanicsGroup;
0018 class MechanicsItem;
0019 class MechanicsSimulation;
0020 
0021 typedef QList<MechanicsItem *> MechItemList;
0022 typedef QList<MechanicsItem *> MechanicsItemList;
0023 
0024 /**
0025 @author David Saxton
0026 */
0027 class MechanicsDocument : public ItemDocument
0028 {
0029     Q_OBJECT
0030 public:
0031     MechanicsDocument(const QString &caption);
0032     ~MechanicsDocument() override;
0033 
0034     View *createView(ViewContainer *viewContainer, uint viewAreaId) override;
0035 
0036     bool isValidItem(const QString &itemId) override;
0037     bool isValidItem(Item *item) override;
0038 
0039     void deleteSelection() override;
0040     void copy() override;
0041     void selectAll() override;
0042     ItemGroup *selectList() const override;
0043     MechanicsItem *mechanicsItemWithID(const QString &id);
0044     Item *addItem(const QString &id, const QPoint &p, bool newItem) override;
0045 
0046     /**
0047      * Adds a KtlQCanvasItem to the delete list to be deleted, when
0048      * flushDeleteList() is called
0049      */
0050     void appendDeleteList(KtlQCanvasItem *qcanvasItem) override;
0051     /**
0052      * Permantly deletes all items that have been added to the delete list with
0053      * the appendDeleteList( KtlQCanvasItem *qcanvasItem ) function.
0054      */
0055     void flushDeleteList() override;
0056     /**
0057      * Register an item with the ICNDocument.
0058      */
0059     bool registerItem(KtlQCanvasItem *qcanvasItem) override;
0060 
0061 protected:
0062     MechanicsGroup *m_selectList;
0063     MechanicsSimulation *m_mechanicsSimulation;
0064 };
0065 
0066 #endif