TGRAPH Repopulate

Re: TGRAPH Repopulate

Postby cnavarro » Thu Jun 26, 2014 8: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
User avatar
cnavarro
 
Posts: 6552
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: TGRAPH Repopulate

Postby Antonio Linares » Thu Jun 26, 2014 9:16 pm

What a great masters we have here ;-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: TGRAPH Repopulate

Postby ukoenig » Fri Jun 27, 2014 8: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 :

Image

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

Image

in Method Paint

Code: Select all  Expand view  RUN

// 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 :lol: :?:
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: TGRAPH Repopulate

Postby ukoenig » Fri Jun 27, 2014 3:54 pm

Added Bar-BMP-brushes

Image

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

Image

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 :lol:
Last edited by ukoenig on Sat Jun 28, 2014 12:08 pm, edited 3 times in total.
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: TGRAPH Repopulate

Postby James Bott » Fri Jun 27, 2014 4:04 pm

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

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: TGRAPH Repopulate

Postby ukoenig » Fri Jun 27, 2014 4:08 pm

James,

all these paintings are included in method :

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

Best regards
Uwe :lol:
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: TGRAPH Repopulate

Postby nageswaragunupudi » Fri Jun 27, 2014 9: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: Select all  Expand view  RUN
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
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: TGRAPH Repopulate

Postby ukoenig » 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.

Image

Best regards
Uwe :lol:
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: TGRAPH Repopulate

Postby ukoenig » Sat Jun 28, 2014 6:16 pm

I found a gradient-solution ( maybe to complicated ),
better possible, to make the graph-area transparent using the dialog-background.

Image

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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: TGRAPH Repopulate

Postby ukoenig » 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"

Image

Brush

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

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

Image

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"

Image

Style change
Image

The first graph-background-tests :

Code: Select all  Expand view  RUN

// 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
 
Last edited by ukoenig on Mon Jun 30, 2014 6:13 pm, edited 1 time in total.
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: TGRAPH Repopulate

Postby Antonio Linares » Sun Jun 29, 2014 5:15 am

Dear Uwe,

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

Thanks so much!
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: TGRAPH Repopulate

Postby James Bott » Sun Jun 29, 2014 1: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: TGRAPH Repopulate

Postby hag » Mon Jun 30, 2014 12:21 am

Very cool. How would you accomplish the same if using resources?
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California

Re: TGRAPH Repopulate

Postby ukoenig » Mon Jun 30, 2014 6: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.

Image

Image

Image

Image

Best regards
Uwe :lol:
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: TGRAPH Repopulate

Postby nageswaragunupudi » Tue Jul 01, 2014 1: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
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 19 guests