TGRAPH Repopulate

User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: TGRAPH Repopulate

Post by cnavarro »

Very good
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: TGRAPH Repopulate

Post by Antonio Linares »

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

Antonio Linares
www.fivetechsoft.com
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: TGRAPH Repopulate

Post 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

// 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: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: TGRAPH Repopulate

Post 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:
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
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: TGRAPH Repopulate

Post by James Bott »

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

Regards,
James
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: TGRAPH Repopulate

Post by ukoenig »

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
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: TGRAPH Repopulate

Post 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

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
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: TGRAPH Repopulate

Post 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:
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: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: TGRAPH Repopulate

Post 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 :?:
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: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: TGRAPH Repopulate

Post 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

// 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
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: TGRAPH Repopulate

Post by Antonio Linares »

Dear Uwe,

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

Thanks so much!
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: TGRAPH Repopulate

Post 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
hag
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California
Contact:

Re: TGRAPH Repopulate

Post by hag »

Very cool. How would you accomplish the same if using resources?
Thank you
Harvey
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: TGRAPH Repopulate

Post 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:
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
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: TGRAPH Repopulate

Post 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.
Regards

G. N. Rao.
Hyderabad, India
Post Reply