Re: [ROOT] Strange histogram drawing (painting) behaviour for inherited class

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed May 05 2004 - 14:57:08 MEST


Hi Eric,

This problem with the TH1 default constructor is now protected in the CVS
version.
In your case a possible workaround is to do
  CInheritTH2 ih;
  ih.UseCurrentStyle();

Rene Brun

"ANCIANT E." wrote:
> 
> Hello rooters,
> I am using root 3.10.02 + GDK on Microsoft Visual C++ 6
> 
> I have a class that inherits from TH2D, when I try to draw it using
> "lego" option, instead of getting full lego-bars, I got thin lego
> (sometimes "lines", sometimes nothings it depends of the order of call
> of the various options)  (see attached c1.ps )
> 
> If I draw it using "box" option I obtain and empty histogram display.
> (although using the Event Status Option one can verify that bins are not
> empty)
> 
> I haven't managed to find out what initialisation of histogram I am
> missing to have them be drawn correctly with "box" and "lego" ,
> apparently  TH2D::TH2D() + TH2::TH2() + TH1():TH1() + SetBins(...) don't
> make it...
> 
> eric
> 
> ----------FILE CInheritTH2.h :
> 
> #ifndef CINHERIT_H
> #define CINHERIT_H
> 
> #include "TH2.h"
> 
> #ifdef __CINT__
> class CInheritTH2 : public TH2D {
> #else
> class __declspec(dllexport) CInheritTH2 : public TH2D {
> #endif
> 
>         //
> public :
> 
>         ClassDef(CInheritTH2,0)
> 
> };
> 
> #endif
> 
> -----------FILE CInheritTH2.cpp :
> 
> #include "CInheritTH2.h"
> 
> ClassImp(CInheritTH2)
> 
> --------
> dictionary was generated without major problem :
> 
> --------------------Configuration: InheritTH2 - Win32
> Debug--------------------
> Building Root dictionnary
> Compiling...
> Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for
> 80x86
> Copyright (C) Microsoft Corp 1984-1998. All rights reserved.
> cl /G5 /MTd /W3 /GR /GX /ZI /Od /I "../InheritTH2" /D
> "INHERITTH2_EXPORTS" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D
> "VISUAL_CPLUSPLUS" /D _X86_=1 /D "_DLL" /Fo"Debug/" /Fd"Debug/" /FD /GZ
> /c
>    "P:\ Simu\InheritTH2\InheritTH2Dict.cxx"
>    "P:\ Simu\InheritTH2\CInheritTH2.cpp"
> InheritTH2Dict.cxx
> p:\simu\inheritth2\cinheritth2.h(9) : warning C4275: non dll-interface
> class 'TH2D' used as base for dll-interface class 'CInheritTH2'
>         p:\root_v3.10.02.win32gdk_debug\include\th2.h(265) : see
> declaration of 'TH2D'
> CInheritTH2.cpp
> p:\simu\inheritth2\cinheritth2.h(9) : warning C4275: non dll-interface
> class 'TH2D' used as base for dll-interface class 'CInheritTH2'
>         p:\root_v3.10.02.win32gdk_debug\include\th2.h(265) : see
> declaration of 'TH2D'
> Generating Code...
> Linking...
> Microsoft (R) Incremental Linker Version 6.00.8447
> Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
> kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib
> shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
> msvcrt.lib p:\root_v3.10.02.win32gdk_Debug\lib\*.lib /dll /pdb:none
> /debug /debugtype:both /machine:I386 "/o
> ut:../Debug/InheritTH2.dll" "/implib:../Debug/InheritTH2.lib"
> /subsystem:console,4.0
> .\Debug\InheritTH2Dict.obj
> .\Debug\CInheritTH2.obj
>    Creating library ../Debug/InheritTH2.lib and object
> ../Debug/InheritTH2.exp
> LINK : warning LNK4098: defaultlib "LIBCMTD" conflicts with use of other
> libs; use /NODEFAULTLIB:library
> 
> InheritTH2.dll - 0 error(s), 3 warning(s)
> 
> -----------Now if I use the class from CiNT :
> 
>   *******************************************
>   *                                         *
>   *        W E L C O M E  to  R O O T       *
>   *                                         *
>   *   Version   3.10/02  17 December 2003   *
>   *                                         *
>   *  You are welcome to visit our Web site  *
>   *          http://root.cern.ch            *
>   *                                         *
>   *******************************************
> 
> Compiled for win32gdk.
> 
> CINT/ROOT C/C++ Interpreter version 5.15.115, Dec 9 2003
> Type ? for help. Commands must be C++ statements.
> Enclose multiple statements between { }.
> root [0] gSystem->Load("p:/simu/debug/InheritTH2.dll")
> (int)0
> root [1] CInheritTH2 ih
> root [2] ih.SetBins(10,0,10,10,0,10)
> root [4] ih.Fill(5,5)
> (Int_t)78
> root [6] ih.Draw("lego")
> <TCanvas::MakeDefCanvas>: created default TCanvas with name c1
> root [7]
> 
> I obtained the strange attached display
> 
> ********
> Ce message et eventuellement les pieces jointes sont exclusivement transmis a l'usage de leur destinataire. Leur contenu est strictement confidentiel. Si vous n etes pas le bon destinataire nous vous demandons de ne pas conserver, copier, utiliser ou divulguer cette communication. Merci de le detruire et de me notifier cette erreur.
> 
> INTERNET ne permettant pas d assurer l integrite de ce message, SODERN decline toute responsabilite au cas ou il aurait ete intercepte ou modifie.
> 
> This message and possibly attachments are transmit for the exclusive use of their address. Their content is strictly confidential. If you are not the intended recipient please do not keep, copy, use or disclose this communication to others. Also please delete it and notify the sender at once.
> 
> Because of the nature of INTERNET the sender is not in a position to ensure the integrity of this message, therefore SODERN disclaims any liability whatoever in the event of this message having been intercepted and/or altered.
> 
>   --------------------------------------------------------------------------------
>                Name: c1.ps
>    c1.ps       Type: Postscript Document (application/postscript)
>            Encoding: base64
>         Description: c1.ps



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:07 MET