FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour TGRAPH Repopulate
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM

Re: TGRAPH Repopulate

Posted: Thu Jun 26, 2014 08:49 PM

Very good

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Re: TGRAPH Repopulate

Posted: Thu Jun 26, 2014 09:16 PM

What a great masters we have here ;-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM

Re: TGRAPH Repopulate

Posted: Fri Jun 27, 2014 08:35 AM
I will create a painter, like I have done for others solution to test
different settings / selections.

Because changing lDegrade to numeric, it is possible, to add more bar-paintings :
0 = NON ( Color )
1 = Gradient horizontal
2 = Gradient vertical

31, 32, 33 = predefined styles ( BORLAND,TILED and BRICKS )
4 = BMP-brush


Another possible change :



Look the difference using the original BMP-structure for background-painting !!!



in Method Paint

Code (fw): Select all Collapse
// add new LOCALS !!!
LOCAL oNewbrush, nRow := 0, nCol := 0, nBmpHeight, nBmpWidth
..
// Back area
//
IF ! Empty( ::cBitmap ) .AND. File( AnsiToOem( Lfn2Sfn( ::cBitmap ) ) )
     // keep the original BMP-structure !!!
     // ------------------------------------------
     DEFINE BITMAP oNewbrush FILENAME ::cBitmap
     nHeight := oNewbrush:nHeight
     nWidth := oNewbrush:nWidth
     IF ::nWidth > 0 
          DO WHILE nRow < ::nHeight
               nCol = 0
               DO WHILE nCol < ::nWidth
                     PalBmpDraw( ::hDC, nRow, nCol, oNewbrush:hBitmap )
                     nCol += nHeight
               ENDDO
               nRow += nWidth
         ENDDO
     ENDIF
     oNewbrush:End()
...
...


Best regards
Uwe :-) :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM

Re: TGRAPH Repopulate

Posted: Fri Jun 27, 2014 03:54 PM
Added Bar-BMP-brushes



IF ::nDegrade = 31 .or. ::nDegrade = 32 .or. ::nDegrade = 33
oBrush := TBrush():New( { "BORLAND", "TILED", "BRICKS" }[ ::nDegrade - 30 ] )
hBru := CreatePatternBrush( oBrush:hBitmap )
FillRect( ::hDC, { nTop, nLeft, nBottom, nRight }, hBru )
ENDIF


It is only a test with ONE Bmp to show, how to display bars with a BMP-brush



IF ::nDegrade = 4
hBmp := ReadBitmap( 0, "Fire.bmp" ) // ::cBitmap is used for the background
oBrush := TBrush():New( ,,,, hBmp )
hBru := CreatePatternBrush( oBrush:hBitmap )
FillRect( ::hDC, { nTop, nLeft, nBottom, nRight }, hBru )
ENDIF


Best regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM

Re: TGRAPH Repopulate

Posted: Fri Jun 27, 2014 04:04 PM

I suggest the sample code for redrawing as methods of the TGraph class.

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM

Re: TGRAPH Repopulate

Posted: Fri Jun 27, 2014 04:08 PM
James,

all these paintings are included in method :

METHOD _FillRect( nTop, nLeft, nBottom, nRight, nColor ) CLASS TGraph

Best regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: TGRAPH Repopulate

Posted: Fri Jun 27, 2014 09:00 PM
Mr Uwe

Thanks for all your suggestions. They are useful for improvement of the class.

May I ask for a few clarifications?

Please see your suggested code:
Code (fw): Select all Collapse
IF ::nDegrade = 1
nMid:=(nRight-nLeft)/2
Gradient( ::hDC, { nTop, nLeft, nBottom, nRight-nMid }, nColor, LightColor(175,nColor), .F. )
Gradient( ::hDC, { nTop, nLeft+nMid, nBottom, nRight }, LightColor(175,nColor), nColor, .F. )
ELSE
hBru = GradientBrush( ::hDC, 0, 0, 0, nTop, { { 0, nColor, LightColor(175,nColor) } }, .T. )
FillRect( ::hDC, { nTop, nLeft, nBottom, nRight }, hBru )   
ENDIF

When nDegrade == 2, you have used GradientBrush but not Gradient function with .t. as the last parameter. Why did you not use Gradient function itself?

Is it necessary to use "File( AnsiToOem( Lfn2Sfn( ::cBitmap ) ) )"? Is "File( ::cBitmap ) not enough?
Regards



G. N. Rao.

Hyderabad, India
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM

Re: TGRAPH Repopulate

Posted: Sat Jun 28, 2014 12:09 PM
Mr. Rao,

I'm working on a extended version of Your sample
It will be possible, to change with the graph-painter the values,
with the dialog-painter the dialog-background.
Because of more than 30 possible graph-values, it might be useful.

Yes not needed ( ! didn't change it )
AnsiToOem( Lfn2Sfn( ::cBitmap ) ) )
I still have to test again the different gradient and brush settings.



Best regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM

Re: TGRAPH Repopulate

Posted: Sat Jun 28, 2014 06:16 PM
I found a gradient-solution ( maybe to complicated ),
better possible, to make the graph-area transparent using the dialog-background.



best regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM

Re: TGRAPH Repopulate

Posted: Sat Jun 28, 2014 10:03 PM
9 possible combinations between dialog- and graph :

// Dialog ( values for function-call )
// --------------------------------------
nDStyle := 2 // 1 = color / 2 = Gradient / 3 = Brush / 4 = Image
nDColorF := 16765559
nDColorB := LightColor( 175, nDColorF )
nDTxtColor := 255
nDGradpos := 0
LDDirect := .T.
cDBrush := "Marble.bmp"
cDImage := "Picture3.jpg"

// Graph adjusted to dialog background
// -------------------------------------------
oGraph:nType := 1
oGraph:nMaxVal := 2000
oGraph:nClrBack := 16765559 // Background color
oGraph:l3D := .T.
oGraph:nDegrade := 2 // 0 = Color / 1 = Grad Horiz. / 2 = Grad vert.

Select one of the background-styles
//oGraph:cBitmap := "Color" // Dialog nDStyle = 1
//oGraph:cBitmap := "Gradient" // Dialog nDStyle = 2
//oGraph:cBitmap := "Marble.bmp" // Dialog nDStyle = 3

Color

// Dialog
// ----------
nDStyle := 1

// Graph
// ----------
oGraph:nDegrade := 0 // 0 = Color / 1 = Grad Horiz. / 2 = Grad vert.
oGraph:cBitmap := "Color"



Brush

// Dialog
// ----------
nDStyle := 3

// Graph
// ----------
oGraph:nDegrade := 0 // 0 = Color / 1 = Grad Horiz. / 2 = Grad vert.
oGraph:cBitmap := "Marble.bmp"



Gradient
Still have to check the graph-gradient-height !!!

// Dialog
// ----------
nDStyle := 2

// Graph
// ----------
oGraph:nDegrade := 0 // 0 = Color / 1 = Grad Horiz. / 2 = Grad vert.
oGraph:cBitmap := "Gradient"



Style change


The first graph-background-tests :

Code (fw): Select all Collapse
// Back area
//
IF ! Empty( ::cBitmap )  .OR. ( Empty( ::oPrn ) .AND. ::nType != GRAPH_TYPE_PIE )
     IF UPPER ( ::cBitmap ) = "COLOR"
          //MsgAlert( "Color" )
          hBru := CreateSolidBrush( ::nClrBack )
          hOld := SelectObject( ::hDC, hBru )
          FillRect( ::hDC, { 0, 0, ::nHeight, ::nWidth }, hBru )
          SelectObject( ::hDC, hOld )
          DeleteObject( hBru )
     ELSEIF UPPER ( ::cBitmap ) = "GRADIENT"
          //MsgAlert( "Gradient" )
          hBru := GradientBrush( ::hDC, 0, 0, ::nHeight, ::nWidth, ; 
          { { 0, LightColor( 175, ::nClrBack ), ::nClrBack } }, .T. )
          hOld := SelectObject( ::hDC, hBru )
          FillRect( ::hDC,{ 0, 0, ::nHeight, ::nWidth }, hBru )
          SelectObject( ::hDC, hOld )
          DeleteObject( hBru )
     ELSEIF File( ::cBitmap )
          DEFINE BITMAP oNewbrush FILENAME ::cBitmap
          nHeight := oNewbrush:nHeight
          nWidth := oNewbrush:nWidth
          IF ::nWidth > 0 
               DO WHILE nRow < ::nHeight
                    nCol = 0
                    DO WHILE nCol < ::nWidth
                          PalBmpDraw( ::hDC, nRow, nCol, oNewbrush:hBitmap )
                          nCol += nHeight
                   ENDDO
                   nRow += nWidth
              ENDDO
        ENDIF
        oNewbrush:End()
    ENDIF
ENDIF
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Re: TGRAPH Repopulate

Posted: Sun Jun 29, 2014 05:15 AM

Dear Uwe,

You are our Graphics master, no doubt about it :-)

Thanks so much!

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM

Re: TGRAPH Repopulate

Posted: Sun Jun 29, 2014 01:41 PM

Uwe,

RE: New methods of TGraph

I was mainly referring to adding methods to clear existing data, so new data could be added.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 598
Joined: Tue Apr 15, 2008 04:51 PM

Re: TGRAPH Repopulate

Posted: Mon Jun 30, 2014 12:21 AM

Very cool. How would you accomplish the same if using resources?

Thank you

Harvey
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM

Re: TGRAPH Repopulate

Posted: Mon Jun 30, 2014 06:16 PM
Harvey,

there is still a lot to do.
Because of over 40 possible settings,
I'm working on a painter, to change and test everything at runtime.
There is a project-file, to save all values.









Best regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: TGRAPH Repopulate

Posted: Tue Jul 01, 2014 01:29 AM
hag wrote:Very cool. How would you accomplish the same if using resources?

Same logic, except that you replace @ r, c syntax with REDEFINE syntax. For samples of rc files for TGraph, please see testfldg.rc and testdisk1.rc in the samples folder.

For better understanding of the class there are some good samples posted by the author of the class in the samples folder.
Regards



G. N. Rao.

Hyderabad, India