[DEV] continue dimention integration...

This commit is contained in:
Edouard DUPIN 2015-12-07 21:32:20 +01:00
parent d3162ad4c3
commit effc33ef14
6 changed files with 268 additions and 311 deletions

View File

@ -134,53 +134,80 @@ void esvg::Base::parsePosition(const std::shared_ptr<const exml::Element>& _elem
}
}
float esvg::Base::parseLength(const std::string& _dataInput) {
std::pair<float, enum esvg::distance> esvg::Base::parseLength2(const std::string& _dataInput) {
SVG_VERBOSE(" lenght : '" << _dataInput << "'");
float n = stof(_dataInput);
std::string unit;
for (int32_t iii=0; iii<_dataInput.size(); iii++) {
for (int32_t iii=0; iii<_dataInput.size(); ++iii) {
if( (_dataInput[iii]>='0' && _dataInput[iii]<='9')
|| _dataInput[iii]<='+'
|| _dataInput[iii]<='-'
|| _dataInput[iii]<='.') {
|| _dataInput[iii]=='+'
|| _dataInput[iii]=='-'
|| _dataInput[iii]=='.') {
continue;
}
unit = std::string(_dataInput, iii-1);
unit = std::string(_dataInput, iii);
break;
}
//SVG_INFO(" == > ?? = " << n );
float font_size = 20.0f;
SVG_VERBOSE(" lenght : '" << n << "' => unit=" << unit);
// note : ";" is for the parsing of the style elements ...
if( unit.size() == 0
|| unit[0] == ';' ) {
return n;
return std::make_pair(n, esvg::distance_pixel);
} else if (unit[0] == '%') { // xxx %
return n / 100.0 * m_paint.viewPort.x();
return std::make_pair(n, esvg::distance_pourcent);
} else if ( unit[0] == 'e'
&& unit[1] == 'm') { // xxx em
return n * font_size;
return std::make_pair(n, esvg::distance_element);
} else if ( unit[0] == 'e'
&& unit[1] == 'x') { // xxx ex
return n / 2.0f * font_size;
return std::make_pair(n, esvg::distance_ex);
} else if ( unit[0] == 'p'
&& unit[1] == 'x') { // xxx px
return n;
return std::make_pair(n, esvg::distance_pixel);
} else if ( unit[0] == 'p'
&& unit[1] == 't') { // xxx pt
return n * 1.25f;
return std::make_pair(n, esvg::distance_point);
} else if ( unit[0] == 'p'
&& unit[1] == 'c') { // xxx pc
return n * 15.0f;
return std::make_pair(n, esvg::distance_pc);
} else if ( unit[0] == 'm'
&& unit[1] == 'm') { // xxx mm
return n * 3.543307f;
return std::make_pair(n, esvg::distance_millimeter);
} else if ( unit[0] == 'c'
&& unit[1] == 'm') { // xxx cm
return n * 35.43307f;
return std::make_pair(n, esvg::distance_centimeter);
} else if ( unit[0] == 'i'
&& unit[1] == 'n') { // xxx in
return n * 90.0f;
return std::make_pair(n, esvg::distance_inch);
}
return std::make_pair(0.0f, esvg::distance_pixel);
}
float esvg::Base::parseLength(const std::string& _dataInput) {
std::pair<float, enum esvg::distance> value = parseLength2(_dataInput);
SVG_VERBOSE(" lenght : '" << value.first << "' => unit=" << value.second);
float font_size = 20.0f;
switch (value.second) {
case esvg::distance_pourcent:
return value.first / 100.0 * m_paint.viewPort.x();
case esvg::distance_element:
return value.first * font_size;
case esvg::distance_ex:
return value.first / 2.0f * font_size;
case esvg::distance_pixel:
return value.first;
case esvg::distance_point:
return value.first * 1.25f;
case esvg::distance_pc:
return value.first * 15.0f;
case esvg::distance_millimeter:
return value.first * 3.543307f;
case esvg::distance_centimeter:
return value.first * 35.43307f;
case esvg::distance_inch:
return value.first * 90.0f;
}
return 0.0f;
}

View File

@ -21,6 +21,7 @@
#include <exml/exml.h>
#include <esvg/Renderer.h>
#include <esvg/Dimension.h>
namespace esvg {
extern const float kappa90; //!< proportional lenght to the radius of a bezier handle for 90° arcs.
@ -82,9 +83,10 @@ namespace esvg {
/**
* @brief parse a lenght of the xml element
* @param[in] _dataInput Data C String with the printed lenght
* @return standart number of pixels
* @return standard number of pixels
*/
float parseLength(const std::string& _dataInput);
std::pair<float, enum esvg::distance> parseLength2(const std::string& _dataInput);
/**
* @brief parse a Painting attribute of a specific node
* @param[in] _element Basic node of the XML that might be parsed

View File

@ -6,19 +6,12 @@
* @license APACHE v2.0 (see license file)
*/
#include <gale/Dimension.h>
#include <gale/debug.h>
#include <esvg/Dimension.h>
#include <esvg/debug.h>
#undef __class__
#define __class__ "Dimension"
// TODO : set this in a super class acced in a statin fuction...
// ratio in milimeter :
static bool isInit = false;
static vec2 ratio(9999999,888888);
static vec2 invRatio(1,1);
static gale::Dimension windowsSize(vec2(9999999,888888), gale::Dimension::Pixel);
static const float inchToMillimeter = 1.0f/25.4f;
static const float footToMillimeter = 1.0f/304.8f;
static const float meterToMillimeter = 1.0f/1000.0f;
@ -30,287 +23,259 @@ static const float millimeterToMeter =1000.0f;
static const float millimeterToCentimeter = 10.0f;
static const float millimeterToKilometer = 1000000.0f;
// 72 px /inch(2.54cm)
static const float basicRatio = 72.0f / 25.4f;
void gale::Dimension::init() {
if (true == isInit) {
return;
}
gale::Dimension conversion(vec2(72,72), gale::Dimension::Inch);
ratio = conversion.getMillimeter();
invRatio.setValue(1.0f/ratio.x(),1.0f/ratio.y());
windowsSize.set(vec2(200,200), gale::Dimension::Pixel);
isInit = true;
}
void gale::Dimension::unInit() {
isInit = false;
ratio.setValue(9999999,888888);
invRatio.setValue(1.0f/ratio.x(),1.0f/ratio.y());
windowsSize.set(vec2(9999999,88888), gale::Dimension::Pixel);
}
void gale::Dimension::setPixelRatio(const vec2& _ratio, enum gale::Dimension::distance _type) {
gale::Dimension::init();
GALE_INFO("Set a new screen ratio for the screen : ratio=" << _ratio << " type=" << _type);
gale::Dimension conversion(_ratio, _type);
GALE_INFO(" == > " << conversion);
ratio = conversion.getMillimeter();
invRatio.setValue(1.0f/ratio.x(),1.0f/ratio.y());
GALE_INFO("Set a new screen ratio for the screen : ratioMm=" << ratio);
}
void gale::Dimension::setPixelWindowsSize(const vec2& _size) {
windowsSize = _size;
GALE_VERBOSE("Set a new Windows property size " << windowsSize << "px");
}
vec2 gale::Dimension::getWindowsSize(enum gale::Dimension::distance _type) {
return windowsSize.get(_type);
}
float gale::Dimension::getWindowsDiag(enum gale::Dimension::distance _type) {
vec2 size = gale::Dimension::getWindowsSize(_type);
return size.length();
}
gale::Dimension::Dimension() :
esvg::Dimension::Dimension() :
m_data(0,0),
m_type(gale::Dimension::Pixel) {
m_type(esvg::distance_pixel) {
// notinh to do ...
}
gale::Dimension::Dimension(const vec2& _size, enum gale::Dimension::distance _type) :
esvg::Dimension::Dimension(const vec2& _size, enum esvg::distance _type) :
m_data(0,0),
m_type(gale::Dimension::Pixel) {
m_type(esvg::distance_pixel) {
set(_size, _type);
}
void gale::Dimension::set(std::string _config) {
void esvg::Dimension::set(std::string _config) {
m_data.setValue(0,0);
m_type = gale::Dimension::Pixel;
enum distance type = gale::Dimension::Pixel;
m_type = esvg::distance_pixel;
enum distance type = esvg::distance_pixel;
if (etk::end_with(_config, "%", false) == true) {
type = gale::Dimension::Pourcent;
type = esvg::distance_pourcent;
_config.erase(_config.size()-1, 1);
} else if (etk::end_with(_config, "px",false) == true) {
type = gale::Dimension::Pixel;
type = esvg::distance_pixel;
_config.erase(_config.size()-2, 2);
} else if (etk::end_with(_config, "ft",false) == true) {
type = gale::Dimension::foot;
type = esvg::distance_foot;
_config.erase(_config.size()-2, 2);
} else if (etk::end_with(_config, "in",false) == true) {
type = gale::Dimension::Inch;
type = esvg::distance_inch;
_config.erase(_config.size()-2, 2);
} else if (etk::end_with(_config, "km",false) == true) {
type = gale::Dimension::Kilometer;
type = esvg::distance_kilometer;
_config.erase(_config.size()-2, 2);
} else if (etk::end_with(_config, "mm",false) == true) {
type = gale::Dimension::Millimeter;
type = esvg::distance_millimeter;
_config.erase(_config.size()-2, 2);
} else if (etk::end_with(_config, "cm",false) == true) {
type = gale::Dimension::Centimeter;
type = esvg::distance_centimeter;
_config.erase(_config.size()-2, 2);
} else if (etk::end_with(_config, "m",false) == true) {
type = gale::Dimension::Meter;
type = esvg::distance_meter;
_config.erase(_config.size()-1, 1);
} else {
GALE_CRITICAL("Can not parse dimention : \"" << _config << "\"");
SVG_CRITICAL("Can not parse dimention : \"" << _config << "\"");
return;
}
vec2 tmp = _config;
set(tmp, type);
GALE_VERBOSE(" config dimention : \"" << _config << "\" == > " << *this );
SVG_VERBOSE(" config dimention : \"" << _config << "\" == > " << *this );
}
gale::Dimension::~Dimension() {
static enum distance parseType(std::string& _config) {
enum distance type = esvg::distance_pixel;
if (etk::end_with(_config, "%", false) == true) {
type = esvg::distance_pourcent;
_config.erase(_config.size()-1, 1);
} else if (etk::end_with(_config, "px",false) == true) {
type = esvg::distance_pixel;
_config.erase(_config.size()-2, 2);
} else if (etk::end_with(_config, "ft",false) == true) {
type = esvg::distance_foot;
_config.erase(_config.size()-2, 2);
} else if (etk::end_with(_config, "in",false) == true) {
type = esvg::distance_inch;
_config.erase(_config.size()-2, 2);
} else if (etk::end_with(_config, "km",false) == true) {
type = esvg::distance_kilometer;
_config.erase(_config.size()-2, 2);
} else if (etk::end_with(_config, "mm",false) == true) {
type = esvg::distance_millimeter;
_config.erase(_config.size()-2, 2);
} else if (etk::end_with(_config, "cm",false) == true) {
type = esvg::distance_centimeter;
_config.erase(_config.size()-2, 2);
} else if (etk::end_with(_config, "m",false) == true) {
type = esvg::distance_meter;
_config.erase(_config.size()-1, 1);
} else {
SVG_CRITICAL("Can not parse dimention : \"" << _config << "\"");
}
return type;
}
void esvg::Dimension::set(std::string _configX, std::string _configY) {
m_data.setValue(0,0);
m_type = esvg::distance_pixel;
enum distance type = esvg::distance_pixel;
// First Parse X
enum distance typeX = parseType(_configX);
float valueX = etk::string_to_float(_configX);
// Second Parse Y
enum distance typeY = parseType(_configY);
float valueY = etk::string_to_float(_configY);
// TODO : Check difference ...
set(vec2(valueX, valueY), typeX);
SVG_VERBOSE(" config dimention : \"" << _config << "\" == > " << *this );
}
esvg::Dimension::~Dimension() {
// nothing to do ...
}
gale::Dimension::operator std::string() const {
esvg::Dimension::operator std::string() const {
std::string str;
str = get(getType());
str = getValue();
switch(getType()) {
case gale::Dimension::Pourcent:
case esvg::distance_pourcent:
str += "%";
break;
case gale::Dimension::Pixel:
case esvg::distance_pixel:
str += "px";
break;
case gale::Dimension::Meter:
case esvg::distance_meter:
str += "m";
break;
case gale::Dimension::Centimeter:
case esvg::distance_centimeter:
str += "cm";
break;
case gale::Dimension::Millimeter:
case esvg::distance_millimeter:
str += "mm";
break;
case gale::Dimension::Kilometer:
case esvg::distance_kilometer:
str += "km";
break;
case gale::Dimension::Inch:
case esvg::distance_inch:
str += "in";
break;
case gale::Dimension::foot:
case esvg::distance_foot:
str += "ft";
break;
case esvg::distance_element:
str += "em";
break;
case esvg::distance_ex:
str += "ex";
break;
case esvg::distance_point:
str += "pt";
break;
case esvg::distance_pc:
str += "pc";
break;
}
return str;
}
vec2 gale::Dimension::get(enum gale::Dimension::distance _type) const {
switch(_type) {
case gale::Dimension::Pourcent:
return getPourcent();
case gale::Dimension::Pixel:
return getPixel();
case gale::Dimension::Meter:
return getMeter();
case gale::Dimension::Centimeter:
return getCentimeter();
case gale::Dimension::Millimeter:
return getMillimeter();
case gale::Dimension::Kilometer:
return getKilometer();
case gale::Dimension::Inch:
return getInch();
case gale::Dimension::foot:
return getFoot();
}
return vec2(0,0);
}
void gale::Dimension::set(const vec2& _size, enum gale::Dimension::distance _type) {
// set min max on input to limit error :
vec2 size(std::avg(0.0f,_size.x(),9999999.0f),
std::avg(0.0f,_size.y(),9999999.0f));
switch(_type) {
case gale::Dimension::Pourcent: {
vec2 size2(std::avg(0.0f,_size.x(),100.0f),
std::avg(0.0f,_size.y(),100.0f));
m_data = vec2(size2.x()*0.01f, size2.y()*0.01f);
//GALE_VERBOSE("Set % : " << size2 << " == > " << m_data);
break;
}
case gale::Dimension::Pixel:
m_data = size;
break;
case gale::Dimension::Meter:
m_data = vec2(size.x()*meterToMillimeter*ratio.x(), size.y()*meterToMillimeter*ratio.y());
break;
case gale::Dimension::Centimeter:
m_data = vec2(size.x()*centimeterToMillimeter*ratio.x(), size.y()*centimeterToMillimeter*ratio.y());
break;
case gale::Dimension::Millimeter:
m_data = vec2(size.x()*ratio.x(), size.y()*ratio.y());
break;
case gale::Dimension::Kilometer:
m_data = vec2(size.x()*kilometerToMillimeter*ratio.x(), size.y()*kilometerToMillimeter*ratio.y());
break;
case gale::Dimension::Inch:
m_data = vec2(size.x()*inchToMillimeter*ratio.x(), size.y()*inchToMillimeter*ratio.y());
break;
case gale::Dimension::foot:
m_data = vec2(size.x()*footToMillimeter*ratio.x(), size.y()*footToMillimeter*ratio.y());
break;
}
void esvg::Dimension::set(const vec2& _size, enum esvg::distance _type) {
m_data = _size;
m_type = _type;
}
vec2 gale::Dimension::getPixel() const {
if (m_type!=gale::Dimension::Pourcent) {
return m_data;
} else {
vec2 windDim = windowsSize.getPixel();
vec2 res = vec2(windDim.x()*m_data.x(), windDim.y()*m_data.y());
//GALE_DEBUG("Get % : " << m_data << " / " << windDim << " == > " << res);
return res;
switch(_type) {
case esvg::distance_pourcent:
case esvg::distance_pixel:
// nothing to do: Supported ...
break;
case esvg::distance_meter:
case esvg::distance_centimeter:
case esvg::distance_millimeter:
case esvg::distance_kilometer:
case esvg::distance_inch:
case esvg::distance_foot:
case esvg::distance_element:
case esvg::distance_ex:
case esvg::distance_point:
case esvg::distance_pc:
SVG_ERROR("Does not support other than Px and % type of dimention : " << _type << " automaticly convert with {72,72} pixel/inch");
break;
}
}
vec2 gale::Dimension::getPourcent() const {
if (m_type!=gale::Dimension::Pourcent) {
vec2 windDim = windowsSize.getPixel();
//GALE_DEBUG(" windows dimention : " /*<< windowsSize*/ << " == > " << windDim << "px"); // ==> infinite loop ...
//printf(" windows dimention : %f,%f", windDim.x(),windDim.y());
//printf(" data : %f,%f", m_data.x(),m_data.y());
return vec2((m_data.x()/windDim.x())*100.0f, (m_data.y()/windDim.y())*100.0f);
vec2 esvg::Dimension::getPixel(const vec2& _upperSize) const {
switch(m_type) {
case esvg::distance_pourcent:
return vec2(_upperSize.x()*m_data.x()*0.01f, _upperSize.y()*m_data.y()*0.01f);
case esvg::distance_pixel:
return m_data;
case esvg::distance_meter:
return vec2(m_data.x()*meterToMillimeter*basicRatio, m_data.y()*meterToMillimeter*basicRatio);
case esvg::distance_centimeter:
return vec2(m_data.x()*centimeterToMillimeter*basicRatio, m_data.y()*centimeterToMillimeter*basicRatio);
case esvg::distance_millimeter:
return vec2(m_data.x()*basicRatio, m_data.y()*basicRatio);
case esvg::distance_kilometer:
return vec2(m_data.x()*kilometerToMillimeter*basicRatio, m_data.y()*kilometerToMillimeter*basicRatio);
case esvg::distance_inch:
return vec2(m_data.x()*inchToMillimeter*basicRatio, m_data.y()*inchToMillimeter*basicRatio);
case esvg::distance_foot:
return vec2(m_data.x()*footToMillimeter*basicRatio, m_data.y()*footToMillimeter*basicRatio);
}
return vec2(m_data.x()*100.0f, m_data.y()*100.0f);;
return vec2(128.0f, 128.0f);
}
vec2 gale::Dimension::getMeter() const {
return gale::Dimension::getMillimeter()*millimeterToMeter;
}
vec2 gale::Dimension::getCentimeter() const {
return gale::Dimension::getMillimeter()*millimeterToCentimeter;
}
vec2 gale::Dimension::getMillimeter() const {
return gale::Dimension::getPixel()*invRatio;
}
vec2 gale::Dimension::getKilometer() const {
return gale::Dimension::getMillimeter()*millimeterToKilometer;
}
vec2 gale::Dimension::getInch() const {
return gale::Dimension::getMillimeter()*millimeterToInch;
}
vec2 gale::Dimension::getFoot() const {
return gale::Dimension::getMillimeter()*millimeterToFoot;
}
std::ostream& gale::operator <<(std::ostream& _os, enum gale::Dimension::distance _obj) {
std::ostream& esvg::operator <<(std::ostream& _os, enum esvg::distance _obj) {
switch(_obj) {
case gale::Dimension::Pourcent:
case esvg::distance_pourcent:
_os << "%";
break;
case gale::Dimension::Pixel:
case esvg::distance_pixel:
_os << "px";
break;
case gale::Dimension::Meter:
case esvg::distance_meter:
_os << "m";
break;
case gale::Dimension::Centimeter:
case esvg::distance_centimeter:
_os << "cm";
break;
case gale::Dimension::Millimeter:
case esvg::distance_millimeter:
_os << "mm";
break;
case gale::Dimension::Kilometer:
case esvg::distance_kilometer:
_os << "km";
break;
case gale::Dimension::Inch:
case esvg::distance_inch:
_os << "in";
break;
case gale::Dimension::foot:
case esvg::distance_foot:
_os << "ft";
break;
case esvg::distance_element:
_os << "em";
break;
case esvg::distance_ex:
_os << "ex";
break;
case esvg::distance_point:
_os << "pt";
break;
case esvg::distance_pc:
_os << "pc";
break;
}
return _os;
}
std::ostream& gale::operator <<(std::ostream& _os, const gale::Dimension& _obj) {
_os << _obj.get(_obj.getType()) << _obj.getType();
std::ostream& esvg::operator <<(std::ostream& _os, const esvg::Dimension& _obj) {
_os << _obj.getValue() << _obj.getType();
return _os;
}
namespace etk {
template<> std::string to_string<gale::Dimension>(const gale::Dimension& _obj) {
template<> std::string to_string<esvg::Dimension>(const esvg::Dimension& _obj) {
return _obj;
}
template<> std::u32string to_u32string<gale::Dimension>(const gale::Dimension& _obj) {
template<> std::u32string to_u32string<esvg::Dimension>(const esvg::Dimension& _obj) {
return etk::to_u32string(etk::to_string(_obj));
}
template<> bool from_string<gale::Dimension>(gale::Dimension& _variableRet, const std::string& _value) {
_variableRet = gale::Dimension(_value);
template<> bool from_string<esvg::Dimension>(esvg::Dimension& _variableRet, const std::string& _value) {
_variableRet = esvg::Dimension(_value);
return true;
}
template<> bool from_string<gale::Dimension>(gale::Dimension& _variableRet, const std::u32string& _value) {
template<> bool from_string<esvg::Dimension>(esvg::Dimension& _variableRet, const std::u32string& _value) {
return from_string(_variableRet, etk::to_string(_value));
}
};

View File

@ -14,22 +14,25 @@
#include <etk/math/Vector2D.h>
namespace esvg {
enum distance {
distance_pourcent=0, //!< "%"
distance_pixel, //!< "px"
distance_meter, //!< "m"
distance_centimeter, //!< "cm"
distance_millimeter, //!< "mm"
distance_kilometer, //!< "km"
distance_inch, //!< "in"
distance_foot, //!< "ft"
distance_element, //!< "em"
distance_ex, //!< "ex"
distance_point, //!< "pt"
distance_pc //!< "pc"
};
/**
* @brief in the dimention class we store the data as the more usefull unit (pixel)
* but one case need to be dynamic the %, then when requested in % the register the % value
*/
class Dimension {
public:
enum distance {
Pourcent=0,
Pixel,
Meter,
Centimeter,
Millimeter,
Kilometer,
Inch,
foot,
};
private:
vec2 m_data;
enum distance m_type;
@ -43,16 +46,26 @@ namespace esvg {
* @param[in] _size Requested dimention
* @param[in] _type Unit of the Dimention
*/
Dimension(const vec2& _size, enum gale::Dimension::distance _type=gale::Dimension::Pixel);
Dimension(const vec2& _size, enum esvg::distance _type=esvg::distance_pixel);
/**
* @brief Constructor
* @param[in] _config dimension configuration.
*/
Dimension(const std::string& _config) :
m_data(0,0),
m_type(gale::Dimension::Pixel) {
m_type(esvg::distance_pixel) {
set(_config);
};
/**
* @brief Constructor
* @param[in] _configX dimension X configuration.
* @param[in] _configY dimension Y configuration.
*/
Dimension(const std::string& _configX, const std::string& _configY) :
m_data(0,0),
m_type(esvg::distance_pixel) {
set(_configX, _configY);
};
/**
* @brief Destructor
*/
@ -64,11 +77,19 @@ namespace esvg {
operator std::string() const;
/**
* @brief get the current dimention in requested type
* @param[in] _type Type of unit requested.
* @brief get the current dimention.
* @return dimention requested.
*/
vec2 get(enum distance _type) const;
const vec2& getValue() const {
return m_data;
}
/**
* @breif get the dimension type
* @return the type
*/
enum distance getType() const {
return m_type;
};
/**
* @brief set the current dimention in requested type
* @param[in] _size Dimention to set
@ -82,47 +103,19 @@ namespace esvg {
* @param[in] _config dimension configuration.
*/
void set(std::string _config);
/**
* @brief set the current dimention in requested type
* @param[in] _configX dimension X configuration.
* @param[in] _configY dimension Y configuration.
*/
void set(std::string _configX, std::string _configY);
public:
/**
* @brief get the current dimention in pixel
* @param[in] _upperSize Size in pixel of the upper value
* @return dimention in Pixel
*/
vec2 getPixel() const;
/**
* @brief get the current dimention in Pourcent
* @return dimention in Pourcent
*/
vec2 getPourcent() const;
/**
* @brief get the current dimention in Meter
* @return dimention in Meter
*/
vec2 getMeter() const;
/**
* @brief get the current dimention in Centimeter
* @return dimention in Centimeter
*/
vec2 getCentimeter() const;
/**
* @brief get the current dimention in Millimeter
* @return dimention in Millimeter
*/
vec2 getMillimeter() const;
/**
* @brief get the current dimention in Kilometer
* @return dimention in Kilometer
*/
vec2 getKilometer() const;
/**
* @brief get the current dimention in Inch
* @return dimention in Inch
*/
vec2 getInch() const;
/**
* @brief get the current dimention in Foot
* @return dimention in Foot
*/
vec2 getFoot() const;
vec2 getPixel(const vec2& _upperSize) const;
/*****************************************************
* = assigment
*****************************************************/
@ -153,49 +146,8 @@ namespace esvg {
}
return false;
}
/**
* @breif get the dimension type
* @return the type
*/
enum distance getType() const {
return m_type;
};
public : // Global static access :
/**
* @brief basic init
*/
static void init();
/**
* @brief basic un-init
*/
static void unInit();
/**
* @brief set the Milimeter ratio for calculation
* @param[in] Ratio Milimeter ration for the screen calculation interpolation
* @param[in] type Unit type requested.
* @note: same as @ref setPixelPerInch (internal manage convertion)
*/
static void setPixelRatio(const vec2& _ratio, enum gale::Dimension::distance _type);
/**
* @brief set the current Windows size
* @param[in] size size of the current windows in pixel.
*/
static void setPixelWindowsSize(const vec2& _size);
/**
* @brief get the Windows size in the request unit
* @param[in] type Unit type requested.
* @return the requested size
*/
static vec2 getWindowsSize(enum gale::Dimension::distance _type);
/**
* @brief get the Windows diagonal size in the request unit
* @param[in] type Unit type requested.
* @return the requested size
*/
static float getWindowsDiag(enum gale::Dimension::distance _type);
};
std::ostream& operator <<(std::ostream& _os, enum esvg::Dimension::distance _obj);
std::ostream& operator <<(std::ostream& _os, enum esvg::distance _obj);
std::ostream& operator <<(std::ostream& _os, const esvg::Dimension& _obj);
};

View File

@ -39,10 +39,17 @@ esvg::Document::~Document() {
void esvg::Document::displayDebug() {
SVG_DEBUG("Main SVG node : size=" << m_size);
SVG_DEBUG("Main SVG: size=" << m_size);
SVG_DEBUG(" refs:");
for (int32_t iii=0; iii<m_refList.size(); iii++) {
if (m_refList[iii] != nullptr) {
m_refList[iii]->display(2);
}
}
SVG_DEBUG(" Nodes:");
for (int32_t iii=0; iii<m_subElementList.size(); iii++) {
if (m_subElementList[iii] != nullptr) {
m_subElementList[iii]->display(1);
m_subElementList[iii]->display(2);
}
}
}
@ -307,7 +314,9 @@ bool esvg::Document::parseXMLData(const std::shared_ptr<exml::Element>& _root, b
} else {
m_size.setValue((int32_t)m_size.x(), (int32_t)m_size.y());
}
displayDebug();
if (_isReference == false) {
displayDebug();
}
return true;
}

View File

@ -42,6 +42,7 @@ def create(target, module_name):
'esvg/Renderer.cpp',
'esvg/Stroking.cpp',
'esvg/Text.cpp',
'esvg/Dimension.cpp',
'esvg/render/Path.cpp',
'esvg/render/Element.cpp',
'esvg/render/ElementClose.cpp',
@ -81,6 +82,7 @@ def create(target, module_name):
'esvg/Text.h',
'esvg/cap.h',
'esvg/join.h',
'esvg/Dimension.h',
'esvg/render/Element.h',
'esvg/render/ElementStop.h',
'esvg/render/ElementClose.h',