drawing text issue

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

drawing text issue

Johnson
I want to draw TEXT directly into view, not using RS_Text, but the "ABCD" could not be displayed ...
Anybody know what's the problems ?

void QC_ApplicationWindow::testFont()
{
    RS_PainterQt painter(getMDIWindow()->getGraphicView()->PixmapLayer2);
    painter.setPen(0,0,255);
    painter.drawText(0,0,"ABCD");
    painter.end();
    getGraphicView()->redraw();
}
Reply | Threaded
Open this post in threaded view
|

Re: drawing text issue

dxli
Hi Johnson,

You can draw text efficiently(see the patch).

CAD uses stick fonts because all fonts are drawn as lines(polylines) and can be converted to CAD entities.

I'm wondering if it's okay to support ordinary fonts, and only revert back to stick fonts when converting is needed. This means efficiency and easy support for all languages.

For the time being, let's fix bugs in 2.0 for a stable release. After that, we implement new features in 2.1.

Thanks,

dxli


diff --git a/librecad/src/lib/gui/rs_graphicview.cpp b/librecad/src/lib/gui/rs_graphicview.cpp
index 726286d..4ee6364 100644
--- a/librecad/src/lib/gui/rs_graphicview.cpp
+++ b/librecad/src/lib/gui/rs_graphicview.cpp
@@ -28,6 +28,7 @@
 #include <limits.h>
 #include "qc_applicationwindow.h"
 #include "rs_graphicview.h"
+#include "rs_painterqt.h"
 
 #include "rs_linetypepattern.h"
 #include "rs_eventhandler.h"
@@ -1094,6 +1095,13 @@ void RS_GraphicView::drawLayer2(RS_Painter *painter)
     // ----------------------------------------------------------
     if (!isPrintPreview())
         drawAbsoluteZero(painter);
+    RS_PainterQt* p0=dynamic_cast<RS_PainterQt*>(painter);
+    if(p0) {
+        DEBUG_HEADER();
+       p0->setPen(0,0,255);
+       p0->setFont(QFont("Times", 20, QFont::Bold));
+       p0->drawText(100, 100, 100, 100, Qt::AlignHCenter, "ABCD");
+    }
 }
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Re: drawing text issue

Johnson
Hi Dxli
 
Yeah. It works.    the text could not be stored into DXF file.  I understand that because the "ABCD" could NOT be converted to CAD entities.  (  it's not a rs_entity too )
 
But I am confused why my below code could not work as expected.
 
----
void QC_ApplicationWindow::testFont()
{
    RS_PainterQt painter(getMDIWindow()->getGraphicView()->PixmapLayer2);
    painter.setPen(0,0,255);
    painter.drawText(0,0,"ABCD");
    painter.end();
    getGraphicView()->redraw();
}
----
 
After that, QG_GraphicView::paintEvent  will be called too. .. why the result is not like as your result with your code.
 
My another question is that now it seems even not response to "zoom in" / "zoom out " ,keep the size forever,   can I fix that to response to zoom in /out ?   Thanks.
 
About your "For the time being, let's fix bugs in 2.0 for a stable release. After that, we implement new features in 2.1. ".  do you mean you will fix this issue (still use stick font ) in later release ?
 
 

wingame82
 
Date: 2013-05-23 19:09
Subject: Re: drawing text issue
Hi Johnson,

You can draw text efficiently(see the patch).

CAD uses stick fonts because all fonts are drawn as lines(polylines) and can be converted to CAD entities.

I'm wondering if it's okay to support ordinary fonts, and only revert back to stick fonts when converting is needed. This means efficiency and easy support for all languages.

For the time being, let's fix bugs in 2.0 for a stable release. After that, we implement new features in 2.1.

Thanks,

dxli


diff --git a/librecad/src/lib/gui/rs_graphicview.cpp b/librecad/src/lib/gui/rs_graphicview.cpp
index 726286d..4ee6364 100644
--- a/librecad/src/lib/gui/rs_graphicview.cpp
+++ b/librecad/src/lib/gui/rs_graphicview.cpp
@@ -28,6 +28,7 @@
 #include <limits.h>
 #include "qc_applicationwindow.h"
 #include "rs_graphicview.h"
+#include "rs_painterqt.h"
 
 #include "rs_linetypepattern.h"
 #include "rs_eventhandler.h"
@@ -1094,6 +1095,13 @@ void RS_GraphicView::drawLayer2(RS_Painter *painter)
     // ----------------------------------------------------------
     if (!isPrintPreview())
         drawAbsoluteZero(painter);
+    RS_PainterQt* p0=dynamic_cast<RS_PainterQt*>(painter);
+    if(p0) {
+        DEBUG_HEADER();
+       p0->setPen(0,0,255);
+       p0->setFont(QFont("Times", 20, QFont::Bold));
+       p0->drawText(100, 100, 100, 100, Qt::AlignHCenter, "ABCD");
+    }
 }
 
 



If you reply to this email, your message will be added to the discussion below:
http://forum.librecad.org/drawing-text-issue-tp5708110p5708111.html
To start a new topic under LibreCAD-dev, email [hidden email]
To unsubscribe from LibreCAD-dev, click here.
NAML
Reply | Threaded
Open this post in threaded view
|

Re: Re: drawing text issue

Johnson
In reply to this post by dxli
Hi,  DxLi and Rallaz
 
Currently I don't need CAD purpose , so I could use system QT fonts .
 
But my difficulities now is that
1.  where should the place I insert each text ? Is there any other place rather than drawLayer2 because this function will be drawn by paintEvent as soon as update is called.
 
2.  my requirement is to draw a line ,   on the left up place of the line, I will draft a line.
    I think I could use RS_Line entity and drawText function with system QT font.
    but the problem now is that if I zoom in/out the view,  the RS_line will be changed correspondingly, but the text won't changed.
   
Could you kindly guide me where to implement this feature ? Thanks.
 

wingame82
 

 
Date: 2013-05-23 19:09
Subject: Re: drawing text issue
Hi Johnson,

You can draw text efficiently(see the patch).

CAD uses stick fonts because all fonts are drawn as lines(polylines) and can be converted to CAD entities.

I'm wondering if it's okay to support ordinary fonts, and only revert back to stick fonts when converting is needed. This means efficiency and easy support for all languages.

For the time being, let's fix bugs in 2.0 for a stable release. After that, we implement new features in 2.1.

Thanks,

dxli


diff --git a/librecad/src/lib/gui/rs_graphicview.cpp b/librecad/src/lib/gui/rs_graphicview.cpp
index 726286d..4ee6364 100644
--- a/librecad/src/lib/gui/rs_graphicview.cpp
+++ b/librecad/src/lib/gui/rs_graphicview.cpp
@@ -28,6 +28,7 @@
 #include <limits.h>
 #include "qc_applicationwindow.h"
 #include "rs_graphicview.h"
+#include "rs_painterqt.h"
 
 #include "rs_linetypepattern.h"
 #include "rs_eventhandler.h"
@@ -1094,6 +1095,13 @@ void RS_GraphicView::drawLayer2(RS_Painter *painter)
     // ----------------------------------------------------------
     if (!isPrintPreview())
         drawAbsoluteZero(painter);
+    RS_PainterQt* p0=dynamic_cast<RS_PainterQt*>(painter);
+    if(p0) {
+        DEBUG_HEADER();
+       p0->setPen(0,0,255);
+       p0->setFont(QFont("Times", 20, QFont::Bold));
+       p0->drawText(100, 100, 100, 100, Qt::AlignHCenter, "ABCD");
+    }
 }
 
 



If you reply to this email, your message will be added to the discussion below:
http://forum.librecad.org/drawing-text-issue-tp5708110p5708111.html
To start a new topic under LibreCAD-dev, email [hidden email]
To unsubscribe from LibreCAD-dev, click here.
NAML
Reply | Threaded
Open this post in threaded view
|

Re: Re: drawing text issue

dxli
Hi Johnson,

I'm thinking about adding a feature to the RS_Text RS_MText entities.

like:

bool m_bUseNativeFonts; //default to true

in the RS_Text::draw() method, you implement drawing native drawText() (should be added from in RS_PainterQt()), according to color, scaling factor, orientation, etc.

For zooming, please note we have a model space (as entity sizes are), and a screen(GUI) space as controlled by zooming factor. draw() methods must do the conversion.

Current font selection is by LibreCAD fonts, we need to implement a selection mechanism for native fonts.

I suggest you to share your implementation in LibreCAD license, i.e., GPLv2 or any later version. By doing so, we can we together to get this important feature.

Thanks,

Dongxu

On Sun, May 26, 2013 at 12:07 PM, Johnson [via LibreCAD] <[hidden email]> wrote:
Hi,  DxLi and Rallaz
 
Currently I don't need CAD purpose , so I could use system QT fonts .
 
But my difficulities now is that
1.  where should the place I insert each text ? Is there any other place rather than drawLayer2 because this function will be drawn by paintEvent as soon as update is called.
 
2.  my requirement is to draw a line ,   on the left up place of the line, I will draft a line.
    I think I could use RS_Line entity and drawText function with system QT font.
    but the problem now is that if I zoom in/out the view,  the RS_line will be changed correspondingly, but the text won't changed.
   
Could you kindly guide me where to implement this feature ? Thanks.
 

wingame82
 

 
Date: <a href="tel:2013-05-23%C2%A019" value="+12013052319" target="_blank">2013-05-23 19:09
Subject: Re: drawing text issue
Hi Johnson,

You can draw text efficiently(see the patch).

CAD uses stick fonts because all fonts are drawn as lines(polylines) and can be converted to CAD entities.

I'm wondering if it's okay to support ordinary fonts, and only revert back to stick fonts when converting is needed. This means efficiency and easy support for all languages.

For the time being, let's fix bugs in 2.0 for a stable release. After that, we implement new features in 2.1.

Thanks,

dxli


diff --git a/librecad/src/lib/gui/rs_graphicview.cpp b/librecad/src/lib/gui/rs_graphicview.cpp
index 726286d..4ee6364 100644
--- a/librecad/src/lib/gui/rs_graphicview.cpp
+++ b/librecad/src/lib/gui/rs_graphicview.cpp
@@ -28,6 +28,7 @@
 #include <limits.h>
 #include "qc_applicationwindow.h"
 #include "rs_graphicview.h"
+#include "rs_painterqt.h"
 
 #include "rs_linetypepattern.h"
 #include "rs_eventhandler.h"
@@ -1094,6 +1095,13 @@ void RS_GraphicView::drawLayer2(RS_Painter *painter)
     // ----------------------------------------------------------
     if (!isPrintPreview())
         drawAbsoluteZero(painter);
+    RS_PainterQt* p0=dynamic_cast<RS_PainterQt*>(painter);
+    if(p0) {
+        DEBUG_HEADER();
+       p0->setPen(0,0,255);
+       p0->setFont(QFont("Times", 20, QFont::Bold));
+       p0->drawText(100, 100, 100, 100, Qt::AlignHCenter, "ABCD");
+    }
 }
 
 



If you reply to this email, your message will be added to the discussion below:
http://forum.librecad.org/drawing-text-issue-tp5708110p5708111.html
To start a new topic under LibreCAD-dev, email [hidden email]
To unsubscribe from LibreCAD-dev, click here.
NAML



If you reply to this email, your message will be added to the discussion below:
http://forum.librecad.org/drawing-text-issue-tp5708110p5708119.html
To start a new topic under LibreCAD-dev, email [hidden email]
To unsubscribe from LibreCAD-dev, click here.
NAML



--
Dongxu Li, Ph.D.
www.librecad.org
Reply | Threaded
Open this post in threaded view
|

Re: Re: drawing text issue

Johnson
Hi Dxli
 
I did not see RS_Text::draw()  function .  could you figure out which function is your purpose  to do this feature ? Thanks.
 

wingame82
 
Date: 2013-05-27 10:28
Subject: Re: Re: drawing text issue
Hi Johnson,

I'm thinking about adding a feature to the RS_Text RS_MText entities.

like:

bool m_bUseNativeFonts; //default to true

in the RS_Text::draw() method, you implement drawing native drawText() (should be added from in RS_PainterQt()), according to color, scaling factor, orientation, etc.

For zooming, please note we have a model space (as entity sizes are), and a screen(GUI) space as controlled by zooming factor. draw() methods must do the conversion.

Current font selection is by LibreCAD fonts, we need to implement a selection mechanism for native fonts.

I suggest you to share your implementation in LibreCAD license, i.e., GPLv2 or any later version. By doing so, we can we together to get this important feature.

Thanks,

Dongxu

On Sun, May 26, 2013 at 12:07 PM, Johnson [via LibreCAD] <[hidden email]> wrote:
Hi,  DxLi and Rallaz
 
Currently I don't need CAD purpose , so I could use system QT fonts .
 
But my difficulities now is that
1.  where should the place I insert each text ? Is there any other place rather than drawLayer2 because this function will be drawn by paintEvent as soon as update is called.
 
2.  my requirement is to draw a line ,   on the left up place of the line, I will draft a line.
    I think I could use RS_Line entity and drawText function with system QT font.
    but the problem now is that if I zoom in/out the view,  the RS_line will be changed correspondingly, but the text won't changed.
   
Could you kindly guide me where to implement this feature ? Thanks.
 

wingame82
 

 
Date: <a href="tel:2013-05-23%C2%A019" value="+12013052319" target="_blank">2013-05-23 19:09
Subject: Re: drawing text issue
Hi Johnson,

You can draw text efficiently(see the patch).

CAD uses stick fonts because all fonts are drawn as lines(polylines) and can be converted to CAD entities.

I'm wondering if it's okay to support ordinary fonts, and only revert back to stick fonts when converting is needed. This means efficiency and easy support for all languages.

For the time being, let's fix bugs in 2.0 for a stable release. After that, we implement new features in 2.1.

Thanks,

dxli


diff --git a/librecad/src/lib/gui/rs_graphicview.cpp b/librecad/src/lib/gui/rs_graphicview.cpp
index 726286d..4ee6364 100644
--- a/librecad/src/lib/gui/rs_graphicview.cpp
+++ b/librecad/src/lib/gui/rs_graphicview.cpp
@@ -28,6 +28,7 @@
 #include <limits.h>
 #include "qc_applicationwindow.h"
 #include "rs_graphicview.h"
+#include "rs_painterqt.h"
 
 #include "rs_linetypepattern.h"
 #include "rs_eventhandler.h"
@@ -1094,6 +1095,13 @@ void RS_GraphicView::drawLayer2(RS_Painter *painter)
     // ----------------------------------------------------------
     if (!isPrintPreview())
         drawAbsoluteZero(painter);
+    RS_PainterQt* p0=dynamic_cast<RS_PainterQt*>(painter);
+    if(p0) {
+        DEBUG_HEADER();
+       p0->setPen(0,0,255);
+       p0->setFont(QFont("Times", 20, QFont::Bold));
+       p0->drawText(100, 100, 100, 100, Qt::AlignHCenter, "ABCD");
+    }
 }
 
 



If you reply to this email, your message will be added to the discussion below:
http://forum.librecad.org/drawing-text-issue-tp5708110p5708111.html
To start a new topic under LibreCAD-dev, email [hidden email]
To unsubscribe from LibreCAD-dev, click here.
NAML



If you reply to this email, your message will be added to the discussion below:
http://forum.librecad.org/drawing-text-issue-tp5708110p5708119.html
To start a new topic under LibreCAD-dev, email [hidden email]
To unsubscribe from LibreCAD-dev, click here.
NAML



--
Dongxu Li, Ph.D.
www.librecad.org



If you reply to this email, your message will be added to the discussion below:
http://forum.librecad.org/drawing-text-issue-tp5708110p5708122.html
To start a new topic under LibreCAD-dev, email [hidden email]
To unsubscribe from LibreCAD-dev, click here.
NAML
Reply | Threaded
Open this post in threaded view
|

Re: Re: drawing text issue

Johnson
In reply to this post by dxli
Hi Dxli
 
I could help on this requirment when I am free.
 
Another question is that .  If I use native text,  the saved file *.dxf won't include those text .    I don't need this requirement  currently , but this should be considered in future,   how to resolve this problem from your thinking ?
 

wingame82
 
Date: 2013-05-27 10:28
Subject: Re: Re: drawing text issue
Hi Johnson,

I'm thinking about adding a feature to the RS_Text RS_MText entities.

like:

bool m_bUseNativeFonts; //default to true

in the RS_Text::draw() method, you implement drawing native drawText() (should be added from in RS_PainterQt()), according to color, scaling factor, orientation, etc.

For zooming, please note we have a model space (as entity sizes are), and a screen(GUI) space as controlled by zooming factor. draw() methods must do the conversion.

Current font selection is by LibreCAD fonts, we need to implement a selection mechanism for native fonts.

I suggest you to share your implementation in LibreCAD license, i.e., GPLv2 or any later version. By doing so, we can we together to get this important feature.

Thanks,

Dongxu

On Sun, May 26, 2013 at 12:07 PM, Johnson [via LibreCAD] <[hidden email]> wrote:
Hi,  DxLi and Rallaz
 
Currently I don't need CAD purpose , so I could use system QT fonts .
 
But my difficulities now is that
1.  where should the place I insert each text ? Is there any other place rather than drawLayer2 because this function will be drawn by paintEvent as soon as update is called.
 
2.  my requirement is to draw a line ,   on the left up place of the line, I will draft a line.
    I think I could use RS_Line entity and drawText function with system QT font.
    but the problem now is that if I zoom in/out the view,  the RS_line will be changed correspondingly, but the text won't changed.
   
Could you kindly guide me where to implement this feature ? Thanks.
 

wingame82
 

 
Date: <a href="tel:2013-05-23%C2%A019" value="+12013052319" target="_blank">2013-05-23 19:09
Subject: Re: drawing text issue
Hi Johnson,

You can draw text efficiently(see the patch).

CAD uses stick fonts because all fonts are drawn as lines(polylines) and can be converted to CAD entities.

I'm wondering if it's okay to support ordinary fonts, and only revert back to stick fonts when converting is needed. This means efficiency and easy support for all languages.

For the time being, let's fix bugs in 2.0 for a stable release. After that, we implement new features in 2.1.

Thanks,

dxli


diff --git a/librecad/src/lib/gui/rs_graphicview.cpp b/librecad/src/lib/gui/rs_graphicview.cpp
index 726286d..4ee6364 100644
--- a/librecad/src/lib/gui/rs_graphicview.cpp
+++ b/librecad/src/lib/gui/rs_graphicview.cpp
@@ -28,6 +28,7 @@
 #include <limits.h>
 #include "qc_applicationwindow.h"
 #include "rs_graphicview.h"
+#include "rs_painterqt.h"
 
 #include "rs_linetypepattern.h"
 #include "rs_eventhandler.h"
@@ -1094,6 +1095,13 @@ void RS_GraphicView::drawLayer2(RS_Painter *painter)
     // ----------------------------------------------------------
     if (!isPrintPreview())
         drawAbsoluteZero(painter);
+    RS_PainterQt* p0=dynamic_cast<RS_PainterQt*>(painter);
+    if(p0) {
+        DEBUG_HEADER();
+       p0->setPen(0,0,255);
+       p0->setFont(QFont("Times", 20, QFont::Bold));
+       p0->drawText(100, 100, 100, 100, Qt::AlignHCenter, "ABCD");
+    }
 }
 
 



If you reply to this email, your message will be added to the discussion below:
http://forum.librecad.org/drawing-text-issue-tp5708110p5708111.html
To start a new topic under LibreCAD-dev, email [hidden email]
To unsubscribe from LibreCAD-dev, click here.
NAML



If you reply to this email, your message will be added to the discussion below:
http://forum.librecad.org/drawing-text-issue-tp5708110p5708119.html
To start a new topic under LibreCAD-dev, email [hidden email]
To unsubscribe from LibreCAD-dev, click here.
NAML



--
Dongxu Li, Ph.D.
www.librecad.org



If you reply to this email, your message will be added to the discussion below:
http://forum.librecad.org/drawing-text-issue-tp5708110p5708122.html
To start a new topic under LibreCAD-dev, email [hidden email]
To unsubscribe from LibreCAD-dev, click here.
NAML
Reply | Threaded
Open this post in threaded view
|

Re: Re: drawing text issue

dxli
In reply to this post by Johnson
Hi,

RS_Text is derived from RS_EntityContainer

You can define a virtual function draw() in RS_Text then.

On Sun, May 26, 2013 at 10:39 PM, Johnson [via LibreCAD] <[hidden email]> wrote:
Hi Dxli
 
I did not see RS_Text::draw()  function .  could you figure out which function is your purpose  to do this feature ? Thanks.
 

wingame82
 
Date: <a href="tel:2013-05-27%C2%A010" value="+12013052710" target="_blank">2013-05-27 10:28
Subject: Re: Re: drawing text issue
Hi Johnson,

I'm thinking about adding a feature to the RS_Text RS_MText entities.

like:

bool m_bUseNativeFonts; //default to true

in the RS_Text::draw() method, you implement drawing native drawText() (should be added from in RS_PainterQt()), according to color, scaling factor, orientation, etc.

For zooming, please note we have a model space (as entity sizes are), and a screen(GUI) space as controlled by zooming factor. draw() methods must do the conversion.

Current font selection is by LibreCAD fonts, we need to implement a selection mechanism for native fonts.

I suggest you to share your implementation in LibreCAD license, i.e., GPLv2 or any later version. By doing so, we can we together to get this important feature.

Thanks,

Dongxu

On Sun, May 26, 2013 at 12:07 PM, Johnson [via LibreCAD] <[hidden email]> wrote:
Hi,  DxLi and Rallaz
 
Currently I don't need CAD purpose , so I could use system QT fonts .
 
But my difficulities now is that
1.  where should the place I insert each text ? Is there any other place rather than drawLayer2 because this function will be drawn by paintEvent as soon as update is called.
 
2.  my requirement is to draw a line ,   on the left up place of the line, I will draft a line.
    I think I could use RS_Line entity and drawText function with system QT font.
    but the problem now is that if I zoom in/out the view,  the RS_line will be changed correspondingly, but the text won't changed.
   
Could you kindly guide me where to implement this feature ? Thanks.
 

wingame82
 

 
Date: <a href="tel:2013-05-23%C2%A019" value="<a href="tel:%2B12013052319" value="+12013052319" target="_blank">+12013052319" target="_blank"><a href="tel:2013-05-23%C2%A019" value="+12013052319" target="_blank">2013-05-23 19:09
Subject: Re: drawing text issue
Hi Johnson,

You can draw text efficiently(see the patch).

CAD uses stick fonts because all fonts are drawn as lines(polylines) and can be converted to CAD entities.

I'm wondering if it's okay to support ordinary fonts, and only revert back to stick fonts when converting is needed. This means efficiency and easy support for all languages.

For the time being, let's fix bugs in 2.0 for a stable release. After that, we implement new features in 2.1.

Thanks,

dxli


diff --git a/librecad/src/lib/gui/rs_graphicview.cpp b/librecad/src/lib/gui/rs_graphicview.cpp
index 726286d..4ee6364 100644
--- a/librecad/src/lib/gui/rs_graphicview.cpp
+++ b/librecad/src/lib/gui/rs_graphicview.cpp
@@ -28,6 +28,7 @@
 #include <limits.h>
 #include "qc_applicationwindow.h"
 #include "rs_graphicview.h"
+#include "rs_painterqt.h"
 
 #include "rs_linetypepattern.h"
 #include "rs_eventhandler.h"
@@ -1094,6 +1095,13 @@ void RS_GraphicView::drawLayer2(RS_Painter *painter)
     // ----------------------------------------------------------
     if (!isPrintPreview())
         drawAbsoluteZero(painter);
+    RS_PainterQt* p0=dynamic_cast<RS_PainterQt*>(painter);
+    if(p0) {
+        DEBUG_HEADER();
+       p0->setPen(0,0,255);
+       p0->setFont(QFont("Times", 20, QFont::Bold));
+       p0->drawText(100, 100, 100, 100, Qt::AlignHCenter, "ABCD");
+    }
 }
 
 



If you reply to this email, your message will be added to the discussion below:
http://forum.librecad.org/drawing-text-issue-tp5708110p5708111.html
To start a new topic under LibreCAD-dev, email [hidden email]
To unsubscribe from LibreCAD-dev, click here.
NAML



If you reply to this email, your message will be added to the discussion below:
http://forum.librecad.org/drawing-text-issue-tp5708110p5708119.html
To start a new topic under LibreCAD-dev, email [hidden email]
To unsubscribe from LibreCAD-dev, click here.
NAML



--
Dongxu Li, Ph.D.
www.librecad.org



If you reply to this email, your message will be added to the discussion below:
http://forum.librecad.org/drawing-text-issue-tp5708110p5708122.html
To start a new topic under LibreCAD-dev, email [hidden email]
To unsubscribe from LibreCAD-dev, click here.
NAML



If you reply to this email, your message will be added to the discussion below:
http://forum.librecad.org/drawing-text-issue-tp5708110p5708123.html
To start a new topic under LibreCAD-dev, email [hidden email]
To unsubscribe from LibreCAD-dev, click here.
NAML



--
Dongxu Li, Ph.D.
www.librecad.org
Reply | Threaded
Open this post in threaded view
|

Re: Re: drawing text issue

Johnson
Yes.  you're right .
I think I also need to disable update function for rs_text class.
 

wingame82
 
Date: 2013-05-27 13:07
Subject: Re: Re: drawing text issue
Hi,

RS_Text is derived from RS_EntityContainer

You can define a virtual function draw() in RS_Text then.

On Sun, May 26, 2013 at 10:39 PM, Johnson [via LibreCAD] <[hidden email]> wrote:
Hi Dxli
 
I did not see RS_Text::draw()  function .  could you figure out which function is your purpose  to do this feature ? Thanks.
 

wingame82
 
Date: <a href="tel:2013-05-27%C2%A010" value="+12013052710" target="_blank">2013-05-27 10:28
Subject: Re: Re: drawing text issue
Hi Johnson,

I'm thinking about adding a feature to the RS_Text RS_MText entities.

like:

bool m_bUseNativeFonts; //default to true

in the RS_Text::draw() method, you implement drawing native drawText() (should be added from in RS_PainterQt()), according to color, scaling factor, orientation, etc.

For zooming, please note we have a model space (as entity sizes are), and a screen(GUI) space as controlled by zooming factor. draw() methods must do the conversion.

Current font selection is by LibreCAD fonts, we need to implement a selection mechanism for native fonts.

I suggest you to share your implementation in LibreCAD license, i.e., GPLv2 or any later version. By doing so, we can we together to get this important feature.

Thanks,

Dongxu

On Sun, May 26, 2013 at 12:07 PM, Johnson [via LibreCAD] <[hidden email]> wrote:
Hi,  DxLi and Rallaz
 
Currently I don't need CAD purpose , so I could use system QT fonts .
 
But my difficulities now is that
1.  where should the place I insert each text ? Is there any other place rather than drawLayer2 because this function will be drawn by paintEvent as soon as update is called.
 
2.  my requirement is to draw a line ,   on the left up place of the line, I will draft a line.
    I think I could use RS_Line entity and drawText function with system QT font.
    but the problem now is that if I zoom in/out the view,  the RS_line will be changed correspondingly, but the text won't changed.
   
Could you kindly guide me where to implement this feature ? Thanks.
 

wingame82
 

 
Date: <a href="tel:2013-05-23%C2%A019" value="<a href="tel:%2B12013052319" value="+12013052319" target="_blank">+12013052319" target="_blank"><a href="tel:2013-05-23%C2%A019" value="+12013052319" target="_blank">2013-05-23 19:09
Subject: Re: drawing text issue
Hi Johnson,

You can draw text efficiently(see the patch).

CAD uses stick fonts because all fonts are drawn as lines(polylines) and can be converted to CAD entities.

I'm wondering if it's okay to support ordinary fonts, and only revert back to stick fonts when converting is needed. This means efficiency and easy support for all languages.

For the time being, let's fix bugs in 2.0 for a stable release. After that, we implement new features in 2.1.

Thanks,

dxli


diff --git a/librecad/src/lib/gui/rs_graphicview.cpp b/librecad/src/lib/gui/rs_graphicview.cpp
index 726286d..4ee6364 100644
--- a/librecad/src/lib/gui/rs_graphicview.cpp
+++ b/librecad/src/lib/gui/rs_graphicview.cpp
@@ -28,6 +28,7 @@
 #include <limits.h>
 #include "qc_applicationwindow.h"
 #include "rs_graphicview.h"
+#include "rs_painterqt.h"
 
 #include "rs_linetypepattern.h"
 #include "rs_eventhandler.h"
@@ -1094,6 +1095,13 @@ void RS_GraphicView::drawLayer2(RS_Painter *painter)
     // ----------------------------------------------------------
     if (!isPrintPreview())
         drawAbsoluteZero(painter);
+    RS_PainterQt* p0=dynamic_cast<RS_PainterQt*>(painter);
+    if(p0) {
+        DEBUG_HEADER();
+       p0->setPen(0,0,255);
+       p0->setFont(QFont("Times", 20, QFont::Bold));
+       p0->drawText(100, 100, 100, 100, Qt::AlignHCenter, "ABCD");
+    }
 }
 
 



If you reply to this email, your message will be added to the discussion below:
http://forum.librecad.org/drawing-text-issue-tp5708110p5708111.html
To start a new topic under LibreCAD-dev, email [hidden email]
To unsubscribe from LibreCAD-dev, click here.
NAML



If you reply to this email, your message will be added to the discussion below:
http://forum.librecad.org/drawing-text-issue-tp5708110p5708119.html
To start a new topic under LibreCAD-dev, email [hidden email]
To unsubscribe from LibreCAD-dev, click here.
NAML



--
Dongxu Li, Ph.D.
www.librecad.org



If you reply to this email, your message will be added to the discussion below:
http://forum.librecad.org/drawing-text-issue-tp5708110p5708122.html
To start a new topic under LibreCAD-dev, email [hidden email]
To unsubscribe from LibreCAD-dev, click here.
NAML



If you reply to this email, your message will be added to the discussion below:
http://forum.librecad.org/drawing-text-issue-tp5708110p5708123.html
To start a new topic under LibreCAD-dev, email [hidden email]
To unsubscribe from LibreCAD-dev, click here.
NAML



--
Dongxu Li, Ph.D.
www.librecad.org



If you reply to this email, your message will be added to the discussion below:
http://forum.librecad.org/drawing-text-issue-tp5708110p5708125.html
To start a new topic under LibreCAD-dev, email [hidden email]
To unsubscribe from LibreCAD-dev, click here.
NAML
Reply | Threaded
Open this post in threaded view
|

Re: Re: drawing text issue

cantcode
hi,
I'm a noob in coding and want to learn how to code. So if someone does have some time, can you answer my questions, please:

"RS_Text is derived from RS_EntityContainer. You can define a virtual function draw() in RS_Text then."

If RS_Text is derived from RS_EntityContainer, shouldn't the draw() function beeing implemented in the RS_EntityContainer class? (cause using virtual??)

"For zooming, please note we have a model space (as entity sizes are), and a screen(GUI) space as controlled by zooming factor. draw() methods must do the conversion."

What is the model space and the screen space?
model space: the canvas, where drwing is performed??
screen space: the GUI?? so one can zoom the GUI??
Reply | Threaded
Open this post in threaded view
|

Re: Re: drawing text issue

Johnson
RS_EntityContainer could not implement draw because this is a "virtual" class who don't know what's the object to draw.
RS_Text is a special derived RS_EntityContainer class , from the name you know it's "TEXT".
 
Yes, I need to do conversion in the implementation of draw . you could refer to RS_Line class.
 
Other question leave to other expert to answer  :)
 

wingame82
 
Date: 2013-05-28 16:43
Subject: Re: Re: drawing text issue
hi,
I'm a noob in coding and want to learn how to code. So if someone does have some time, can you answer my questions, please:

"RS_Text is derived from RS_EntityContainer. You can define a virtual function draw() in RS_Text then."

If RS_Text is derived from RS_EntityContainer, shouldn't the draw() function beeing implemented in the RS_EntityContainer class? (cause using virtual??)

"For zooming, please note we have a model space (as entity sizes are), and a screen(GUI) space as controlled by zooming factor. draw() methods must do the conversion."

What is the model space and the screen space?
model space: the canvas, where drwing is performed??
screen space: the GUI?? so one can zoom the GUI??


If you reply to this email, your message will be added to the discussion below:
http://forum.librecad.org/drawing-text-issue-tp5708110p5708130.html
To start a new topic under LibreCAD-dev, email [hidden email]
To unsubscribe from LibreCAD-dev, click here.
NAML
Reply | Threaded
Open this post in threaded view
|

Re: Re: drawing text issue

cantcode
thx for the fast answer.
Why should the draw function be virtual?
I thought that virtual should be used if you want to derive from this class (so thats why I thought draw should be implemented in RS_EntityContainer). Or are there classes which are derived from RS_Text?
Reply | Threaded
Open this post in threaded view
|

Re: Re: drawing text issue

Johnson
RS_Entity and RS_EntityContainer ( contains many RS_Entitys...  )is an Abstract class which is the base class for basic graphic class such as RS_line and RS_Circle etc.
 
 

wingame82
 
Date: 2013-05-28 19:14
Subject: Re: Re: drawing text issue
thx for the fast answer.
Why should the draw function be virtual?
I thought that virtual should be used if you want to derive from this class (so thats why I thought draw should be implemented in RS_EntityContainer). Or are there classes which are derived from RS_Text?


If you reply to this email, your message will be added to the discussion below:
http://forum.librecad.org/drawing-text-issue-tp5708110p5708132.html
To start a new topic under LibreCAD-dev, email [hidden email]
To unsubscribe from LibreCAD-dev, click here.
NAML
Reply | Threaded
Open this post in threaded view
|

Re: Re: drawing text issue

cantcode
stupid me,

I didn't know that draw was already defined in RS_Entity.
Now I understand why you should "redefine" the draw() function as virtual in RS_Text.

many thanks.