[DEBUG] build back with new etk and no stl
This commit is contained in:
parent
a0420a8897
commit
27a67f7745
@ -268,7 +268,7 @@ static void storeSVG(const etk::String& _fileName,
|
||||
data += " ";
|
||||
}
|
||||
first = false;
|
||||
data += etk::toString(itPoints.x()*100.0f) + "," + etk::to_string((1.0-itPoints.y())*100.0f);
|
||||
data += etk::toString(itPoints.x()*100.0f) + "," + etk::toString((1.0-itPoints.y())*100.0f);
|
||||
}
|
||||
data += "\"\n";
|
||||
data += " />\n";
|
||||
@ -282,25 +282,25 @@ static void storeSVG(const etk::String& _fileName,
|
||||
data += " ";
|
||||
}
|
||||
first = false;
|
||||
data += etk::toString(itPoints.x()*100.0f) + "," + etk::to_string((1.0-itPoints.y())*100.0f);
|
||||
data += etk::toString(itPoints.x()*100.0f) + "," + etk::toString((1.0-itPoints.y())*100.0f);
|
||||
}
|
||||
data += "\"\n";
|
||||
data += " />\n";
|
||||
}
|
||||
etk::Vector<vec2> refListPoint = _gesture->getEnginePoints();
|
||||
for (auto &it : refListPoint) {
|
||||
data += " <circle fill=\"red\" cx=\"" + etk::toString(it.x()*100.0f) + "\" cy=\"" + etk::to_string((1.0-it.y())*100.0f) + "\" r=\"0.6\"/>\n";
|
||||
data += " <circle fill=\"red\" cx=\"" + etk::toString(it.x()*100.0f) + "\" cy=\"" + etk::toString((1.0-it.y())*100.0f) + "\" r=\"0.6\"/>\n";
|
||||
}
|
||||
etk::Vector<vec2> testListPoint = _points;
|
||||
for (auto &it : testListPoint) {
|
||||
data += " <circle fill=\"orange\" cx=\"" + etk::toString(it.x()*100.0f) + "\" cy=\"" + etk::to_string((1.0-it.y())*100.0f) + "\" r=\"0.6\"/>\n";
|
||||
data += " <circle fill=\"orange\" cx=\"" + etk::toString(it.x()*100.0f) + "\" cy=\"" + etk::toString((1.0-it.y())*100.0f) + "\" r=\"0.6\"/>\n";
|
||||
}
|
||||
for (auto &it : _links) {
|
||||
data += " <polyline fill=\"none\" stroke=\"blue\" stroke-opacity=\"0.8\" stroke-width=\"0.5\"\n";
|
||||
data += " points=\"";
|
||||
data += etk::toString(refListPoint[it.second].x()*100.0f) + "," + etk::to_string((1.0-refListPoint[it.second].y())*100.0f);
|
||||
data += etk::toString(refListPoint[it.second].x()*100.0f) + "," + etk::toString((1.0-refListPoint[it.second].y())*100.0f);
|
||||
data += " ";
|
||||
data += etk::toString(testListPoint[it.first].x()*100.0f) + "," + etk::to_string((1.0-testListPoint[it.first].y())*100.0f);
|
||||
data += etk::toString(testListPoint[it.first].x()*100.0f) + "," + etk::toString((1.0-testListPoint[it.first].y())*100.0f);
|
||||
data += "\"\n";
|
||||
data += " />\n";
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <limits>
|
||||
#include <iostream>
|
||||
#include <etk/String.hpp>
|
||||
#include <etk/Pair.hpp>
|
||||
|
||||
namespace dollar {
|
||||
class EnginePPlus : public dollar::Engine {
|
||||
|
@ -164,7 +164,7 @@ void dollar::Gesture::storeSVG(const etk::String& _fileName, bool _storeDot) {
|
||||
data += " ";
|
||||
}
|
||||
first = false;
|
||||
data += etk::toString(itPoints.x()*100.0f) + "," + etk::to_string((1.0-itPoints.y())*100.0f);
|
||||
data += etk::toString(itPoints.x()*100.0f) + "," + etk::toString((1.0-itPoints.y())*100.0f);
|
||||
}
|
||||
data += "\"\n";
|
||||
data += " />\n";
|
||||
@ -172,7 +172,7 @@ void dollar::Gesture::storeSVG(const etk::String& _fileName, bool _storeDot) {
|
||||
if (_storeDot == true) {
|
||||
/*
|
||||
for (auto &it : m_enginePoints) {
|
||||
data += " <circle fill=\"red\" cx=\"" + etk::toString(it.x()*100.0f) + "\" cy=\"" + etk::to_string((1.0-it.y())*100.0f) + "\" r=\"0.6\"/>\n";
|
||||
data += " <circle fill=\"red\" cx=\"" + etk::toString(it.x()*100.0f) + "\" cy=\"" + etk::toString((1.0-it.y())*100.0f) + "\" r=\"0.6\"/>\n";
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
@ -6,7 +6,9 @@
|
||||
#include <dollar/Rectangle.hpp>
|
||||
#include <dollar/debug.hpp>
|
||||
|
||||
#define MAX_FLOAT std::numeric_limits<float>::max()
|
||||
#include <etk/types.hpp>
|
||||
|
||||
//#define MAX_FLOAT std::numeric_limits<float>::max()
|
||||
|
||||
dollar::Rectangle::Rectangle(const vec2& _pos, const vec2& _size):
|
||||
m_pos(_pos),
|
||||
@ -14,8 +16,8 @@ dollar::Rectangle::Rectangle(const vec2& _pos, const vec2& _size):
|
||||
|
||||
}
|
||||
dollar::Rectangle::Rectangle(const etk::Vector<vec2>& _points) {
|
||||
vec2 minPos(MAX_FLOAT,MAX_FLOAT);
|
||||
vec2 maxPos(-MAX_FLOAT,-MAX_FLOAT);
|
||||
vec2 minPos(FLT_MAX, FLT_MAX);
|
||||
vec2 maxPos(FLT_MIN, FLT_MIN);
|
||||
for (auto &it : _points) {
|
||||
minPos.setMin(it);
|
||||
maxPos.setMax(it);
|
||||
@ -24,8 +26,8 @@ dollar::Rectangle::Rectangle(const etk::Vector<vec2>& _points) {
|
||||
m_size = maxPos-minPos;
|
||||
}
|
||||
dollar::Rectangle::Rectangle(const etk::Vector<etk::Vector<vec2>>& _points) {
|
||||
vec2 minPos(MAX_FLOAT,MAX_FLOAT);
|
||||
vec2 maxPos(-MAX_FLOAT,-MAX_FLOAT);
|
||||
vec2 minPos(FLT_MAX, FLT_MAX);
|
||||
vec2 maxPos(FLT_MIN, FLT_MIN);
|
||||
for (auto &it : _points) {
|
||||
for (auto &itPoint : it) {
|
||||
minPos.setMin(itPoint);
|
||||
|
@ -80,7 +80,7 @@ etk::Vector<vec2> dollar::scaleToOne(const etk::Vector<vec2>& _points, bool _kee
|
||||
return out;
|
||||
}
|
||||
|
||||
etk::Vector<etk::Vector<vec2>> dollar::scaleToOne(const std::vector<std::vector<vec2>>& _points, bool _keepAspectRation) {
|
||||
etk::Vector<etk::Vector<vec2>> dollar::scaleToOne(const etk::Vector<etk::Vector<vec2>>& _points, bool _keepAspectRation) {
|
||||
dollar::Rectangle box(_points);
|
||||
etk::Vector<etk::Vector<vec2>> out;
|
||||
vec2 scale(1.0f/box.getSize().x(), 1.0f/box.getSize().y());
|
||||
@ -162,7 +162,7 @@ etk::Vector<vec2> dollar::resample(etk::Vector<vec2> _points, int32_t _nbPoints)
|
||||
return out;
|
||||
}
|
||||
|
||||
etk::Vector<etk::Vector<vec2>> dollar::makeReferenceStrokes(const std::vector<std::vector<vec2>>& _strokes) {
|
||||
etk::Vector<etk::Vector<vec2>> dollar::makeReferenceStrokes(const etk::Vector<etk::Vector<vec2>>& _strokes) {
|
||||
etk::Vector<etk::Vector<vec2>> out;
|
||||
// create the ordr of all possibilities of writing the strokes ... (ABC, ACB, BAC, BCA ...)
|
||||
etk::Vector<size_t> order;
|
||||
@ -172,7 +172,7 @@ etk::Vector<etk::Vector<vec2>> dollar::makeReferenceStrokes(const std::vector<st
|
||||
// For all orders (every permutation of the path):
|
||||
do {
|
||||
// now we have an other problem: the user can write in multiple way the path
|
||||
size_t nbPermutation = std::pow(2, order.size());
|
||||
size_t nbPermutation = etk::pow(2.0f, float(order.size()));
|
||||
// we use the bit like a flag to know the order of the draw
|
||||
for (size_t permut=0; permut<nbPermutation; ++permut) {
|
||||
etk::Vector<vec2> stroke;
|
||||
@ -180,7 +180,9 @@ etk::Vector<etk::Vector<vec2>> dollar::makeReferenceStrokes(const std::vector<st
|
||||
etk::Vector<vec2> pts = _strokes[order[iii]];
|
||||
// check to permut the value order
|
||||
if (((permut>>iii) & 0x01) == 1) {
|
||||
reverse(pts.begin(),pts.end());
|
||||
for (size_t kkk=0; kkk < pts.size()/2; ++kkk) {
|
||||
etk::swap(pts[kkk], pts[pts.size()-1-kkk]);
|
||||
}
|
||||
}
|
||||
// Add point in next of the path...
|
||||
for (auto &it : pts) {
|
||||
@ -190,11 +192,11 @@ etk::Vector<etk::Vector<vec2>> dollar::makeReferenceStrokes(const std::vector<st
|
||||
// Add new generated stroke
|
||||
out.pushBack(stroke);
|
||||
}
|
||||
} while (next_permutation(order.begin(), order.end()));
|
||||
} while (false); // TODO : Set back: next_permutation(order.begin(), order.end()));
|
||||
return out;
|
||||
}
|
||||
|
||||
etk::Vector<vec2> dollar::combineStrokes(const etk::Vector<std::vector<vec2>>& _strokes) {
|
||||
etk::Vector<vec2> dollar::combineStrokes(const etk::Vector<etk::Vector<vec2>>& _strokes) {
|
||||
etk::Vector<vec2> out;
|
||||
for (auto &it : _strokes) {
|
||||
for (auto &pointIt : it) {
|
||||
@ -250,7 +252,7 @@ float dollar::getAspectRatio(etk::Vector<etk::Vector<vec2>> _points) {
|
||||
}
|
||||
}
|
||||
|
||||
etk::Vector<vec2> dollar::normalizePathToPoints(etk::Vector<std::vector<vec2>> _points, float _distance, bool _keepAspectRatio) {
|
||||
etk::Vector<vec2> dollar::normalizePathToPoints(etk::Vector<etk::Vector<vec2>> _points, float _distance, bool _keepAspectRatio) {
|
||||
// Scale point to (0.0,0.0) position and (1.0,1.0) size
|
||||
_points = dollar::scaleToOne(_points, _keepAspectRatio);
|
||||
etk::Vector<vec2> out;
|
||||
|
@ -54,7 +54,7 @@ namespace dollar {
|
||||
* @param[in] _keepAspectRation Keep the aspect ratio of the scaling
|
||||
* @return modify points
|
||||
*/
|
||||
etk::Vector<etk::Vector<vec2>> scaleToOne(const std::vector<std::vector<vec2>>& _points, bool _keepAspectRation=false);
|
||||
etk::Vector<etk::Vector<vec2>> scaleToOne(const etk::Vector<etk::Vector<vec2>>& _points, bool _keepAspectRation=false);
|
||||
/**
|
||||
* @brief Get center of the path and move the path to be center at (0,0)
|
||||
* @param[in] _points List of point in the path
|
||||
@ -73,13 +73,13 @@ namespace dollar {
|
||||
* @param[in] _strokes List of all strokes
|
||||
* @return List of a list of single stroke of multiple stroke
|
||||
*/
|
||||
etk::Vector<etk::Vector<vec2>> makeReferenceStrokes(const std::vector<std::vector<vec2>>& _strokes);
|
||||
etk::Vector<etk::Vector<vec2>> makeReferenceStrokes(const etk::Vector<etk::Vector<vec2>>& _strokes);
|
||||
/**
|
||||
* @brief combine some stroke in a single one.
|
||||
* @param[in] _strokes value to merge
|
||||
* @return Merged vector
|
||||
*/
|
||||
etk::Vector<vec2> combineStrokes(const etk::Vector<std::vector<vec2>>& _strokes);
|
||||
etk::Vector<vec2> combineStrokes(const etk::Vector<etk::Vector<vec2>>& _strokes);
|
||||
/**
|
||||
* @brief Normalise the Path with the full magnetude of the data
|
||||
* @param[in] _points Input path
|
||||
@ -111,7 +111,7 @@ namespace dollar {
|
||||
* @param[in] _keepAspectRatio Keep Aspect ratio when scaling to the correct size (1.0,1.0) (it will be centered)
|
||||
* @return new list of points
|
||||
*/
|
||||
etk::Vector<vec2> normalizePathToPoints(etk::Vector<std::vector<vec2>> _points, float _distance, bool _keepAspectRatio);
|
||||
etk::Vector<vec2> normalizePathToPoints(etk::Vector<etk::Vector<vec2>> _points, float _distance, bool _keepAspectRatio);
|
||||
/**
|
||||
* @brief get the aspect ratio of a list of points
|
||||
* @param[in] _points List of points
|
||||
|
@ -12,10 +12,7 @@
|
||||
#include <etest/etest.hpp>
|
||||
|
||||
int main(int _argc, const char *_argv[]) {
|
||||
// init Google test :
|
||||
::testing::InitGoogleTest(&_argc, const_cast<char **>(_argv));
|
||||
// init etk log system and file interface:
|
||||
etk::init(_argc, _argv);
|
||||
etest::init(_argc, _argv);
|
||||
// Run all test with etest
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
@ -35,8 +32,8 @@ TEST(TestAll, singleStroke_normal) {
|
||||
ememory::SharedPtr<dollar::Engine> reco = dollar::createEngine("$N");
|
||||
reco->loadPath("DATA:figure");
|
||||
dollar::Results res = reco->recognize(dollar::loadPoints("DATA:test/arrow.json"));
|
||||
EXPECT_EQ(res.haveMath(), true);
|
||||
if (res.haveMath() == false) {
|
||||
EXPECT_EQ(res.haveMatch(), true);
|
||||
if (res.haveMatch() == false) {
|
||||
TEST_INFO(" Recognise noting ...");
|
||||
return;
|
||||
}
|
||||
@ -51,8 +48,8 @@ TEST(TestAll, singleStroke_protractor) {
|
||||
ememory::SharedPtr<dollar::Engine> reco = dollar::createEngine("$N");
|
||||
reco->loadPath("DATA:figure");
|
||||
dollar::Results res = reco->recognize(dollar::loadPoints("DATA:test/arrow.json"));
|
||||
EXPECT_EQ(res.haveMath(), true);
|
||||
if (res.haveMath() == false) {
|
||||
EXPECT_EQ(res.haveMatch(), true);
|
||||
if (res.haveMatch() == false) {
|
||||
TEST_INFO(" Recognise noting ...");
|
||||
return;
|
||||
}
|
||||
@ -71,8 +68,8 @@ TEST(TestAll, multiStroke_normal) {
|
||||
ememory::SharedPtr<dollar::Engine> reco = dollar::createEngine("$N");
|
||||
reco->loadPath("DATA:text");
|
||||
dollar::Results res = reco->recognize(dollar::loadPoints("DATA:test/P.json"));
|
||||
EXPECT_EQ(res.haveMath(), true);
|
||||
if (res.haveMath() == false) {
|
||||
EXPECT_EQ(res.haveMatch(), true);
|
||||
if (res.haveMatch() == false) {
|
||||
TEST_INFO(" Recognise noting ...");
|
||||
return;
|
||||
}
|
||||
@ -87,8 +84,8 @@ TEST(TestAll, multiStroke_protractor) {
|
||||
ememory::SharedPtr<dollar::Engine> reco = dollar::createEngine("$N-protractor");
|
||||
reco->loadPath("DATA:text");
|
||||
dollar::Results res = reco->recognize(dollar::loadPoints("DATA:test/P.json"));
|
||||
EXPECT_EQ(res.haveMath(), true);
|
||||
if (res.haveMath() == false) {
|
||||
EXPECT_EQ(res.haveMatch(), true);
|
||||
if (res.haveMatch() == false) {
|
||||
TEST_INFO(" Recognise noting ...");
|
||||
return;
|
||||
}
|
||||
@ -105,8 +102,8 @@ TEST(TestAll, multiStroke_point) {
|
||||
ememory::SharedPtr<dollar::Engine> reco = dollar::createEngine("$P");
|
||||
reco->loadPath("DATA:text");
|
||||
dollar::Results res = reco->recognize(dollar::loadPoints("DATA:test/P.json"));
|
||||
EXPECT_EQ(res.haveMath(), true);
|
||||
if (res.haveMath() == false) {
|
||||
EXPECT_EQ(res.haveMatch(), true);
|
||||
if (res.haveMatch() == false) {
|
||||
TEST_INFO(" Recognise noting ...");
|
||||
return;
|
||||
}
|
||||
@ -123,8 +120,8 @@ TEST(TestAll, multiStroke_pointPlus) {
|
||||
ememory::SharedPtr<dollar::Engine> reco = dollar::createEngine("$P+");
|
||||
reco->loadPath("DATA:text");
|
||||
dollar::Results res = reco->recognize(dollar::loadPoints("DATA:test/P.json"));
|
||||
EXPECT_EQ(res.haveMath(), true);
|
||||
if (res.haveMath() == false) {
|
||||
EXPECT_EQ(res.haveMatch(), true);
|
||||
if (res.haveMatch() == false) {
|
||||
TEST_INFO(" Recognise noting ...");
|
||||
return;
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ void generateFile(const etk::String& _fileName, const etk::Vector<etk::String>&
|
||||
data += " ";
|
||||
}
|
||||
first = false;
|
||||
data += etk::toString(itPoints.x()*100.0f) + "," + etk::to_string((1.0-itPoints.y())*100.0f);
|
||||
data += etk::toString(itPoints.x()*100.0f) + "," + etk::toString((1.0-itPoints.y())*100.0f);
|
||||
}
|
||||
data += "\"\n";
|
||||
data += " />\n";
|
||||
|
@ -137,7 +137,7 @@ void generateFile(const etk::String& _fileName, const etk::Vector<etk::String>&
|
||||
data += " ";
|
||||
}
|
||||
first = false;
|
||||
data += etk::toString(itPoints.x()*100.0f) + "," + etk::to_string((1.0-itPoints.y())*100.0f);
|
||||
data += etk::toString(itPoints.x()*100.0f) + "," + etk::toString((1.0-itPoints.y())*100.0f);
|
||||
}
|
||||
data += "\"\n";
|
||||
data += " />\n";
|
||||
@ -157,7 +157,7 @@ void generateFile(const etk::String& _fileName, const etk::Vector<etk::String>&
|
||||
data += " ";
|
||||
}
|
||||
first = false;
|
||||
data += etk::toString(itPoints.x()*100.0f) + "," + etk::to_string((1.0-itPoints.y())*100.0f);
|
||||
data += etk::toString(itPoints.x()*100.0f) + "," + etk::toString((1.0-itPoints.y())*100.0f);
|
||||
}
|
||||
data += "\"\n";
|
||||
data += " />\n";
|
||||
@ -187,7 +187,10 @@ bool testCorpus(const etk::String& _srcCorpus) {
|
||||
}if (elemName == "back-slash") {
|
||||
elemName = "\\";
|
||||
}
|
||||
if (std::find(listOfElementInCorpus.begin(), listOfElementInCorpus.end(), elemName) == listOfElementInCorpus.end()) {
|
||||
for (auto &it: listOfElementInCorpus) {
|
||||
if (it == elemName) {
|
||||
continue;
|
||||
}
|
||||
listOfElementInCorpus.pushBack(elemName);
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ void appl::widget::TextAreaRecognition::init() {
|
||||
//m_dollarEngine.loadPath("DATA:text");
|
||||
m_dollarEngine = dollar::createEngine("$P+");
|
||||
m_dollarEngine->loadPath("DATA:reference");
|
||||
m_dollarEngine->setScaleKeepRatio(true);
|
||||
// TODO: m_dollarEngine->setScaleKeepRatio(true);
|
||||
markToRedraw();
|
||||
// connect a periodic update ...
|
||||
m_periodicConnection = getObjectManager().periodicCall.connect(this, &appl::widget::TextAreaRecognition::callbackPeriodicUpdate);
|
||||
@ -38,7 +38,7 @@ appl::widget::TextAreaRecognition::~TextAreaRecognition() {
|
||||
void appl::widget::TextAreaRecognition::clear() {
|
||||
m_dataList.clear();
|
||||
m_current.clear();
|
||||
m_time = std::chrono::system_clock::now();
|
||||
m_time = echrono::Clock::now();
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ void appl::widget::TextAreaRecognition::undo() {
|
||||
return;
|
||||
}
|
||||
m_dataList.erase(m_dataList.begin()+(m_dataList.size()-1));
|
||||
m_time = std::chrono::system_clock::now();
|
||||
m_time = echrono::Clock::now();
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ void appl::widget::TextAreaRecognition::store(const etk::String& _userName, cons
|
||||
doc.add("user", ejson::String(_userName));
|
||||
doc.add("value", ejson::String(_value));
|
||||
doc.add("type", ejson::String(_type));
|
||||
doc.add("time", ejson::Number(m_time.time_since_epoch().count()));
|
||||
doc.add("time", ejson::Number(m_time.get()));
|
||||
ejson::Array list;
|
||||
doc.add("data", list);
|
||||
for (auto &it : m_dataList) {
|
||||
@ -95,7 +95,7 @@ void appl::widget::TextAreaRecognition::store(const etk::String& _userName, cons
|
||||
fileName += "_";
|
||||
fileName += _userName;
|
||||
fileName += "_";
|
||||
fileName += etk::toString(m_time.time_since_epoch().count());
|
||||
fileName += etk::toString(m_time.get());
|
||||
fileName += ".json";
|
||||
etk::FSNodeWriteAllData(fileName, streamOut);
|
||||
APPL_WARNING("store: " << fileName);
|
||||
@ -106,10 +106,10 @@ void appl::widget::TextAreaRecognition::onDraw() {
|
||||
m_text.draw();
|
||||
}
|
||||
|
||||
etk::Vector<etk::Vector<vec2>> scalePoints(std::vector<std::vector<vec2>> _list, float _objectSize) {
|
||||
etk::Vector<etk::Vector<vec2>> scalePoints(etk::Vector<etk::Vector<vec2>> _list, float _objectSize) {
|
||||
// get min/max point
|
||||
vec2 minPos(99999999,99999999);
|
||||
vec2 maxPos(0,0);
|
||||
vec2 minPos(FLT_MAX, FLT_MAX);
|
||||
vec2 maxPos(FLT_MIN, FLT_MIN);
|
||||
for (auto &itLines : _list) {
|
||||
for (auto& itPoints : itLines) {
|
||||
minPos.setMin(itPoints);
|
||||
@ -119,7 +119,7 @@ etk::Vector<etk::Vector<vec2>> scalePoints(std::vector<std::vector<vec2>> _list,
|
||||
// center and reduce to a size of XXX
|
||||
float scale = 1.0f;
|
||||
vec2 size = maxPos-minPos;
|
||||
vec2 center(0,0);
|
||||
vec2 center(0, 0);
|
||||
if (size.x() > size.y()) {
|
||||
scale = _objectSize/size.x();
|
||||
center.setY((_objectSize-size.y()*scale)*0.5);
|
||||
@ -137,11 +137,11 @@ etk::Vector<etk::Vector<vec2>> scalePoints(std::vector<std::vector<vec2>> _list,
|
||||
return _list;
|
||||
}
|
||||
|
||||
etk::Vector<etk::Color<float,4>> renderWithSVG(const etk::Vector<std::vector<vec2>>& _list, int32_t _objectSize, const etk::String& _filename) {
|
||||
etk::Vector<etk::Color<float,4>> renderWithSVG(const etk::Vector<etk::Vector<vec2>>& _list, int32_t _objectSize, const etk::String& _filename) {
|
||||
// generate SVG to render:
|
||||
esvg::Document docSvg;
|
||||
etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n");
|
||||
data += "<svg height='" + etk::toString(_objectSize) + "' width='" + etk::to_string(_objectSize) + "'>\n";
|
||||
data += "<svg height='" + etk::toString(_objectSize) + "' width='" + etk::toString(_objectSize) + "'>\n";
|
||||
for (auto &itLines : _list) {
|
||||
data += " <polyline\n";
|
||||
data += " fill='none'\n";
|
||||
@ -155,7 +155,7 @@ etk::Vector<etk::Color<float,4>> renderWithSVG(const etk::Vector<std::vector<vec
|
||||
data += " ";
|
||||
}
|
||||
first = false;
|
||||
data += etk::toString(itPoints.x()) + "," + etk::to_string(itPoints.y());
|
||||
data += etk::toString(itPoints.x()) + "," + etk::toString(itPoints.y());
|
||||
}
|
||||
data += "'\n";
|
||||
data += " />\n";
|
||||
@ -294,7 +294,7 @@ void appl::widget::TextAreaRecognition::onRegenerateDisplay() {
|
||||
}
|
||||
m_text.setColor(etk::color::white);
|
||||
m_text.setPos(vec2(0, m_text.getHeight()*2));
|
||||
m_text.print("Dollar=" + etk::toString(m_dollarTime.count()) + " ms");
|
||||
m_text.print("Dollar=" + etk::toString(m_dollarTime.get()) + " ms");
|
||||
}
|
||||
}
|
||||
|
||||
@ -306,7 +306,7 @@ bool appl::widget::TextAreaRecognition::onEventInput(const ewol::event::Input& _
|
||||
|| m_current.m_type == _event.getType()
|
||||
)
|
||||
) {
|
||||
m_time = std::chrono::system_clock::now();
|
||||
m_time = echrono::Clock::now();
|
||||
if(_event.getStatus() == gale::key::status::down) {
|
||||
m_current.m_type = _event.getType();
|
||||
m_current.addPoint(relativePosition(_event.getPos()));
|
||||
@ -320,7 +320,7 @@ bool appl::widget::TextAreaRecognition::onEventInput(const ewol::event::Input& _
|
||||
m_current.addPoint(relativePosition(_event.getPos()));
|
||||
}
|
||||
markToRedraw();
|
||||
m_lastEvent = std::chrono::system_clock::now();
|
||||
m_lastEvent = echrono::Clock::now();
|
||||
m_updateDone = false;
|
||||
m_findValue = "";
|
||||
m_dollarResults.clear();
|
||||
@ -329,7 +329,7 @@ bool appl::widget::TextAreaRecognition::onEventInput(const ewol::event::Input& _
|
||||
return false;
|
||||
}
|
||||
|
||||
static etk::Vector<etk::Vector<vec2>> convertInLines(const std::vector<appl::DrawingLine>& _list) {
|
||||
static etk::Vector<etk::Vector<vec2>> convertInLines(const etk::Vector<appl::DrawingLine>& _list) {
|
||||
etk::Vector<etk::Vector<vec2>> out;
|
||||
for (auto &it : _list) {
|
||||
if (it.m_data.size() > 1) {
|
||||
@ -343,7 +343,7 @@ static etk::Vector<etk::Vector<vec2>> convertInLines(const std::vector<appl::Dra
|
||||
|
||||
|
||||
void appl::widget::TextAreaRecognition::callbackPeriodicUpdate(const ewol::event::Time& _event) {
|
||||
if ( (std::chrono::system_clock::now() - m_lastEvent) > std::chrono::milliseconds(1200)
|
||||
if ( (echrono::Clock::now() - m_lastEvent) > echrono::milliseconds(1200)
|
||||
&& m_updateDone == false) {
|
||||
if (m_current.m_data.size() != 0) {
|
||||
// ==> writing in progress
|
||||
@ -362,11 +362,11 @@ void appl::widget::TextAreaRecognition::callbackPeriodicUpdate(const ewol::event
|
||||
return;
|
||||
}
|
||||
|
||||
std::chrono::system_clock::time_point tic = std::chrono::system_clock::now();
|
||||
echrono::Clock tic = echrono::Clock::now();
|
||||
// First Test with dollar engine
|
||||
m_dollarResults = m_dollarEngine->recognize(fullListlines);
|
||||
m_findValue = m_dollarResults.getName();
|
||||
m_dollarTime = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - tic);
|
||||
m_dollarTime = echrono::Clock::now() - tic;
|
||||
markToRedraw();
|
||||
m_updateDone = true;
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <ewol/compositing/Drawing.hpp>
|
||||
#include <ewol/compositing/Text.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
#include <echrono/echrono.hpp>
|
||||
|
||||
#include <dollar/Engine.hpp>
|
||||
|
||||
@ -41,8 +42,8 @@ namespace appl {
|
||||
ewol::compositing::Text m_text; //!< drawing instance
|
||||
etk::Vector<DrawingLine> m_dataList;
|
||||
DrawingLine m_current;
|
||||
std::chrono::system_clock::time_point m_time;
|
||||
std::chrono::system_clock::time_point m_lastEvent;
|
||||
echrono::Clock m_time;
|
||||
echrono::Clock m_lastEvent;
|
||||
esignal::Connection m_periodicConnection;
|
||||
bool m_updateDone;
|
||||
etk::String m_svgData;
|
||||
@ -51,7 +52,7 @@ namespace appl {
|
||||
ememory::SharedPtr<dollar::Engine> m_dollarEngine;
|
||||
dollar::Results m_dollarResults;
|
||||
etk::String m_findValue;
|
||||
std::chrono::milliseconds m_dollarTime;
|
||||
echrono::Duration m_dollarTime;
|
||||
protected:
|
||||
//! @brief constructor
|
||||
TextAreaRecognition();
|
||||
|
Loading…
x
Reference in New Issue
Block a user