Hi,
This is my opinion about Graphics4VO. I've written this text for those
people who are not sure if this library is suitable for their needs. I hope
it helps to make a decision. I also would like to thank for the great
support from Fred, the author of G4VO.
I was working with Graphic4VO library for several months. My main goal was
to develop an application which reads electrical measurements from measurers
connected via serial port and presents them in a chart form. My client
wanted the application to export charts in rastered and vectorised format
and copy the charts to a clipboard in both formats, as well. If you want to
see what measurers I am talking about, look into my client site:
http://www.sonel.com.pl/
At this stage, my knowledge about vectorised formats was rather poor. I
thought that it is enough to convert raster to vectorised format with a help
of one of free converting librariers.
The application could not use an Execel, because a final client needs to
have an Excel to use it. The same problem was with Office Web components.
The only way was that the application must create charts itself and
natively.
Of course, I like VO, as we all do, I prefered to use a library from our VO
community. So very soon, I downloaded Graphic4VO demo version to check if it
is suitable for me. At this very early stage I've found some small issues
and asked the author for help. He helped me very fast with private and
public corespondence.
After some time I decided to buy G4VO. During my learning time I found more
problems and several issues. Some of them were posted privately and some
were posted public. Fred prefers to get information about G4VO rather
public, because it helps to other G2VO users too, and he can manage a
subject once.
At last I hit a wall. I realized that I am unable to export/copy charts in
vectorised formats. My application was ready in a 70%. I dramatically was
looking for the way how to do it. At first I tried to convert raster format
to EMF format - wrong way.
I stopped using the G4VO and started looking for a free or commercial
library which can create charts/pictires in vectorized format:
1. MS Excel, at first step I again had to look if Execel is able to save
charts in vectorised format, unfortunately NO
2. MS Graphs - NO
3. MS Office Web Components - NO
4. Several others commercial libraries - NO.
At last I found MetaDraw. Yes, that is it. MetaDraw fully works in vectors
mode but it is not a VO library and it is very expensive.
During this time I found, that if a device context is opened with
CreateEnhMetaFile, than all graphics work is recorder in a file which can be
played later.
I asked Fred what is his opinion if it is possible to include vectorised
format into G4VO. It was bad time for me, I did'nt know what I should do
next. After some time I received a letter form Fred. He informed me that he
was just working on the this subject. I was very happy. I offered additional
payment for his hard work but Fred refused. He only wanted me to make some
tests with a new G4VO library.
My work started again and soon I finished the application. The charts can be
exported in the following formats:
1. Rastered: BMP, DIB, JPG, PNG, TIFF
2. Vectorised: WMF, EMF
The charts can be copied to a clipboard in BMP/DIB and WMF/EMF formats.
Vectorised picture can be scaled in any size. The view is perfect.
Unfortunately the EMF pictures cannot be printed in ReportPro. It does not
allow to include vectorised pictures.
Of course there were much more work then I described. The main problem I had
with large charts which were built from several thousands points. The time
needed to build a chart was about several seconds. Each window resize,
minimalize, tab page changing etc. forced calling Paint() method.
Soon, I discovered, that G4VO sometimes calls Paint() method when it is not
needed. I included some piece of the code to supress Paint() and informed
Fred about it. And, as usually, Fred improved G4VO very much. He removed
unneeded Paint() calls. His support was and still is very good.
At last, I found the way how use vectorised format to get the chart painted
very fast even when the window is resized. I found also, how to paint a
chart/pictures on a subwindows or elsewhere on a window, for example 3
independent charts on 3 subwindows on one DataWindow etc.
To explain it, at first, I need to describe how it works originally.
1. Paint() - here is a definition how to build a chart/picture. For large
charts each Paint() call costs several seconds.
2. Whenever a window need to be repainted, G4VO calls Paint(). It occurs
mainly when window resize is needed.
3. Window has to be inherited from one of G4VO graphic classes.
My idea uses vectorised format and instead call the Paint() method it uses
PlayEnhMetaFile() to expose a picture. Paint() method is used only for EMF
file creation.
1. Paint() - here is a definition how to build a chart/picture. For large
charts each Paint() call costs several seconds. This call is used only for
creating a vectorised EMF file. The flag is set to show that new EMF file
has been created. The file can be a tempfile.
2. Whenever a window is to be painted then EMF file is played on its
surface. It extremely fast and can be used in Resize() event. Windows
function PlayEnhMetaFile() do the job.
4. The window do not need to be inherited from G4VO graphic classes. Paint()
method creates EMF file using gEnhMetaFile class.
5. There is only one point when Paint() method needs to build a new EMF
file. It is when a picture itself must be changed. For example when the user
changes a chart range. It that point, earlier saved flag is set to FALSE and
Paint() method has to be called. The new EMF file will be created.
The described method can be tested without of using G4VO library. To test it
you need have a EMF file and play it on a window, subwindow, or any control
sufrace.
An example for DialogWindows:
METHOD PlayEMF() CLASS W_Dialog
//Put your PostInit additions here
LOCAL hDC, hEMF AS PTR
LOCAL lpRect IS _WINRECT
LOCAL nTBHeight AS INT
IF SELF:Toolbar<>Null_Object
nTBHeight := SELF:ToolBar:Size:Height
ENDIF
hEMF := GetEnhMetaFile( String2Psz( "Example.EMF"))
IF hEMF<>NULL_PTR
hDC := GetDC( SELF:hwnd )
IF hDC<>NULL_PTR
lpRect.Top := SELF:CanvasArea:Height - SELF:CanvasArea:top + nTBHeight
lpRect.Bottom := SELF:CanvasArea:Height - SELF:CanvasArea:Bottom
lpRect.Left := SELF:CanvasArea:left
lpRect.Right := SELF:CanvasArea:Right
PlayEnhMetaFile( hDC, hEMF, @lpRect )
ReleaseDC( SELF:hwnd, hDC )
ENDIF
DeleteEnhMetaFile( hEMF )
ENDIF
RETURN NIL
Put additional calls of the PlayEMF() in Resize() and Expose() methods
I have a test application which shows how to play an EMF file on
DialogWIndow, DataWindow, subwindows and tab pages. The EMF file has been
created with G4VO library. I can send this test application if you need.
At the end I would like to thank for Fred's support and help during several
months of my work. If someone is thinking about integrate graphics with VO,
then Grahpics4VO is a very good choice. I can recommend it and offer my help
in charting, creating / copying vectorised pictures. Thank you Fred!
References:
------------
[1] Graphics4VO
http://www.killetsoft.de/graph32.htm
[2] MetaDraw
http://www.bennet-tec.com/default.htm
[3] How to Create & Play Enhanced Metafiles in Win32
http://support.microsoft.com/default.aspx?scid=kb;en-us;145999
[4] Conversion of Enhanced Metafile to Bitmap and viceversa
http://www.codeproject.com/bitmap/ConvertEMFToBMP.asp?df=100&forumid=24972&s
[5] Clipboard Copy in a Nutshell
http://www.codeproject.com/clipboard/clipnutshell.asp?target=clipboard
[6] All you ever wanted to know about the Clipboard...
http://www.codeproject.com/clipboard/clipboard_faq.asp
[7] Discussion of Metafiles,
http://support.microsoft.com/default.aspx?scid=kb;en-us;81497
Regards,
Marek
SetLineCap()
--------------
My client informed me that when the chart line is very fat, more than 5
pixels, then it can be seen that the chart line consists of rectangles. The
joining point, where the line changes its direction looks bad. Too much
sharpnes, no smooth line. The line is cutted into pieces.
As a first solution I covered this joining points with a filled circles
using a piece of my additional code. I had to compute the size of the circle
which should be fitted with the line width and are compatible with printed
chart view. I had to convert from pixels and device depended size into
points. It was not very elegant. It was only a kind of a workaround.
And again, I asked Fred if he could do something with this. And, he
developed a new method SetLineCap(). In this method I can set how the line
ends are to be showed. It was really excelent and professional solution.
There are the following settings available:
G_LINECAPFLAT - Flat line caps (default)
G_LINECAPROUND - Round line caps
G_LINECAPSQUARE - Square line caps
Reference:
------------
[1] Windows GDI - Pen End Cap
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/pens_87
jk.asp
Regards,
Marek
I've put the sample on my site. If you or someone else would like to get it,
please download it from the the address: www.zgadzaj.hg.pl/VO/EMFTest.zip
Regards,
Marek
________________ De reactie van Fred ______________________________
Wow, I am very much surprised and a little bit proud about this mailing!!!
It is very interesting to get informations about the experience from users
of the graphics library Graphics4VO.
Marek, you developed a marvelous application with graphic surface in VO,
which is inferior in no way professional graphics applications written in
other programming languages. I would like to thank you here for your idea
wealth. Graphics4VO could be substantially improved by your good ideas. I
did the conversion of your ideas to Graphics4VO gladly, even if the time
were sometimes somewhat limited. Your article will be many VO usern a
suggestion to try Graphics4VO first of all as a test version.
Graphics4VO is not alone my development. After I had presented the basic
version some years ago, which contained only graphics primitives at that
time, Geoff Schaller gave me good ideas and examples of the development of
the charts. The common development of the charts crosswise over the globe
(Australia - Germany) made very much fun for us (Wasn't it Geoff?).
Afterwards Michael Rubinstein living in the USA made hisself very much
trouble to translate my German-language function descriptions into English
language. He did it exelently. Fortunately Michael controls both languages
perfectly. He also brought in good ideas for image representation with OLE
functions. COM and OLE are his special fields. Afterwards many improvement
suggestions and extensions of the users came from many countries in the
world. I programmed these to a large extent gradually. The last large
extension was the class gEnhMetaFile, which is to due to Marek Zgadzajs
idea. Marek, we communicated only over approx. 1500 km, but Graphics4VO is a
genuine international, intercontinental development of an efficient team,
which lives over the whole world scattered. Without our newsgroup we would
not have created that.
At last, thank you for the flowers .
Best greatings to all people who helped develoup Graphics4VO and to all who
use it!
Fred