]> Shamusworld >> Repos - architektonas/commitdiff
Adding missing implementation.
authorShamus Hammons <jlhamm@acm.org>
Wed, 4 Aug 2010 13:36:40 +0000 (13:36 +0000)
committerShamus Hammons <jlhamm@acm.org>
Wed, 4 Aug 2010 13:36:40 +0000 (13:36 +0000)
src/base/rs_flags.cpp [new file with mode: 0644]
src/base/rs_pen.cpp [new file with mode: 0644]

diff --git a/src/base/rs_flags.cpp b/src/base/rs_flags.cpp
new file mode 100644 (file)
index 0000000..2dcba42
--- /dev/null
@@ -0,0 +1,68 @@
+// rs_flags.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// Portions copyright (C) 2001-2003 RibbonSoft
+// Copyright (C) 2010 Underground Software
+// See the README and GPLv2 files for licensing and warranty information
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  08/03/2010  Created this file. :-)
+//
+
+#include "rs_flags.h"
+
+/** Default constructor. Resets all flags to 0. */
+RS_Flags::RS_Flags()
+{
+       flags = 0;
+}
+
+/** Constructor with initialisation to the given flags. */
+RS_Flags::RS_Flags(unsigned int f)
+{
+       flags = f;
+}
+
+/*virtual*/ RS_Flags::~RS_Flags()
+{
+}
+
+unsigned int RS_Flags::getFlags() const
+{
+       return flags;
+}
+
+void RS_Flags::resetFlags()
+{
+       flags = 0;
+}
+
+void RS_Flags::setFlags(unsigned int f)
+{
+       flags = f;
+}
+
+void RS_Flags::setFlag(unsigned int f)
+{
+       flags = flags | f;
+}
+
+void RS_Flags::delFlag(unsigned int f)
+{
+       flags = flags & (~f);
+}
+
+void RS_Flags::toggleFlag(unsigned int f)
+{
+       flags = flags ^ f;
+}
+
+bool RS_Flags::getFlag(unsigned int f) const
+{
+       return (flags & f ? true : false);
+}
diff --git a/src/base/rs_pen.cpp b/src/base/rs_pen.cpp
new file mode 100644 (file)
index 0000000..2423cf4
--- /dev/null
@@ -0,0 +1,127 @@
+// rs_pen.cpp
+//
+// Part of the Architektonas Project
+// Originally part of QCad Community Edition by Andrew Mustun
+// Extensively rewritten and refactored by James L. Hammons
+// Portions copyright (C) 2001-2003 RibbonSoft
+// Copyright (C) 2010 Underground Software
+// See the README and GPLv2 files for licensing and warranty information
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  08/03/2010  Created this file. :-)
+//
+
+#include "rs_pen.h"
+
+/**
+ * Creates a default pen (black, solid, width 0).
+ */
+RS_Pen::RS_Pen(): RS_Flags()
+{
+       setColor(RS_Color(0, 0, 0));
+       setWidth(RS2::Width00);
+       setLineType(RS2::SolidLine);
+       setScreenWidth(0);
+}
+
+/**
+ * Creates a pen with the given attributes.
+ */
+RS_Pen::RS_Pen(const RS_Color & c, RS2::LineWidth w, RS2::LineType t): RS_Flags()
+{
+       setColor(c);
+       setWidth(w);
+       setLineType(t);
+       setScreenWidth(0);
+}
+
+/**
+ * Creates a default pen with the given flags. This is
+ * usually used to create invalid pens.
+ *
+ * e.g.:
+ * <pre>
+ *   RS_Pen p(RS2::FlagInvalid);
+ * </pre>
+ */
+RS_Pen::RS_Pen(unsigned int f): RS_Flags(f)
+{
+       setColor(RS_Color(0, 0, 0));
+       setWidth(RS2::Width00);
+       setLineType(RS2::SolidLine);
+       setScreenWidth(0);
+}
+
+/*virtual*/ RS_Pen::~RS_Pen()
+{
+}
+
+RS2::LineType RS_Pen::getLineType() const
+{
+       return lineType;
+}
+
+void RS_Pen::setLineType(RS2::LineType t)
+{
+       lineType = t;
+}
+
+RS2::LineWidth RS_Pen::getWidth() const
+{
+       return width;
+}
+
+void RS_Pen::setWidth(RS2::LineWidth w)
+{
+       width = w;
+}
+
+double RS_Pen::getScreenWidth() const
+{
+       return screenWidth;
+}
+
+void RS_Pen::setScreenWidth(double w)
+{
+       screenWidth = w;
+}
+
+const RS_Color & RS_Pen::getColor() const
+{
+       return color;
+}
+
+void RS_Pen::setColor(const RS_Color & c)
+{
+       color = c;
+}
+
+bool RS_Pen::isValid()
+{
+       return !getFlag(RS2::FlagInvalid);
+}
+
+bool RS_Pen::operator==(const RS_Pen & p) const
+{
+       return (lineType == p.lineType && width == p.width && color == p.color);
+}
+
+bool RS_Pen::operator!=(const RS_Pen & p) const
+{
+       return !(*this == p);
+}
+
+/*friend*/ std::ostream & operator<<(std::ostream & os, const RS_Pen & p)
+{
+       //os << "style: " << p.style << std::endl;
+       os << " pen color: " << p.getColor()
+       << " pen width: " << p.getWidth()
+       << " pen screen width: " << p.getScreenWidth()
+       << " pen line type: " << p.getLineType()
+       << " flags: " << (p.getFlag(RS2::FlagInvalid) ? "INVALID" : "")
+       << std::endl;
+       return os;
+}