]> Shamusworld >> Repos - architektonas/blobdiff - src/base/drawing.cpp
Changed RS_Graphic to Drawing; this is less confusing as a drawing is
[architektonas] / src / base / drawing.cpp
similarity index 70%
rename from src/base/rs_graphic.cpp
rename to src/base/drawing.cpp
index f2ed6048df0b1feeacf1645a7678f802f3f26891..dbdc1e2f8716e4c7abb3e2382f0087fd462b3172 100644 (file)
@@ -1,4 +1,4 @@
-// rs_graphic.cpp
+// drawing.cpp
 //
 // Part of the Architektonas Project
 // Originally part of QCad Community Edition by Andrew Mustun
 // Who  When        What
 // ---  ----------  -----------------------------------------------------------
 // JLH  05/21/2010  Added this text. :-)
+// JLH  06/02/2010  Changed all references of this class from RS_Graphic to
+//                  Drawing, as that makes it more clear that this is what it
+//                  is (a CAD drawing, not a bitmap).
 //
 
-#include "rs_graphic.h"
+#include "drawing.h"
 
 #include "rs_debug.h"
 #include "rs_fileio.h"
@@ -23,7 +26,7 @@
 /**
  * Default constructor.
  */
-RS_Graphic::RS_Graphic(RS_EntityContainer * parent): RS_Document(parent), layerList(),
+Drawing::Drawing(RS_EntityContainer * parent): RS_Document(parent), layerList(),
        blockList(true)
 #ifdef RS_CAM
        , camData()
@@ -58,12 +61,12 @@ RS_Graphic::RS_Graphic(RS_EntityContainer * parent): RS_Document(parent), layerL
 /**
  * Destructor.
  */
-RS_Graphic::~RS_Graphic()
+Drawing::~Drawing()
 {
 }
 
 /** @return RS2::EntityGraphic */
-/*virtual*/ RS2::EntityType RS_Graphic::rtti() const
+/*virtual*/ RS2::EntityType Drawing::rtti() const
 {
        return RS2::EntityGraphic;
 }
@@ -71,7 +74,7 @@ RS_Graphic::~RS_Graphic()
 /**
  * Counts the entities on the given layer.
  */
-unsigned long int RS_Graphic::countLayerEntities(RS_Layer * layer)
+unsigned long int Drawing::countLayerEntities(RS_Layer * layer)
 {
     int c = 0;
 
@@ -89,12 +92,12 @@ unsigned long int RS_Graphic::countLayerEntities(RS_Layer * layer)
     return c;
 }
 
-/*virtual*/ RS_LayerList * RS_Graphic::getLayerList()
+/*virtual*/ RS_LayerList * Drawing::getLayerList()
 {
        return &layerList;
 }
 
-/*virtual*/ RS_BlockList * RS_Graphic::getBlockList()
+/*virtual*/ RS_BlockList * Drawing::getBlockList()
 {
        return &blockList;
 }
@@ -103,9 +106,9 @@ unsigned long int RS_Graphic::countLayerEntities(RS_Layer * layer)
  * Clears all layers, blocks and entities of this graphic.
  * A default layer (0) is created.
  */
-void RS_Graphic::newDoc()
+void Drawing::newDoc()
 {
-       RS_DEBUG->print("RS_Graphic::newDoc");
+       RS_DEBUG->print("Drawing::newDoc");
 
        clear();
 
@@ -121,11 +124,11 @@ void RS_Graphic::newDoc()
 /**
  * Saves this graphic with the current filename and settings.
  */
-bool RS_Graphic::save()
+bool Drawing::save()
 {
        bool ret = false;
 
-       RS_DEBUG->print("RS_Graphic::save");
+       RS_DEBUG->print("Drawing::save");
        RS_DEBUG->print("  file: %s", filename.toLatin1().data());
        RS_DEBUG->print("  format: %d", (int)formatType);
 
@@ -139,7 +142,7 @@ bool RS_Graphic::save()
                blockList.setModified(false);
        }
 
-       RS_DEBUG->print("RS_Graphic::save ok");
+       RS_DEBUG->print("Drawing::save ok");
 
        return ret;
 }
@@ -147,9 +150,9 @@ bool RS_Graphic::save()
 /**
  * Saves this graphic with the given filename and current settings.
  */
-bool RS_Graphic::saveAs(const QString & filename, RS2::FormatType type)
+bool Drawing::saveAs(const QString & filename, RS2::FormatType type)
 {
-       RS_DEBUG->print("RS_Graphic::saveAs");
+       RS_DEBUG->print("Drawing::saveAs");
 
        this->filename = filename;
        this->formatType = type;
@@ -160,9 +163,9 @@ bool RS_Graphic::saveAs(const QString & filename, RS2::FormatType type)
 /**
  * Loads the given fils into this graphic.
  */
-bool RS_Graphic::open(const QString &filename, RS2::FormatType type)
+bool Drawing::open(const QString &filename, RS2::FormatType type)
 {
-       RS_DEBUG->print("RS_Graphic::open(%s)", filename.toLatin1().data());
+       RS_DEBUG->print("Drawing::open(%s)", filename.toLatin1().data());
 
        bool ret = false;
 
@@ -178,46 +181,46 @@ bool RS_Graphic::open(const QString &filename, RS2::FormatType type)
        layerList.setModified(false);
        blockList.setModified(false);
 
-       //cout << *((RS_Graphic*)graphic);
+       //cout << *((Drawing*)graphic);
        //calculateBorders();
 
-       RS_DEBUG->print("RS_Graphic::open(%s): OK", filename.toLatin1().data());
+       RS_DEBUG->print("Drawing::open(%s): OK", filename.toLatin1().data());
 
        return ret;
 }
 
 // Wrappers for Layer functions:
-void RS_Graphic::clearLayers()
+void Drawing::clearLayers()
 {
        layerList.clear();
 }
 
-uint RS_Graphic::countLayers() const
+uint Drawing::countLayers() const
 {
        return layerList.count();
 }
 
-RS_Layer * RS_Graphic::layerAt(uint i)
+RS_Layer * Drawing::layerAt(uint i)
 {
        return layerList.at(i);
 }
 
-void RS_Graphic::activateLayer(const QString & name)
+void Drawing::activateLayer(const QString & name)
 {
        layerList.activate(name);
 }
 
-void RS_Graphic::activateLayer(RS_Layer * layer)
+void Drawing::activateLayer(RS_Layer * layer)
 {
        layerList.activate(layer);
 }
 
-RS_Layer * RS_Graphic::getActiveLayer()
+RS_Layer * Drawing::getActiveLayer()
 {
        return layerList.getActive();
 }
 
-/*virtual*/ void RS_Graphic::addLayer(RS_Layer * layer)
+/*virtual*/ void Drawing::addLayer(RS_Layer * layer)
 {
        layerList.add(layer);
 }
@@ -225,7 +228,7 @@ RS_Layer * RS_Graphic::getActiveLayer()
 /**
  * Removes the given layer and undoes all entities on it.
  */
-/*virtual*/ void RS_Graphic::removeLayer(RS_Layer * layer)
+/*virtual*/ void Drawing::removeLayer(RS_Layer * layer)
 {
        if (layer != NULL && layer->getName() != "0")
        {
@@ -267,186 +270,186 @@ RS_Layer * RS_Graphic::getActiveLayer()
        }
 }
 
-/*virtual*/ void RS_Graphic::editLayer(RS_Layer * layer, const RS_Layer & source)
+/*virtual*/ void Drawing::editLayer(RS_Layer * layer, const RS_Layer & source)
 {
        layerList.edit(layer, source);
 }
 
-RS_Layer * RS_Graphic::findLayer(const QString & name)
+RS_Layer * Drawing::findLayer(const QString & name)
 {
        return layerList.find(name);
 }
 
-void RS_Graphic::toggleLayer(const QString & name)
+void Drawing::toggleLayer(const QString & name)
 {
        layerList.toggle(name);
 }
 
-void RS_Graphic::toggleLayer(RS_Layer * layer)
+void Drawing::toggleLayer(RS_Layer * layer)
 {
        layerList.toggle(layer);
 }
 
-void RS_Graphic::toggleLayerLock(RS_Layer * layer)
+void Drawing::toggleLayerLock(RS_Layer * layer)
 {
        layerList.toggleLock(layer);
 }
 
-void RS_Graphic::freezeAllLayers(bool freeze)
+void Drawing::freezeAllLayers(bool freeze)
 {
        layerList.freezeAll(freeze);
 }
 
-void RS_Graphic::addLayerListListener(RS_LayerListListener * listener)
+void Drawing::addLayerListListener(RS_LayerListListener * listener)
 {
        layerList.addListener(listener);
 }
 
-void RS_Graphic::removeLayerListListener(RS_LayerListListener * listener)
+void Drawing::removeLayerListListener(RS_LayerListListener * listener)
 {
        layerList.removeListener(listener);
 }
 
 // Wrapper for block functions:
 
-void RS_Graphic::clearBlocks()
+void Drawing::clearBlocks()
 {
        blockList.clear();
 }
 
-uint RS_Graphic::countBlocks()
+uint Drawing::countBlocks()
 {
        return blockList.count();
 }
 
-RS_Block * RS_Graphic::blockAt(uint i)
+RS_Block * Drawing::blockAt(uint i)
 {
        return blockList.at(i);
 }
 
-void RS_Graphic::activateBlock(const QString & name)
+void Drawing::activateBlock(const QString & name)
 {
        blockList.activate(name);
 }
 
-void RS_Graphic::activateBlock(RS_Block * block)
+void Drawing::activateBlock(RS_Block * block)
 {
        blockList.activate(block);
 }
 
-RS_Block * RS_Graphic::getActiveBlock()
+RS_Block * Drawing::getActiveBlock()
 {
        return blockList.getActive();
 }
 
-/*virtual*/ bool RS_Graphic::addBlock(RS_Block * block, bool notify/*= true*/)
+/*virtual*/ bool Drawing::addBlock(RS_Block * block, bool notify/*= true*/)
 {
        return blockList.add(block, notify);
 }
 
-/*virtual*/ void RS_Graphic::addBlockNotification()
+/*virtual*/ void Drawing::addBlockNotification()
 {
        blockList.addNotification();
 }
 
-/*virtual*/ void RS_Graphic::removeBlock(RS_Block * block)
+/*virtual*/ void Drawing::removeBlock(RS_Block * block)
 {
        blockList.remove(block);
 }
 
-RS_Block * RS_Graphic::findBlock(const QString & name)
+RS_Block * Drawing::findBlock(const QString & name)
 {
        return blockList.find(name);
 }
 
-QString RS_Graphic::newBlockName()
+QString Drawing::newBlockName()
 {
        return blockList.newName();
 }
 
-void RS_Graphic::toggleBlock(const QString & name)
+void Drawing::toggleBlock(const QString & name)
 {
        blockList.toggle(name);
 }
 
-void RS_Graphic::toggleBlock(RS_Block * block)
+void Drawing::toggleBlock(RS_Block * block)
 {
        blockList.toggle(block);
 }
 
-void RS_Graphic::freezeAllBlocks(bool freeze)
+void Drawing::freezeAllBlocks(bool freeze)
 {
        blockList.freezeAll(freeze);
 }
 
-void RS_Graphic::addBlockListListener(RS_BlockListListener * listener)
+void Drawing::addBlockListListener(RS_BlockListListener * listener)
 {
        blockList.addListener(listener);
 }
 
-void RS_Graphic::removeBlockListListener(RS_BlockListListener * listener)
+void Drawing::removeBlockListListener(RS_BlockListListener * listener)
 {
        blockList.removeListener(listener);
 }
 
 // Wrappers for variable functions:
-void RS_Graphic::clearVariables()
+void Drawing::clearVariables()
 {
        variableDict.clear();
 }
 
-int RS_Graphic::countVariables()
+int Drawing::countVariables()
 {
        return variableDict.count();
 }
 
-void RS_Graphic::addVariable(const QString & key, const Vector & value, int code)
+void Drawing::addVariable(const QString & key, const Vector & value, int code)
 {
        variableDict.add(key, value, code);
 }
 
-void RS_Graphic::addVariable(const QString & key, const QString & value, int code)
+void Drawing::addVariable(const QString & key, const QString & value, int code)
 {
        variableDict.add(key, value, code);
 }
 
-void RS_Graphic::addVariable(const QString & key, int value, int code)
+void Drawing::addVariable(const QString & key, int value, int code)
 {
        variableDict.add(key, value, code);
 }
 
-void RS_Graphic::addVariable(const QString & key, double value, int code)
+void Drawing::addVariable(const QString & key, double value, int code)
 {
        variableDict.add(key, value, code);
 }
 
-Vector RS_Graphic::getVariableVector(const QString & key, const Vector & def)
+Vector Drawing::getVariableVector(const QString & key, const Vector & def)
 {
        return variableDict.getVector(key, def);
 }
 
-QString RS_Graphic::getVariableString(const QString & key, const QString & def)
+QString Drawing::getVariableString(const QString & key, const QString & def)
 {
        return variableDict.getString(key, def);
 }
 
-int RS_Graphic::getVariableInt(const QString & key, int def)
+int Drawing::getVariableInt(const QString & key, int def)
 {
        return variableDict.getInt(key, def);
 }
 
-double RS_Graphic::getVariableDouble(const QString & key, double def)
+double Drawing::getVariableDouble(const QString & key, double def)
 {
        return variableDict.getDouble(key, def);
 }
 
-void RS_Graphic::removeVariable(const QString & key)
+void Drawing::removeVariable(const QString & key)
 {
        variableDict.remove(key);
 }
 
 //Q3Dict<RS_Variable> & getVariableDict()
-QMultiHash<QString, RS_Variable *> & RS_Graphic::getVariableDict()
+QMultiHash<QString, RS_Variable *> & Drawing::getVariableDict()
 {
        return variableDict.getVariableDict();
 }
@@ -454,7 +457,7 @@ QMultiHash<QString, RS_Variable *> & RS_Graphic::getVariableDict()
 /**
  * @return true if the grid is switched on (visible).
  */
-bool RS_Graphic::isGridOn()
+bool Drawing::isGridOn()
 {
        int on = getVariableInt("$GRIDMODE", 1);
        return (on != 0);
@@ -463,7 +466,7 @@ bool RS_Graphic::isGridOn()
 /**
  * Enables / disables the grid.
  */
-void RS_Graphic::setGridOn(bool on)
+void Drawing::setGridOn(bool on)
 {
        addVariable("$GRIDMODE", (int)on, 70);
 }
@@ -471,7 +474,7 @@ void RS_Graphic::setGridOn(bool on)
 /**
  * Sets the unit of this graphic to 'u'
  */
-void RS_Graphic::setUnit(RS2::Unit u)
+void Drawing::setUnit(RS2::Unit u)
 {
        setPaperSize(RS_Units::convert(getPaperSize(), getUnit(), u));
 
@@ -483,7 +486,7 @@ void RS_Graphic::setUnit(RS2::Unit u)
 /**
  * Gets the unit of this graphic
  */
-RS2::Unit RS_Graphic::getUnit()
+RS2::Unit Drawing::getUnit()
 {
        return (RS2::Unit)getVariableInt("$INSUNITS", 0);
        //return unit;
@@ -493,7 +496,7 @@ RS2::Unit RS_Graphic::getUnit()
  * @return The linear format type for this document.
  * This is determined by the variable "$LUNITS".
  */
-RS2::LinearFormat RS_Graphic::getLinearFormat()
+RS2::LinearFormat Drawing::getLinearFormat()
 {
        int lunits = getVariableInt("$LUNITS", 2);
 
@@ -528,7 +531,7 @@ RS2::LinearFormat RS_Graphic::getLinearFormat()
  * @return The linear precision for this document.
  * This is determined by the variable "$LUPREC".
  */
-int RS_Graphic::getLinearPrecision()
+int Drawing::getLinearPrecision()
 {
        return getVariableInt("$LUPREC", 4);
 }
@@ -537,7 +540,7 @@ int RS_Graphic::getLinearPrecision()
  * @return The angle format type for this document.
  * This is determined by the variable "$AUNITS".
  */
-RS2::AngleFormat RS_Graphic::getAngleFormat()
+RS2::AngleFormat Drawing::getAngleFormat()
 {
        int aunits = getVariableInt("$AUNITS", 0);
 
@@ -572,7 +575,7 @@ RS2::AngleFormat RS_Graphic::getAngleFormat()
  * @return The linear precision for this document.
  * This is determined by the variable "$LUPREC".
  */
-int RS_Graphic::getAnglePrecision()
+int Drawing::getAnglePrecision()
 {
        return getVariableInt("$AUPREC", 4);
 }
@@ -582,7 +585,7 @@ int RS_Graphic::getAnglePrecision()
  * This is the distance from the lower left paper edge to the zero
  * point of the drawing. DXF: $PINSBASE.
  */
-Vector RS_Graphic::getPaperInsertionBase()
+Vector Drawing::getPaperInsertionBase()
 {
        return getVariableVector("$PINSBASE", Vector(0.0,0.0));
 }
@@ -590,7 +593,7 @@ Vector RS_Graphic::getPaperInsertionBase()
 /**
  * Sets the PINSBASE variable.
  */
-void RS_Graphic::setPaperInsertionBase(const Vector & p)
+void Drawing::setPaperInsertionBase(const Vector & p)
 {
        addVariable("$PINSBASE", p, 10);
 }
@@ -598,7 +601,7 @@ void RS_Graphic::setPaperInsertionBase(const Vector & p)
 /**
  * @return Paper size in graphic units.
  */
-Vector RS_Graphic::getPaperSize()
+Vector Drawing::getPaperSize()
 {
        Vector def = RS_Units::convert(Vector(210.0, 297.0), RS2::Millimeter, getUnit());
 
@@ -611,7 +614,7 @@ Vector RS_Graphic::getPaperSize()
 /**
  * Sets a new paper size.
  */
-void RS_Graphic::setPaperSize(const Vector & s)
+void Drawing::setPaperSize(const Vector & s)
 {
        addVariable("$PLIMMIN", Vector(0.0, 0.0), 10);
        addVariable("$PLIMMAX", s, 10);
@@ -623,7 +626,7 @@ void RS_Graphic::setPaperSize(const Vector & s)
  *
  * @param landscape will be set to true for landscape and false for portrait if not NULL.
  */
-RS2::PaperFormat RS_Graphic::getPaperFormat(bool * landscape)
+RS2::PaperFormat Drawing::getPaperFormat(bool * landscape)
 {
        Vector size = RS_Units::convert(getPaperSize(), getUnit(), RS2::Millimeter);
 
@@ -636,7 +639,7 @@ RS2::PaperFormat RS_Graphic::getPaperFormat(bool * landscape)
 /**
  * Sets the paper format to the given format.
  */
-void RS_Graphic::setPaperFormat(RS2::PaperFormat f, bool landscape)
+void Drawing::setPaperFormat(RS2::PaperFormat f, bool landscape)
 {
        Vector size = RS_Units::paperFormatToSize(f);
 
@@ -654,7 +657,7 @@ void RS_Graphic::setPaperFormat(RS2::PaperFormat f, bool landscape)
 /**
  * @return Paper space scaling (DXF: $PSVPSCALE).
  */
-double RS_Graphic::getPaperScale()
+double Drawing::getPaperScale()
 {
        double ret;
 
@@ -669,7 +672,7 @@ double RS_Graphic::getPaperScale()
 /**
  * Sets a new scale factor for the paper space.
  */
-void RS_Graphic::setPaperScale(double s)
+void Drawing::setPaperScale(double s)
 {
        addVariable("$PSVPSCALE", s, 40);
 }
@@ -677,7 +680,7 @@ void RS_Graphic::setPaperScale(double s)
 /**
  * Centers drawing on page. Affects DXF variable $PINSBASE.
  */
-void RS_Graphic::centerToPage()
+void Drawing::centerToPage()
 {
        Vector size = getPaperSize();
        double scale = getPaperScale();
@@ -688,7 +691,7 @@ void RS_Graphic::centerToPage()
 /**
  * Fits drawing on page. Affects DXF variable $PINSBASE.
  */
-void RS_Graphic::fitToPage()
+void Drawing::fitToPage()
 {
        double border = RS_Units::convert(25.0, RS2::Millimeter, getUnit());
        Vector ps = getPaperSize() - Vector(border, border);
@@ -713,7 +716,7 @@ void RS_Graphic::fitToPage()
  * @retval true The document has been modified since it was last saved.
  * @retval false The document has not been modified since it was last saved.
  */
-/*virtual*/ bool RS_Graphic::isModified() const
+/*virtual*/ bool Drawing::isModified() const
 {
        return modified || layerList.isModified() || blockList.isModified();
 }
@@ -721,7 +724,7 @@ void RS_Graphic::fitToPage()
 /**
  * Sets the documents modified status to 'm'.
  */
-/*virtual*/ void RS_Graphic::setModified(bool m)
+/*virtual*/ void Drawing::setModified(bool m)
 {
        modified = m;
        layerList.setModified(m);
@@ -729,12 +732,12 @@ void RS_Graphic::fitToPage()
 }
 
 #ifdef RS_CAM
-RS_CamData & RS_Graphic::getCamData()
+RS_CamData & Drawing::getCamData()
 {
        return camData;
 }
 
-void RS_Graphic::setCamData(const RS_CamData & d)
+void Drawing::setCamData(const RS_CamData & d)
 {
        camData = d;
 }
@@ -743,9 +746,9 @@ void RS_Graphic::setCamData(const RS_CamData & d)
 /**
  * Dumps the entities to stdout.
  */
-std::ostream & operator<<(std::ostream & os, RS_Graphic & g)
+std::ostream & operator<<(std::ostream & os, Drawing & g)
 {
-    os << "--- Graphic: \n";
+    os << "--- Drawing: \n";
     os << "---" << *g.getLayerList() << "\n";
     os << "---" << *g.getBlockList() << "\n";
     os << "---" << (RS_Undo&)g << "\n";