New export: Export Measurements for Body Measurements App/Widget
In the longer run, it would be nice to have a way to get the measurements info (including translations) known to Valentina exported into a format that can be used in other apps.
I figured that one way to do this is if I can manage to get VTranslateMeasurements()
to compile, I could just write a simple program that
- sets a language
- exports all the measurements data from
VTranslateMeasurements()
- repeats for the next language until I have exported data for all languages
I started trying to get VTranslateMeasurements()
to compile, but keep running into more dependencies I need to add. I'm at a point where I must start adding things dealing with translations of line, angle and arc names in order to get it to compile.
Code so far at: https://bitbucket.org/dismine/body-measurements-widget/src/53d4e7d78a2f/tools/translation_importer/?at=master
Haven't started trying to export since I couldn't get it to compile yet.
Question: does the approach I'm taking make sense or not? Is there a way I can get VTranslateMeasurements()
to compile without a huge load of additional dependencies?
This is not blocking development of measurements app in any way, I can transfer some measurements data by hand and develop the measurements app. Just in the long run it would be cool not to have to maintain duplicate info.
Comments (56)
-
repo owner -
reporter I don't know much about C++, haven't used it in years. I also don't know Valentina's codebase well. I've just been looking for the measurements code and trying to get the translations out.
Because I ran into trouble, I figured that I'm doing this the wrong way, hence why I'm asking instead of wasting time. :p
With importing the vpatterndb static library you mean I
- compile Valentina
- copy .o file I need and link that? vpatterndb.o or so?
Tape app supports exporting to CSV format.
That's cool, but not really needed for measurements app. .vit files are good. Measurement app needs to work with .vit files anyways, I think, to make using it with Valentina easy. I only meant getting the measurement name/description info (e.g. translations, code letter/number of measurement).
-
reporter Ok, sorry, I saw vpatterndb has it's own qt project file, that's nice. Don't worry, I'll figure things out from here. And thanks for pointing out that I just need to link the compiled library.
-
repo owner All you need is vpatterndb.lib (Windows) or libvpatterndb.a (Unix) file. And saying a linker to use it. You can do it through Qt Creator.
-
repo owner Is this utility good only for you? Maybe we should add it as part of the main project?
-
reporter It should be useful for others who want to do something with measurement translation strings, too, I think. I want to export to JSON.
-
repo owner I want to export to JSON.
Qt has class for working with JSON.
-
reporter I'm failing at linking libvpatterndb.a on Ubuntu command line (using qmake and .pro file) but that's my own fault. Trying to add it to .pro file with
INCLUDE += -L../../../valentina/src/libs/vpatterndb/bin/libvpatterndb.a
doesn't seem to work. I get
undefined reference to `VTranslateVars::VTranslateVars(bool)'
But I'm pretty sure that's just something silly I'm doing wrong since that seems to be a rather normal C++ linking error.
-
reporter Qt has class for working with JSON.
Oh, that's perfect. :)
-
repo owner Also i forgot to mention that you also will need .QM files. These files contains translation.
-
repo owner But I'm pretty sure that's just something silly I'm doing wrong since that seems to be a rather normal C++ linking error.
I think your syntax is wrong. Did you use Qt Creator?
-
reporter Not yet, I was working with qmake and editing .pro file because Qt Creator looked so intimidating.
I managed to get vpatterndb library to link after fixing wrong syntax for linking, but then I had lots of undefined references to qmuparser. Then I linked libqmuparser.so and had undefined references to vmisc library. Then I had undefined references to QPrinter and QPrinterInfo that I resolved by adding
QT += printsupport
.I installed Qt Creator and tried to find the place where to link libraries, but am totally lost in there. I'm much more comfortable on command line.
It compiles now, but I get
error while loading shared libraries: libqmuparser.so.2: cannot open shared object file: No such file or directory
so I'm probably doing something wrong with regard to linking that.
Edit: link to .pro file updated
-
repo owner so I'm probably doing something wrong with regard to linking that.
You are doing all right for building. But you forgot that when you start the app it can't find the shared library. The library is not in the standard path.
On linux by default you also can't add just a library to folder with binary. But i know one way.
- I recommend you add a symlink to qmuparser library.
- Use RPATH option for linker.
Here is example from Valentina:
noRunPath{ # For enable run qmake with CONFIG+=noRunPath # do nothing } else { unix:!macx{ # suppress the default RPATH # helps to run the program without Qt Creator # see problem with path to libqmuparser and libpropertybrowser QMAKE_LFLAGS_RPATH = QMAKE_LFLAGS += "-Wl,-rpath,\'\$$ORIGIN\' -Wl,-rpath,$${OUT_PWD}/../../libs/qmuparser/$${DESTDIR} -Wl,-rpath,$${OUT_PWD}/../../libs/vpropertyexplorer/$${DESTDIR}" } }
$$ORIGIN
is binary folder.This way is not recommended for production, but perfect for testing.
-
reporter Ok, thanks, that makes sense! Considering that this will never be a production app, a hacky solution is fine. I just need to run it whenever measurements known by Valentina are updated. Anyone other than me should be using the exported JSON files directly, instead of running the exporter themselves.
-
reporter How to build QM files from TS files?
When I build full Valentina from Valentina.pro, it looks like it's trying to do something to
.qm
files but there are no.qm
files inshare/translations/
, only.ts
files. -
repo owner It should be there after you call qmake. If it is not working. Use script lrelease.sh in folder scripts.
-
reporter That worked, thanks.
Looking at the translations I just noticed that the names like "height_neck_back" are translated, too. Does that mean that the correct way to identify a measurement across languages is to use, e.g. "A01", etc?
Is the correct way to write .vit file (v0.3.3) this:
<m name="height" value="168.0" full_name="Height: Total" description="Vertical distance from crown of head to floor." />
or
<m name="A01" value="168.0" full_name="Height: Total" description="Vertical distance from crown of head to floor." />
or another different way?
-
repo owner Looking at the translations I just noticed that the names like "height_neck_back" are translated, too.
Yes.
Does that mean that the correct way to identify a measurement across languages is to use, e.g. "A01", etc?
No. Valentina has internal names. All files use internal names.
-
reporter Ok, is it correct that internal names are
heightWaistFront_M
, etc.? -
repo owner Yes.
-
reporter Good. then it seems clear what I need to get out of the system.
Looks like I'll need to figure out how to make a derived class of VTranslateVars to access all of
measurements
,guiTexts
,descriptions
,numbers
so I can save them to JSON. -
reporter Ah, no, that was a stupid thought. Looks like there are getter functions. :)
-
repo owner Why do you need
VTranslateVars
you haveVTranslateMeasurements
? It can do all you need. ClassTST_MeasurementRegExp
will help you understand how all works. -
reporter Simplest way for me to export would be to iterate over
measurements
and use the getters to get numbers, guiTexts and descriptions.Ah, but I still can't access
measurements
unless I derive a class, right or wrong? -
repo owner Ah, but I still can't access measurements unless I derive a class, right or wrong?
Who did say this? I don't see any reason why you can't use this class.
-
reporter But
TST_MeasurementsRegExp
usesVTranslateVars
. That's why I've been trying to use that too since I can then copy code fromTST_MeasurementsRegExp
. -
reporter Compiler says
error: ‘QMap<QString, qmu::QmuTranslation> VTranslateMeasurements::measurements’ is protected
-
repo owner It uses both because test also internal variables.
-
repo owner VTranslateVars *trMs; const QStringList originalNames = AllGroupNames(); foreach(const QString &originalName, originalNames) { const QString translated = trMs->VarToUser(originalName); }
-
reporter Ok. I'll try to use
VTranslateMeasurements
directly. -
reporter Thanks, that works fine. :)
-
reporter I won't need VarToUser to make
.vit
files, right or wrong? -
repo owner No, i guess.
-
repo owner Valentina has internal names. All files use internal names.
-
reporter Ok, good. I have JSON files now.
It looks like p0-p50 are pattern systems and every pattern system has its own file with measurement names. How do I know what code is for what system? Is there a measurements translation file independent of pattern systems? Like, e.g. original measurements known to Valentina.
-
repo owner It looks like p0-p50 are pattern systems and every pattern system has its own file with measurement names.
Yes.
How do I know what code is for what system?
const QStringList listSystems = ListPMSystems(); QMap<QString, QString> systems; for (int i = 0; i < listSystems.size()-1; ++i) { systems.insert(qApp->TrVars()->PMSystemName(listSystems.at(i)) + " ("+listSystems.at(i)+")", listSystems.at(i)); }
Is there a measurements translation file independent of pattern systems? Like, e.g. original measurements known to Valentina.
Sorry, don't understand this question.
-
reporter Like.. if I'm using Valentina without a pattern system, what measurements do I use?
-
repo owner It depends on which translation file you loaded.
-
reporter I could use any of the pattern system translations, whichever I like best, basically?
-
repo owner Yes, but vit file should contain only internal names.
-
reporter Ok. Thanks so much. I think I got it now thanks to your help.
-
reporter I'm trying to export diagrams using
MapDiagrams
on measurement number. It fails with SegFault because it's trying to accessqApp->TrVars()
(which my translation exporter program doesn't have).What should I do?
-
repo owner Show me your code.
-
reporter It seems that
MapDiagrams
calls another function that needsqApp
. So I could either addqApp
to my code or find a way to refactorMapDiagrams
so that it doesn't needqApp
. -
repo owner This is my design mistake. Yes, better to refactor
MapDiagrams
to take pointer toVTranslateMeasurements
from outside. Do you want me make this changes or you want make a pull request yourself? -
reporter If you know already how to do it you will be way faster than me. Too clueless about C++, would take me ages. :)
-
repo owner Fine, give me some time. :)
-
reporter Ah, okay, no, I think I can do that, actually. Refactoring to take a pointer doesn't seem so hard. Just have to find all
MapDiagram
calls and passqApp->TrVars()
.Should I?
-
repo owner No. Do your part of job. This is my mistake. :)
-
repo owner Refactoring function MapDiagrams(). ref
#576.→ <<cset 4deaed941cc3>>
-
repo owner @grumpi, did my changes help you?
-
reporter Yes, these work fine. Thanks! :)
-
- changed title to New feature: Export Measurements Translations for Body Measurements App/Widget
- changed milestone to v0.6.0
-
- changed component to File Format, Export
- changed title to New feature: Export Measurements for Body Measurements App/Widget
-
- changed title to New export: Export Measurements for Body Measurements App/Widget
- changed milestone to TBD
On hold until someone works on the Body Measurement app/widget
-
repo owner - changed status to closed
This repository has been archived. If you want to report a bug or your feature request, you need to do this in the new repository https://gitlab.com/smart-pattern/valentina. This issue ticket will be closed.
- Log in to comment
Not really. First of all Valentina already provide you with good example. So your task for me is very easy.
VTranslateMeasurements()
why try to import source file when you can import the vpatterdb static library or any other if need too? The linker will clear all pieces you don't need.TST_MeasurementRegExp
will help you understand how all is working. It tests translation.Tape app supports exporting to CSV format.