Rounding of values

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
24 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Rounding of values

Allan.W.Macdonald
I notice that, when a value to be rounded is 5, LibreCAD rounds down, not up.  For example, if the drawing precision is 0.00 and an entity such as a straight line is 30.165, when dimensioning the line, LibreCAD draws 30.16 instead of 30.17.

What is the standard drafting rule for rounding, up, down or other?  What are LibreCAD's rules?  Can the rounding rules be adjusted?
Reply | Threaded
Open this post in threaded view
|

Re: Rounding of values

dxli
Hi,

Thanks a lot for raising this issue:

The current implementation always rounds down, and seems to be a bad choice to me.

Please have a look at the source code:
https://github.com/LibreCAD/LibreCAD/blob/master/librecad/src/lib/math/rs_math.cpp#L320


Allan.W.Macdonald wrote
I notice that, when a value to be rounded is 5, LibreCAD rounds down, not up.  For example, if the drawing precision is 0.00 and an entity such as a straight line is 30.165, when dimensioning the line, LibreCAD draws 30.16 instead of 30.17.

What is the standard drafting rule for rounding, up, down or other?  What are LibreCAD's rules?  Can the rounding rules be adjusted?
Reply | Threaded
Open this post in threaded view
|

Re: Rounding of values

Allan.W.Macdonald
I tried building the source but it fails:
make_output.txt

My system: ubuntu 14.04 LTS

gcc version:
gcc.txt

I installed dependencies:
myusername@mysystem:~/source/LibreCAD/LibreCAD$ sudo apt-get build-dep librecad
Reading package lists... Done
Building dependency tree      
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
myusername@mysystem:~/source/LibreCAD/LibreCAD$

Am I missing something?
Reply | Threaded
Open this post in threaded view
|

Re: Rounding of values

ravas
"Project ERROR: Unknown module(s) in QT: help"

http://askubuntu.com/questions/508503/whats-the-development-package-for-qt5-in-14-04

Maybe the second answer is what you need?
qtbase5-dev

Otherwise, the third answer shows:
help                qttools5-dev                        libqt5help5



Reply | Threaded
Open this post in threaded view
|

Re: Rounding of values

ravas
qttools5-dev is what I think you need to install...
Reply | Threaded
Open this post in threaded view
|

Re: Rounding of values

ravas
Reply | Threaded
Open this post in threaded view
|

Re: Rounding of values

Allan.W.Macdonald
Thank you ravas for all your suggetions.  I am at the office right now; I will try your suggestions when I get home later today.
Reply | Threaded
Open this post in threaded view
|

Re: Rounding of values

Allan.W.Macdonald
In reply to this post by ravas
Thanks ravas. I installed qttools5-dev and got past that error.  Unfortunately, there are yet more errors, this time related to printing, perhaps.

make_error2.txt
Reply | Threaded
Open this post in threaded view
|

Re: Rounding of values

ravas
Looks like a problem I recently introduced.
It's fixed now if you know how to sync your local repository.

Otherwise you could delete the code manually and rebuild.

https://github.com/LibreCAD/LibreCAD/commit/0a4ca3caefa706135fb831b402a647c6485a0ea5
Reply | Threaded
Open this post in threaded view
|

Re: Rounding of values

ravas
Why it was happening is not apparent to me...
It built fine for me and it clearly shows that those types are a part of QPrinter in Qt 5.
http://doc.qt.io/qt-5/qprinter.html#PaperSize-enum
Reply | Threaded
Open this post in threaded view
|

Re: Rounding of values

ravas
In reply to this post by Allan.W.Macdonald
What version of Qt are you using specifically?
Reply | Threaded
Open this post in threaded view
|

Re: Rounding of values

ravas
In reply to this post by ravas
It looks like there are two other places to find this enum
enum QPagedPaintDevice::PageSize
enum QPageSize::PageSizeId

Since QPageSize was added in 5.3 it would probably be safe to use
#if QT_VERSION >= 0x050300

I'm going to wait for some feedback on the Qt forum.
Reply | Threaded
Open this post in threaded view
|

Re: Rounding of values

Allan.W.Macdonald
In reply to this post by ravas
$ qmake --version
QMake version 3.0
Using Qt version 5.2.1 in /usr/lib/x86_64-linux-gnu

Packages (output of pkg-config --modversion for each package):

QtHelp 4.8.6
Qt5Qml 5.2.1
QtNetwork 4.8.6
QtTest 4.8.6
Qt5Help 5.2.1
QtDeclarative 4.8.6
Qt5Test 5.2.1
QtScriptTools 4.8.6
Qt5Quick 5.2.1
Qt5Network 5.2.1
Qt5OpenGLExtensions 5.2.1
Qt5QuickTest 5.2.1
Qt5Sql 5.2.1
Qt5Bootstrap 5.2.1
QtCore 4.8.6
Qt5Widgets 5.2.1
QtDesigner 4.8.6
Qt5Core 5.2.1
QtSql 4.8.6
QtUiTools 4.8.6
Qt5PlatformSupport 5.2.1
Qt5Xml 5.2.1
Qt5Concurrent 5.2.1
QtXml 4.8.6
Qt5UiTools 5.2.1
QtScript 4.8.6
Qt5QuickParticles 5.2.1
QtDesignerComponents 4.8.6
Qt3Support 4.8.6
Qt5QmlDevTools 5.2.1
QtDBus 4.8.6
Qt5Gui 5.2.1
Qt5CLucene 5.2.1
Qt5DBus 5.2.1
Qt5DesignerComponents 5.2.1
QtGui 4.8.6
Qt5Svg 5.2.1
QtXmlPatterns 4.8.6
Qt5OpenGL 5.2.1
QtSvg 4.8.6
QtCLucene 4.8.6
Qt5PrintSupport 5.2.1
Qt5Designer 5.2.1
Reply | Threaded
Open this post in threaded view
|

Re: Rounding of values

Allan.W.Macdonald
My OS is Ubuntu 14.04 LTS.
Reply | Threaded
Open this post in threaded view
|

Re: Rounding of values

ravas
In reply to this post by Allan.W.Macdonald
Thanks! It looks like my guess about 5.3+ was probably right.
However, with the fix I mentioned, I would expect that you can build now.
Reply | Threaded
Open this post in threaded view
|

Re: Rounding of values

ravas
In reply to this post by Allan.W.Macdonald
Reply | Threaded
Open this post in threaded view
|

Re: Rounding of values

Allan.W.Macdonald
In reply to this post by ravas
I just deleted the directory and re-cloned the repo to ensure I got a completely clean start.  It seems to build but I still get what appears to be an error.  The error message appears around line 966 of 1390 lines of make output complaining something about not finding a Boost installation, which I think I have.  My question, is it really an issue or am I good to go?

cd /home/myusername/source/LibreCAD/LibreCAD/librecad/src/../.. && scripts/postprocess-unix.sh
qcollectiongenerator: could not exec '/usr/lib/x86_64-linux-gnu/qt5/bin/qcollectiongenerator': No such file or directory
cp: cannot stat ‘/home/myusername/source/LibreCAD/LibreCAD/librecad/support/doc/*.qch’: No such file or directory
cp: cannot stat ‘/home/myusername/source/LibreCAD/LibreCAD/librecad/support/doc/*.qhc’: No such file or directory
Project ERROR: Boost installation not found.Project ERROR: does not contain a Boost installation/usr/share/qt4/mkspecs/features/qt_functions.prf(117): Function 'system' is not implementedProject MESSAGE: Using external muparserProject MESSAGE: Emulating C99 math features.Project MESSAGE: Warning: unknown QT: help/usr/share/qt4/mkspecs/features/qt_functions.prf(117): Function 'system' is not implementedProject ERROR: Package muparser not foundUpdating '/home/myusername/source/LibreCAD/LibreCAD/librecad/src/../ts/librecad_ar.qm'...
    Generated 618 translation(s) (472 finished and 146 unfinished)
    Ignored 1554 untranslated source text(s)


Also, when I run LibreCAD, I get some info popups such as "Plugin verification data mismatch in '/usr/lib/librecad/libalign.so'", "Plugin verification data mismatch in '/usr/lib/librecad/libasciifile.so'", ... etc.

What is happening here?  I previously installed LibreCAD using apt-get install.  Should I uninstall that first?

Reply | Threaded
Open this post in threaded view
|

Re: Rounding of values

ravas
As far as I understand it, on unix boost is looked for via this code in boost.pri:
BOOST_DIR = $$findBoostDirIn( /usr /usr/local /usr/pkg /opt/local )

Therefore if it is not in one of those locations it will fail. Boost is required.

Something else I'm noticing is you have some qt4 and some qt5 libs.
And I think that is part of the problem.

In https://github.com/LibreCAD/LibreCAD/blob/master/scripts/postprocess-unix.sh
I notice
[ "$( which lrelease-qt4 )" ] && LRELEASE="lrelease-qt4"

Maybe this needs to be updated? This is out of my realm of experience.

You might have more luck if you focus on qt4... unfortunately.

From https://github.com/LibreCAD/LibreCAD/wiki/Build-from-source

Make sure you have the Qt development packages installed. For to install Qt version 4, run the following commands:

$ sudo apt-get install g++ gcc make git-core libqt4-dev qt4-qmake libqt4-help \
qt4-dev-tools libboost-all-dev libmuparser-dev libfreetype6-dev pkg-config

Alternatively, you make sure you have deb-src lines enabled in your sources.list file, and run,

$ sudo apt-get build-dep librecad
Good luck! >_<
Reply | Threaded
Open this post in threaded view
|

Re: Rounding of values

Allan.W.Macdonald
I uninstalled qt4 and qt5 and reinstalled qt4 ($ sudo apt-get build-dep librecad) but I have unresolved dependencies.  Here is the output of apt-get:

myusername@mysystem:~/source/LibreCAD/LibreCAD$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
 libqt4-declarative : Depends: libqtcore4 (= 4:4.8.5+git192-g085f851+dfsg-2ubuntu4.1) but it is not installed
 libqt4-designer : Depends: libqtcore4 (= 4:4.8.5+git192-g085f851+dfsg-2ubuntu4.1) but it is not installed
 libqt4-dev : Depends: libqtcore4 (= 4:4.8.5+git192-g085f851+dfsg-2ubuntu4.1) but it is not installed
 libqt4-dev-bin : Depends: libqtcore4 (= 4:4.8.5+git192-g085f851+dfsg-2ubuntu4.1) but it is not installed
 libqt4-help : Depends: libqtcore4 (= 4:4.8.5+git192-g085f851+dfsg-2ubuntu4.1) but it is not installed
 libqt4-network : Depends: libqtcore4 (= 4:4.8.5+git192-g085f851+dfsg-2ubuntu4.1) but it is not installed
 libqt4-opengl : Depends: libqtcore4 (= 4:4.8.5+git192-g085f851+dfsg-2ubuntu4.1) but it is not installed
 libqt4-qt3support : Depends: libqtcore4 (= 4:4.8.5+git192-g085f851+dfsg-2ubuntu4.1) but it is not installed
 libqt4-script : Depends: libqtcore4 (= 4:4.8.5+git192-g085f851+dfsg-2ubuntu4.1) but it is not installed
 libqt4-scripttools : Depends: libqtcore4 (= 4:4.8.5+git192-g085f851+dfsg-2ubuntu4.1) but it is not installed
 libqt4-sql : Depends: libqtcore4 (= 4:4.8.5+git192-g085f851+dfsg-2ubuntu4.1) but it is not installed
 libqt4-sql-mysql : Depends: libqtcore4 (= 4:4.8.5+git192-g085f851+dfsg-2ubuntu4.1) but it is not installed
 libqt4-sql-sqlite : Depends: libqtcore4 (= 4:4.8.5+git192-g085f851+dfsg-2ubuntu4.1) but it is not installed
 libqt4-svg : Depends: libqtcore4 (= 4:4.8.5+git192-g085f851+dfsg-2ubuntu4.1) but it is not installed
 libqt4-test : Depends: libqtcore4 (= 4:4.8.5+git192-g085f851+dfsg-2ubuntu4.1) but it is not installed
 libqt4-xml : Depends: libqtcore4 (= 4:4.8.5+git192-g085f851+dfsg-2ubuntu4.1) but it is not installed
 libqt4-xmlpatterns : Depends: libqtcore4 (= 4:4.8.5+git192-g085f851+dfsg-2ubuntu4.1) but it is not installed
 libqtdbus4 : Depends: libqtcore4 (= 4:4.8.5+git192-g085f851+dfsg-2ubuntu4.1) but it is not installed
 libqtgui4 : Depends: libqtcore4 (= 4:4.8.5+git192-g085f851+dfsg-2ubuntu4.1) but it is not installed
 libqtwebkit4 : Depends: libqtcore4 (>= 4:4.8.4) but it is not installed
 qdbus : Depends: libqtcore4 (= 4:4.8.5+git192-g085f851+dfsg-2ubuntu4.1) but it is not installed
 qt4-designer : Depends: libqtcore4 (= 4:4.8.5+git192-g085f851+dfsg-2ubuntu4.1) but it is not installed
 qt4-dev-tools : Depends: libqtcore4 (= 4:4.8.5+git192-g085f851+dfsg-2ubuntu4.1) but it is not installed
 qt4-linguist-tools : Depends: libqtcore4 (= 4:4.8.5+git192-g085f851+dfsg-2ubuntu4.1) but it is not installed
E: Unmet dependencies. Try using -f.
myusername@mysystem:~/source/LibreCAD/LibreCAD$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following extra packages will be installed:
  libqtcore4
Suggested packages:
  libicu48
The following NEW packages will be installed:
  libqtcore4
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
31 not fully installed or removed.
Need to get 0 B/1,555 kB of archives.
After this operation, 5,174 kB of additional disk space will be used.
Do you want to continue? [Y/n] 
(Reading database ... 1025905 files and directories currently installed.)
Preparing to unpack .../libqtcore4_4%3a4.8.5+git192-g085f851+dfsg-2ubuntu4.1_amd64.deb ...
Unpacking libqtcore4:amd64 (4:4.8.5+git192-g085f851+dfsg-2ubuntu4.1) ...
dpkg: error processing archive /var/cache/apt/archives/libqtcore4_4%3a4.8.5+git192-g085f851+dfsg-2ubuntu4.1_amd64.deb (--unpack):
 trying to overwrite shared '/etc/xdg/Trolltech.conf', which is different from other instances of package libqtcore4:amd64
Errors were encountered while processing:
 /var/cache/apt/archives/libqtcore4_4%3a4.8.5+git192-g085f851+dfsg-2ubuntu4.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
myusername@mysystem:~/source/LibreCAD/LibreCAD$ 

Any help would be appreciated.
Reply | Threaded
Open this post in threaded view
|

Re: Rounding of values

Allan.W.Macdonald
Hey folks,

I found a solution to my last post after hours of agonizing googling!

$ sudo dpkg --force-all --purge libqtcore4
$ sudo apt-get install libqtcore4

Now, apt-get update and upgrade do not give errors.

I'm not sure what happened to my config files but it seems to be fixed now.  I will now try building the source.  Stay tuned!

Allan
12