| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
|
|
| #ifndef RS_GRAPHIC_H |
| #define RS_GRAPHIC_H |
|
|
| #include <memory> |
| #include <QDateTime> |
|
|
| #include "lc_dimstyle.h" |
| #include "lc_ucslist.h" |
| #include "lc_viewslist.h" |
| #include "rs_blocklist.h" |
| #include "rs_document.h" |
| #include "rs_layerlist.h" |
| #include "rs_variabledict.h" |
| #include "lc_dimstyleslist.h" |
| #include "lc_textstylelist.h" |
|
|
| class RS_Dimension; |
| class LC_DimStyleToVariablesMapper; |
| class LC_DimStylesList; |
| class QString; |
|
|
| class LC_View; |
| class QG_LayerWidget; |
|
|
| class LC_GraphicModificationListener { |
| public: |
| virtual ~LC_GraphicModificationListener() = default; |
| virtual void graphicModified(const RS_Graphic* g, bool modified) = 0; |
| virtual void undoStateChanged(const RS_Graphic* g, bool undoAvailable, bool redoAvailable) = 0; |
| }; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| class RS_Graphic : public RS_Document { |
| public: |
| RS_Graphic(RS_EntityContainer* parent=nullptr); |
| ~RS_Graphic() override; |
|
|
| virtual void onLoadingCompleted(); |
| |
| RS2::EntityType rtti() const override {return RS2::EntityGraphic;} |
|
|
| virtual unsigned countLayerEntities(RS_Layer* layer) const; |
|
|
| RS_LayerList* getLayerList() override {return &layerList;} |
| RS_BlockList* getBlockList() override {return &blockList;} |
| LC_ViewList* getViewList() override {return &namedViewsList;} |
| LC_UCSList* getUCSList() override {return &ucsList;} |
| LC_DimStylesList* getDimStyleList() override {return &dimstyleList;} |
| LC_TextStyleList* getTextStyleList() override {return &textStyleList;} |
| void addDimStyle(LC_DimStyle* style) {dimstyleList.addDimStyle(style);} |
| void newDoc() override; |
| |
| void clearLayers() {layerList.clear();} |
| unsigned countLayers() const {return layerList.count();} |
| RS_Layer* layerAt(unsigned i) {return layerList.at(i);} |
| void activateLayer(const QString& name, bool notify = false) {layerList.activate(name, notify);} |
| void activateLayer(RS_Layer* layer, bool notify = false) {layerList.activate(layer, notify);} |
| RS_Layer* getActiveLayer() const {return layerList.getActive();} |
| virtual void addLayer(RS_Layer* layer) {layerList.add(layer);} |
| void addEntity(RS_Entity* entity) override; |
| void removeLayer(RS_Layer* layer); |
| void editLayer(RS_Layer* layer, const RS_Layer& source) {layerList.edit(layer, source);} |
| RS_Layer* findLayer(const QString& name) {return layerList.find(name);} |
| void toggleLayer(const QString& name) {layerList.toggle(name);} |
| void toggleLayer(RS_Layer* layer) {layerList.toggle(layer);} |
| void toggleLayerLock(RS_Layer* layer) {layerList.toggleLock(layer);} |
| void toggleLayerPrint(RS_Layer* layer) {layerList.togglePrint(layer);} |
| void toggleLayerConstruction(RS_Layer* layer) {layerList.toggleConstruction(layer);} |
| void freezeAllLayers(bool freeze) {layerList.freezeAll(freeze);} |
| void lockAllLayers(bool lock) {layerList.lockAll(lock);} |
| void addLayerListListener(RS_LayerListListener* listener) {layerList.addListener(listener);} |
| void removeLayerListListener(RS_LayerListListener* listener) {layerList.removeListener(listener);} |
|
|
| void addViewListListener(LC_ViewListListener* listener) { namedViewsList.addListener(listener);} |
| void removeViewListListener(LC_ViewListListener* listener) { namedViewsList.removeListener(listener);} |
|
|
| |
| void clearBlocks() {blockList.clear();} |
| unsigned countBlocks() {return blockList.count();} |
| RS_Block* blockAt(unsigned i) {return blockList.at(i);} |
| void activateBlock(const QString& name) {blockList.activate(name);} |
| void activateBlock(RS_Block* block) {blockList.activate(block);} |
| RS_Block* getActiveBlock() const {return blockList.getActive();} |
| bool addBlock(RS_Block* block, bool notify=true) {return blockList.add(block, notify);} |
| void addBlockNotification() {blockList.addNotification();} |
| void removeBlock(RS_Block* block) {blockList.remove(block);} |
| RS_Block* findBlock(const QString& name) {return blockList.find(name);} |
| QString newBlockName() {return blockList.newName();} |
| void toggleBlock(const QString& name) {blockList.toggle(name);} |
| void toggleBlock(RS_Block* block) {blockList.toggle(block);} |
| void freezeAllBlocks(bool freeze) {blockList.freezeAll(freeze);} |
| void addBlockListListener(RS_BlockListListener* listener) {blockList.addListener(listener);} |
| void removeBlockListListener(RS_BlockListListener* listener) {blockList.removeListener(listener);} |
|
|
| |
| void clearVariables(); |
| QString getCustomProperty(const QString& key, const QString& defaultValue); |
| void addCustomProperty(const QString& key, const QString& value); |
| void removeCustomProperty(const QString& key); |
| bool hasCustomProperty(const QString& key); |
| const QHash<QString, RS_Variable>& getCustomProperties() const; |
| int countVariables() const; |
|
|
| void addVariable(const QString& key, const RS_Vector& value, int code); |
| void addVariable(const QString& key, const QString& value, int code); |
| void addVariable(const QString& key, int value, int code); |
| void addVariable(const QString& key, bool value, int code); |
| void addVariable(const QString& key, double value, int code); |
| void removeVariable(const QString& key); |
|
|
| QHash<QString, RS_Variable>& getVariableDict(); |
| RS_Vector getVariableVector(const QString& key, const RS_Vector& def) const; |
| QString getVariableString(const QString& key, const QString& def) const; |
| int getVariableInt(const QString& key, int def) const; |
| bool getVariableBool(const QString& key, bool def) const; |
| double getVariableDouble(const QString& key, double def) const; |
|
|
| void setVariableDictObject(RS_VariableDict inputVariableDict) {m_variableDict = inputVariableDict;} |
|
|
| RS_VariableDict getVariableDictObject() const{ |
| return m_variableDict; |
| } |
|
|
| RS_VariableDict* getVariableDictObjectRef() { |
| return &m_variableDict; |
| } |
|
|
| RS2::LinearFormat getLinearFormat() const; |
| void replaceCustomVars(const QHash<QString, QString>& hash); |
| virtual void prepareForSave(); |
|
|
| static RS2::LinearFormat convertLinearFormatDXF2LC(int f); |
| int getLinearPrecision() const; |
| RS2::AngleFormat getAngleFormat() const; |
| int getAnglePrecision() const; |
|
|
| RS_Vector getPaperSize() const; |
| void setPaperSize(const RS_Vector& s); |
| RS_Vector getPrintAreaSize(bool total=true) const; |
|
|
| RS_Vector getPaperInsertionBase(); |
| void setPaperInsertionBase(const RS_Vector& p); |
|
|
| RS2::PaperFormat getPaperFormat(bool* landscape); |
| void setPaperFormat(RS2::PaperFormat f, bool landscape); |
|
|
| double getPaperScale() const; |
| void setPaperScale(double s); |
|
|
| virtual void setUnit(RS2::Unit u); |
| virtual RS2::Unit getUnit() const; |
|
|
| bool isGridOn() const; |
| void setGridOn(bool on); |
| bool isIsometricGrid() const; |
| void setIsometricGrid(bool on); |
| void setCurrentUCS(LC_UCS* ucs); |
| LC_UCS* getCurrentUCS() const; |
| RS2::IsoGridViewType getIsoView() const; |
| void setIsoView(RS2::IsoGridViewType viewType); |
| void centerToPage(); |
| bool fitToPage(); |
| bool isBiggerThanPaper(); |
| |
| |
| |
| |
| bool isModified() const override; |
| |
| |
| |
| void setModified(bool m) override; |
| void markSaved(const QDateTime &lastSaveTime); |
|
|
| QDateTime getLastSaveTime(){return lastSaveTime;} |
| void setLastSaveTime(const QDateTime &time) { lastSaveTime = time;} |
|
|
| |
| void setPaperScaleFixed(bool fixed){paperScaleFixed=fixed;} |
| bool getPaperScaleFixed() const{return paperScaleFixed;} |
|
|
| |
| |
| |
| void setMargins(double left, double top, double right, double bottom){ |
| if (left >= 0.0) marginLeft = left; |
| if (top >= 0.0) marginTop = top; |
| if (right >= 0.0) marginRight = right; |
| if (bottom >= 0.0) marginBottom = bottom; |
| } |
|
|
| double getMarginLeft() const{return marginLeft;} |
| double getMarginTop() const{return marginTop;} |
| double getMarginRight() const{ return marginRight;} |
| double getMarginBottom() const{return marginBottom;} |
|
|
| |
| |
| |
| void setMarginsInUnits(double left, double top, double right, double bottom); |
| double getMarginLeftInUnits(); |
| double getMarginTopInUnits(); |
| double getMarginRightInUnits(); |
| double getMarginBottomInUnits(); |
| |
| |
| |
| void setPagesNum(int horiz, int vert); |
| void setPagesNum(const QString &horizXvert); |
| int getPagesNumHoriz() const {return pagesNumH;} |
| int getPagesNumVert() const {return pagesNumV;} |
| friend std::ostream& operator << (std::ostream& os, RS_Graphic& g); |
| int clean(); |
| LC_View *findNamedView(QString viewName) {return namedViewsList.find(viewName);}; |
| LC_UCS *findNamedUCS(QString ucsName) {return ucsList.find(ucsName);}; |
| void addNamedView(LC_View *view) {namedViewsList.add(view);}; |
| void addUCS(LC_UCS *ucs) {ucsList.add(ucs);}; |
|
|
| double getAnglesBase() const; |
| void setAnglesBase(double baseAngle); |
| bool areAnglesCounterClockWise() const; |
| void setAnglesCounterClockwise(bool on); |
| QString formatAngle(double angle) const; |
| QString formatLinear(double linear) const; |
|
|
| RS2::FormatType getFormatType() const; |
|
|
| void setFormatType(RS2::FormatType formatType); |
|
|
| |
| |
| |
| |
| QString getFilename() const {return filename;} |
|
|
| |
| |
| |
| QString getAutoSaveFileName() const {return autosaveFilename;} |
|
|
| |
| |
| |
| void setFilename(QString fn) {filename = std::move(fn);} |
|
|
| const QString &getAutosaveFilename() const; |
|
|
| void setAutosaveFileName(const QString &autosaveFilename); |
|
|
| void setModificationListener(LC_GraphicModificationListener * listener) {m_modificationListener = listener;} |
|
|
| LC_DimStyle* getFallBackDimStyleFromVars() const; |
| LC_DimStyle* getDimStyleByName(const QString &name, RS2::EntityType dimType = RS2::EntityUnknown) const; |
| QString getDefaultDimStyleName() const; |
| void setDefaultDimStyleName(QString name); |
| LC_DimStyle* getEffectiveDimStyle(const QString &styleName, RS2::EntityType dimType, LC_DimStyle* styleOverride) const; |
| virtual LC_DimStyle* getResolvedDimStyle(const QString &dimStyleName, RS2::EntityType dimType = RS2::EntityUnknown) const; |
| void updateFallbackDimStyle(LC_DimStyle* get_copy); |
| void replaceDimStylesList(const QString& defaultStyleName, const QList<LC_DimStyle*>& styles); |
| protected: |
| void fireUndoStateChanged(bool undoAvailable, bool redoAvailable) const override; |
| private: |
| QDateTime lastSaveTime; |
| QString currentFileName; |
|
|
| |
| RS_LayerList layerList{}; |
| RS_BlockList blockList{true}; |
| RS_VariableDict m_variableDict; |
| RS_VariableDict m_customVariablesDict; |
| LC_ViewList namedViewsList; |
| LC_UCSList ucsList; |
| LC_DimStylesList dimstyleList; |
| LC_TextStyleList textStyleList; |
|
|
| |
| bool paperScaleFixed = false; |
|
|
| |
| RS2::FormatType formatType = RS2::FormatUnknown; |
|
|
| |
| double marginLeft = 0.; |
| double marginTop = 0.; |
| double marginRight = 0.; |
| double marginBottom = 0.; |
|
|
| |
| int pagesNumH = 1; |
| int pagesNumV = 1; |
|
|
| |
| QString filename; |
| |
| QString autosaveFilename; |
|
|
| LC_GraphicModificationListener* m_modificationListener = nullptr; |
| }; |
| #endif |
|
|