Skip to content

Commit

Permalink
Merge pull request LibreCAD#3 from gaganjyot/master
Browse files Browse the repository at this point in the history
Text operations, reference -> copy
  • Loading branch information
rvt committed May 20, 2014
2 parents 06b74ad + f393c35 commit 68a8310
Show file tree
Hide file tree
Showing 16 changed files with 308 additions and 34 deletions.
2 changes: 1 addition & 1 deletion lckernel/cad/geometry/geoarc.cpp
Expand Up @@ -32,7 +32,7 @@ double Arc::endAngle() const {
return _endAngle;
}

const Coordinate& Arc::center() const {
const Coordinate Arc::center() const {
return _center;
}

Expand Down
2 changes: 1 addition & 1 deletion lckernel/cad/geometry/geoarc.h
Expand Up @@ -10,7 +10,7 @@ namespace lc {
public:
Arc(const Coordinate& center, double radius, double startAngle, double endAngle);

const Coordinate& center() const;
const Coordinate center() const;

/*!
* \brief Returns the radius of Arc.
Expand Down
4 changes: 2 additions & 2 deletions lckernel/cad/geometry/geoarea.cpp
Expand Up @@ -15,10 +15,10 @@ Area::Area(const Coordinate& coordA, const Coordinate& coordB) :

}

const Coordinate& Area::minP() const {
const Coordinate Area::minP() const {
return _minP;
}
const Coordinate& Area::maxP() const {
const Coordinate Area::maxP() const {
return _maxP;
}

Expand Down
4 changes: 2 additions & 2 deletions lckernel/cad/geometry/geoarea.h
Expand Up @@ -24,12 +24,12 @@ namespace lc {
/**
* Return the smalles corner (closest to (0,0,0) )
*/
const Coordinate& minP() const;
const Coordinate minP() const;

/**
* Return the heigest corner
*/
const Coordinate& maxP() const;
const Coordinate maxP() const;

/**
* Test of a specific point lies within a area
Expand Down
2 changes: 1 addition & 1 deletion lckernel/cad/geometry/geocircle.cpp
Expand Up @@ -11,7 +11,7 @@ Circle::Circle(const Coordinate& center, double radius) : _center(center) {
_radius = radius;
}

const Coordinate& Circle::center() const {
const Coordinate Circle::center() const {
return _center;
}
double Circle::radius() const {
Expand Down
2 changes: 1 addition & 1 deletion lckernel/cad/geometry/geocircle.h
Expand Up @@ -15,7 +15,7 @@ namespace lc {
* \brief Returns the Center of circle.
* \return lc::geo::Coordinate Center.
*/
const Coordinate& center() const;
const Coordinate center() const;

/*!
* \brief returns the radius of the circle.
Expand Down
4 changes: 2 additions & 2 deletions lckernel/cad/geometry/geoellipse.cpp
Expand Up @@ -16,11 +16,11 @@ Ellipse::Ellipse(const Coordinate& center, const Coordinate& majorP, double mino
_endAngle = endAngle;
}

const Coordinate& Ellipse::center() const {
const Coordinate Ellipse::center() const {
return _center;
}

const Coordinate& Ellipse::majorP() const {
const Coordinate Ellipse::majorP() const {
return _majorP;
}

Expand Down
4 changes: 2 additions & 2 deletions lckernel/cad/geometry/geoellipse.h
Expand Up @@ -10,8 +10,8 @@ namespace lc {
public:
Ellipse(const Coordinate& center, const Coordinate& majorP, double minorRadius, double startAngle, double endAngle, bool isArc = false);

const Coordinate& center() const;
const Coordinate& majorP() const;
const Coordinate center() const;
const Coordinate majorP() const;
double minorRadius() const;
double startAngle() const;
double endAngle() const;
Expand Down
2 changes: 1 addition & 1 deletion lckernel/cad/geometry/geospline.cpp
Expand Up @@ -8,7 +8,7 @@ Spline::Spline(const std::vector<Coordinate>& control_points, int degree, bool c
_closed = closed;
}

const std::vector<Coordinate>& Spline::control_points() const {
const std::vector<Coordinate> Spline::control_points() const {
return _control_points;
}

Expand Down
2 changes: 1 addition & 1 deletion lckernel/cad/geometry/geospline.h
Expand Up @@ -11,7 +11,7 @@ namespace lc {
public:
Spline(const std::vector<Coordinate>& control_points, int degree, bool closed);

const std::vector<Coordinate>& control_points() const;
const std::vector<Coordinate> control_points() const;

int degree() const;

Expand Down
49 changes: 45 additions & 4 deletions lckernel/cad/geometry/geotext.cpp
Expand Up @@ -3,24 +3,65 @@
using namespace lc;
using namespace geo;

Text::Text(const Coordinate& insertion_point, double height, std::string text_value) : _insertion_point(insertion_point) {
Text::Text(const Coordinate &insertion_point,
const Coordinate& second_point, const double height,
const std::string text_value, const double width_rel,
const double angle, const std::string style,
const TextGeneration textgeneration,
const HAlign halign, const VAlign valign) :
_insertion_point(insertion_point), _second_point(second_point) {

_height = height;
_text_value = text_value;
_width_rel = width_rel;
_angle = angle;
_style = style;
_textgeneration = textgeneration;
_halign = halign;
_valign = valign;

_height = height;
_text_value = text_value;
}

const Coordinate& Text::insertion_point() const {
const Coordinate Text::insertion_point() const {
return _insertion_point;
}

const Coordinate Text::second_point() const {
return _second_point;
}

double Text::height() const {
return _height;
}

double Text::width_rel() const {
return _width_rel;
}

double Text::angle() const {
return _angle;
}

std::string Text::text_value() const {
return _text_value;
}

std::string Text::style() const {
return _style;
}

Text::TextGeneration Text::textgeneration() const {
return _textgeneration;
}

Text::HAlign Text::halign() const {
return _halign;
}

Text::VAlign Text::valign() const {
return _valign;
}

Coordinate Text::nearestPointOnPath(const Coordinate& coord) const {
//return;
}
Expand Down
148 changes: 143 additions & 5 deletions lckernel/cad/geometry/geotext.h
Expand Up @@ -7,21 +7,159 @@

namespace lc {
namespace geo {
/**
* @brief The Text class
* Reference : http://www.autodesk.com/techpubs/autocad/acad2000/dxf/text_dxf_06.htm
*/
class Text {
public:
Text(const Coordinate& insertion_point, double height, std::string text_value);
/**
* Vertical alignments.
*/
enum VAlign {
VABaseline, /**< Bottom */
VABottom, /**< Bottom */
VAMiddle, /**< Middle */
VATop /**< Top. */
};

const Coordinate& insertion_point() const;
/**
* Horizontal alignments.
*/
enum HAlign {
HALeft, /**< Left */
HACenter, /**< Centered */
HARight, /**< Right */
HAAligned, /**< Aligned */
HAMiddle, /**< Middle */
HAFit /**< Fit */
};

/**
* Text drawing direction.
*/
enum TextGeneration {
None, /**< Normal text */
Backward, /**< Mirrored in X */
UpsideDown /**< Mirrored in Y */
};
/**
* @brief Text Entity
* @param insertion_point insertion_point of the text
* @param second_point second_point of text in UCS
* @param height height of the text
* @param text_value the text itself
* @param width_rel X scale factor-width
* @param angle angle of obliqueness
* @param style name of text style
* @param textgeneration Text drawing direction
* @param halign Horizontal alignment
* @param valign Vertical alignment
*/
Text(const Coordinate& insertion_point,
const Coordinate& second_point, const double height,
const std::string text_value, const double width_rel,
const double angle, const std::string style,
const TextGeneration textgeneration,
const HAlign halign, const VAlign valign);

/**
* @brief Insertion point of text
* First alignment point (in OCS)
* DXF: X value; APP: 3D point
* DXF: Y and Z values of first alignment point (in OCS)
* @return Coordinate insertion_point
*/
const Coordinate insertion_point() const;

/**
* @brief Height of text
* Text height. code 40
* @return double height
*/
double height() const;

/**
* @brief text value of the text
* Text value itself. code 1
* @return string text value.
*/
std::string text_value() const;

/**
* @brief Second point
* Second alignment point (in OCS) (optional)
* DXF: X value; APP: 3D point
* This value is meaningful only if the value of a 72 or 73 group is nonzero
* (if the justification is anything other than baseline/left).
* DXF: Y and Z values of second alignment point (in OCS) (optional)
* @return Coordinate second point.
*/
const Coordinate second_point() const;

/**
* @brief X factor relative width
* Relative X scale factor-width (optional; default = 1)
* This value is also adjusted when fit-type text is used.
* @return double X factor relative width
*/
double width_rel() const;

/**
* @brief angle
* Oblique angle (optional; default = 0)
* @return double oblique angle
*/
double angle() const;

/**
* @brief style
* Text style name (optional, default = STANDARD)
* @return string style name
*/
std::string style() const;

/**
* @brief textgeneration
* Text generation flags (optional, default = 0):
* 2 = Text is backward (mirrored in X).
* 4 = Text is upside down (mirrored in Y).
* @return
*/
TextGeneration textgeneration() const;

/**
* @brief halign
* Horizontal text justification type (optional, default = 0) integer codes (not bit-coded)
* 0 = Left; 1= Center; 2 = Right
* 3 = Aligned (if vertical alignment = 0)
* 4 = Middle (if vertical alignment = 0)
* 5 = Fit (if vertical alignment = 0)
* See the Group 72 and 73 integer codes table for clarification.
* @return
*/
HAlign halign() const;

/**
* @brief valign
* Vertical text justification type (optional, default = 0): integer codes (not bit- coded):
* 0 = Baseline; 1 = Bottom; 2 = Middle; 3 = Top
* See the Group 72 and 73 integer codes table for clarification.
* @return
*/
VAlign valign() const;

Coordinate nearestPointOnPath(const Coordinate& coord) const;
bool isCoordinateOnPath(const Coordinate& coord) const;

private:
const Coordinate _insertion_point;
double _height;
std::string _text_value;
const Coordinate _insertion_point, _second_point;
double _height, _width_rel, _angle;
VAlign _valign;
HAlign _halign;
TextGeneration _textgeneration;
std::string _style, _text_value;

};
}
}
Expand Down
4 changes: 2 additions & 2 deletions lckernel/cad/geometry/geovector.cpp
Expand Up @@ -11,10 +11,10 @@ Vector::Vector(const Coordinate& start, const Coordinate& end) : _start(start),
Vector::Vector(const Vector& v) : _start(v._start), _end(v._end) {
}

const Coordinate& Vector::start() const {
const Coordinate Vector::start() const {
return _start;
}
const Coordinate& Vector::end() const {
const Coordinate Vector::end() const {
return _end;
}

Expand Down
4 changes: 2 additions & 2 deletions lckernel/cad/geometry/geovector.h
Expand Up @@ -12,8 +12,8 @@ namespace lc {
Vector(const Coordinate& start, const Coordinate& end);
Vector(const Vector& v);

const Coordinate& start() const;
const Coordinate& end() const;
const Coordinate start() const;
const Coordinate end() const;

Coordinate nearestPointOnPath(const geo::Coordinate& coord) const;
bool isCoordinateOnPath(const Coordinate& coord) const;
Expand Down

0 comments on commit 68a8310

Please sign in to comment.