Page 2 of 3

Re: TGRAPH Repopulate

Posted: Thu Jun 26, 2014 8:49 pm
by cnavarro
Very good

Re: TGRAPH Repopulate

Posted: Thu Jun 26, 2014 9:16 pm
by Antonio Linares
What a great masters we have here ;-)

Re: TGRAPH Repopulate

Posted: Fri Jun 27, 2014 8:35 am
by ukoenig
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


// 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: :?:

Re: TGRAPH Repopulate

Posted: Fri Jun 27, 2014 3:54 pm
by ukoenig
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:

Re: TGRAPH Repopulate

Posted: Fri Jun 27, 2014 4:04 pm
by James Bott
I suggest the sample code for redrawing as methods of the TGraph class.

Regards,
James

Re: TGRAPH Repopulate

Posted: Fri Jun 27, 2014 4:08 pm
by ukoenig
James,

all these paintings are included in method :

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

Best regards
Uwe :lol:

Re: TGRAPH Repopulate

Posted: Fri Jun 27, 2014 9:00 pm
by nageswaragunupudi
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

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?

Re: TGRAPH Repopulate

Posted: Sat Jun 28, 2014 12:09 pm
by ukoenig
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:

Re: TGRAPH Repopulate

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

Image

best regards
Uwe :?:

Re: TGRAPH Repopulate

Posted: Sat Jun 28, 2014 10:03 pm
by ukoenig
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


// 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
 

Re: TGRAPH Repopulate

Posted: Sun Jun 29, 2014 5:15 am
by Antonio Linares
Dear Uwe,

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

Thanks so much!

Re: TGRAPH Repopulate

Posted: Sun Jun 29, 2014 1:41 pm
by James Bott
Uwe,

RE: New methods of TGraph

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

James

Re: TGRAPH Repopulate

Posted: Mon Jun 30, 2014 12:21 am
by hag
Very cool. How would you accomplish the same if using resources?

Re: TGRAPH Repopulate

Posted: Mon Jun 30, 2014 6:16 pm
by ukoenig
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:

Re: TGRAPH Repopulate

Posted: Tue Jul 01, 2014 1:29 am
by nageswaragunupudi
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.