-// 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"
/**
* 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()
/**
* 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;
}
/**
* 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;
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;
}
* 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();
/**
* 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);
blockList.setModified(false);
}
- RS_DEBUG->print("RS_Graphic::save ok");
+ RS_DEBUG->print("Drawing::save ok");
return ret;
}
/**
* 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;
/**
* 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;
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);
}
/**
* 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")
{
}
}
-/*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();
}
/**
* @return true if the grid is switched on (visible).
*/
-bool RS_Graphic::isGridOn()
+bool Drawing::isGridOn()
{
int on = getVariableInt("$GRIDMODE", 1);
return (on != 0);
/**
* Enables / disables the grid.
*/
-void RS_Graphic::setGridOn(bool on)
+void Drawing::setGridOn(bool on)
{
addVariable("$GRIDMODE", (int)on, 70);
}
/**
* 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));
/**
* Gets the unit of this graphic
*/
-RS2::Unit RS_Graphic::getUnit()
+RS2::Unit Drawing::getUnit()
{
return (RS2::Unit)getVariableInt("$INSUNITS", 0);
//return unit;
* @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);
* @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);
}
* @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);
* @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);
}
* 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));
}
/**
* Sets the PINSBASE variable.
*/
-void RS_Graphic::setPaperInsertionBase(const Vector & p)
+void Drawing::setPaperInsertionBase(const Vector & p)
{
addVariable("$PINSBASE", p, 10);
}
/**
* @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());
/**
* 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);
*
* @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);
/**
* 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);
/**
* @return Paper space scaling (DXF: $PSVPSCALE).
*/
-double RS_Graphic::getPaperScale()
+double Drawing::getPaperScale()
{
double ret;
/**
* Sets a new scale factor for the paper space.
*/
-void RS_Graphic::setPaperScale(double s)
+void Drawing::setPaperScale(double s)
{
addVariable("$PSVPSCALE", s, 40);
}
/**
* Centers drawing on page. Affects DXF variable $PINSBASE.
*/
-void RS_Graphic::centerToPage()
+void Drawing::centerToPage()
{
Vector size = getPaperSize();
double scale = getPaperScale();
/**
* 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);
* @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();
}
/**
* 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);
}
#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;
}
/**
* 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";