tgraph problem end oDlg and print

Re: tgraph problem end oDlg and print

Postby nageswaragunupudi » Sun Jun 13, 2010 1:16 pm

I think window is to be activated after creating the Graph control.
Window can be activated in hidden mode. ACTIVATE WINDOW HIDDEN. I don't know if this helps.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10628
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: tgraph problem end oDlg and print

Postby James Bott » Sun Jun 13, 2010 2:29 pm

Reinaldo,

OK, here is a crude working example. The acual pies are not showing but that is probably due to my made-up numbers.

James



Code: Select all  Expand view
#include "fivewin.ch"
#include "tgraph.ch"


function main()
   local oWnd
   define window oWnd title "Graph printing test"
   activate window oWnd on init doIt()
return nil


function doIt()
   local oWnd
   define window oWnd
   activate window oWnd on init doPie(oWnd)
return nil


function doPie(oWnd)
   local oPie
   local a:={},b:={}
   local nWidth:=500, nHeight:=500

   oWnd:hide()

   aadd(a,1)
   aadd(a,1)
   aadd(b,20)
   aadd(b,20)

    oPie :=  TGraph():New( 0, 0, oWnd,  nWidth, nHeight, .f., .t.  )

    with object oPie
        :cTitle     := "Malignancy % Found On Sample"
        :cSubTit    := alltrim( "Specimen" )
        :AddSerie( { 14 },"Cancer %", RGB( 50, 50,200), GRAPH_TYPE_PIE, .t. )
        :AddSerie( { 100.00 - 14 },"Non-Cancer", CLR_BLUE, GRAPH_TYPE_PIE, .t. )
    end

    PrintGraph( oPie, a[ 1 ], a[ 2 ], b[ 2 ] - a[ 2 ], b[ 1 ] - a[ 1 ] )

    oPie:end()
    oWnd:end()

return nil


FUNCTION PrintGraph(oGraph, nTop, nLeft, nWidth, nHeight)
   LOCAL oPrn
   PRINT oPrn NAME "Impresión de gráficos" //PREVIEW
      oPrn:Cmtr2Pix(@nTop  , @nLeft)
      oPrn:Cmtr2Pix(@nWidth, @nHeight)
      PAGE
         oGraph:Print( oPrn, nTop, nLeft, nWidth, nHeight )
      ENDPAGE
   ENDPRINT
RETURN (NIL)

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

Re: tgraph problem end oDlg and print

Postby reinaldocrespo » Mon Jun 14, 2010 9:24 pm

James and Neogs;

Thank you for your replies. I'm sorry I was off-line over the weekend. I found a way to solve the problem. Actually I'm creating and displaying the window, but for some reason, it doesn't show. Maybe the coordinates are so small, it shows but it is invisible, or maybe the procedure runs so fast, that it creates and :end()'s the window before it can be catch by the eye... Bottom line is that the window doesn't display and I'm not sure why. But it works.

You can see the output here:
http://ssfl.dynalias.com/utilities/Printing_transcription.pdf

And, here is the code:
Code: Select all  Expand view
*--------------------------------------------------------------------------------------------------------------------------
METHOD PrintPieCharts() Class PathologyTranscription
local oPie
local oWnd
local a, b
local n := 1
local nLastLine := ::nLastLine - 1
local nWidthInInchs, nhrzFctr, nVrtFctr

    DEFINE WINDOW oWnd FROM 0,0 to 1, 2
    ACTIVATE WINDOW oWnd

    ::oSpcs:Seek( ::odbf:PathNo )

    nhrzFctr := GetSysMetrics( 0 ) / GetDeviceCaps( ::oPrn:hDC, HORZRES )
    nVrtFctr := GetSysMetrics( 1 ) / GetDeviceCaps( ::oPrn:hDC, VERTRES )
   
    While !::oSpcs:eof() .and. ::oSpcs:PathNo == ::odbf:PathNo

        if ::oSpcs:Cancrprcnt > 0.00

            nLastLine += 2.00
           
            nWidthInInchs := Min( ::aColumnsCoords[ ::nCurrCol, 2 ] - ::aColumnsCoords[ ::nCurrCol, 1 ], 2 ) + 1
           
            a := ::oprn:Inch2Pix( nLastLine, ::aColumnsCoords[ ::nCurrCol, 1 ] +1.25)
            b := ::oPrn:Inch2Pix( nLastLine + 1.5, nWidthInInchs + 0.5)
           
            oPie :=  TGraph():New( a[ 1 ] * nVrtFctr, a[ 2 ] * nhrzFctr, oWnd,  ;
                b[ 2 ] * nHrzFctr , b[ 2 ] * nVrtFctr )
               
            With Object oPie
                :lPopUp     := .f.
                :nType      := GRAPH_TYPE_PIE
                :l3D        := .T.
                :lLegends   := .f.
                :lViewVal   := .f.
                :lBorders   := .t.
                :AddSerie( { ::oSpcs:Cancrprcnt },"Cancer %", RGB( 50, 50,200), GRAPH_TYPE_PIE, .t. )
                :AddSerie( { 100.00 - ::oSpcs:Cancrprcnt },"Non-Cancer", CLR_WHITE, GRAPH_TYPE_PIE, .t. )
            End With

            oPie:Print( ::oPrn, a[ 1 ], a[ 2 ], 0.00, 0.00 )
            oPie:End()

            a := ::oPrn:Inch2Pix( nLastLine - 1, ::aColumnsCoords[ ::nCurrCol, 1 ] )
            b := ::oPrn:Inch2Pix( ::aColumnsCoords[ ::nCurrCol, 2 ], nLastLine - 1 )
                       
            ::PrintSectionHdr( a, b,, Str( n, 2 ) + ")" + ;
                ProperName( Alltrim( ::oSpcs:Specimen ) ), ::aFonts[ 13 ] )
                   
            ::oPrn:InchSay( nLastLine + 0.25, ::aColumnsCoords[ ::nCurrCol, 1 ] + 0.25, ;
                    "Malignancy " + Transform( ::oSpcs:Cancrprcnt, "999.99%" ) + ;
                    iif( ::oSpcs:gleason_1 + ::oSpcs:gleason_2 > 0, ;
                        " Gleason Score: " + Str( ::oSpcs:Gleason_1 + ::oSpcs:Gleason_2, 2 ) +;
                        " (" + Str( ::oSpcs:Gleason_1 ) + "-" + Str( ::oSpcs:Gleason_2 ) + ") ", "" ), ;
                    ::aFonts[ 1 ] )

            ::nMaxLineOnPage := Max( ::nMaxLineOnPage, nLastLine )  //used for placement of signature
           
            if nLastLine + 1.5 > ::nbottom
                nLastLine := ::nTop - 1
                ::nCurrCol++
               
                if ::nCurrCol > ::nMaxCols
                    ::nCurrCol := 1
                    ::PrintFooter()
                    ::oPrn:EndPage()
                    ::oPrn:StartPage()
                endif
               
            endif

        End
       
        n++
        ::oSpcs:Skip()
    End

    if nLastLine == ::nLastLine - 1
        ::nLastLine := ::nTop
    else
        ::nLastLine := nLastLine + 1    //units is in inches
    endif
   
    oWnd:End()
       
return Nil
 


Any ideas to further enhance the output report are always welcome.

Regards,


Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: tgraph problem end oDlg and print

Postby James Bott » Tue Jun 15, 2010 3:27 pm

Small coordinates...good idea. Glad you got it working.

The report looks very professional.

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

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

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