46 TCanvasInit() { TApplication::NeedGraphicsLibs(); }
48 static TCanvasInit gCanvasInit;
53 Bool_t TCanvas::fgIsFolder = kFALSE;
55 const Size_t kDefaultCanvasSize = 20;
122 TCanvas::TCanvas(Bool_t build) : TPad(), fDoubleBuffer(0)
133 fXsizeReal = kDefaultCanvasSize;
134 fYsizeReal = kDefaultCanvasSize;
135 fHighLightColor = gEnv->GetValue(
"Canvas.HighLightColor", kRed);
146 fClickSelectedPad = 0;
151 fUseGL = gStyle->GetCanvasPreferGL();
153 if (!build || TClass::IsCallingNew() != TClass::kRealNew) {
156 const char *defcanvas = gROOT->GetDefCanvasName();
159 auto lc = (TList*)gROOT->GetListOfCanvases();
160 if (lc->FindObject(defcanvas)) {
161 Int_t n = lc->GetSize()+1;
162 while (lc->FindObject(Form(
"%s_n%d",defcanvas,n))) n++;
163 cdef = StrDup(Form(
"%s_n%d",defcanvas,n));
165 cdef = StrDup(Form(
"%s",defcanvas));
167 Constructor(cdef, cdef, 1);
175 void TCanvas::Constructor()
180 if ((*gThreadXAR)(
"CANV", 2, arr, 0))
return;
193 fClickSelectedPad = 0;
197 SetBit(kShowToolBar);
207 TCanvas::TCanvas(
const char *name, Int_t ww, Int_t wh, Int_t winid) : TPad(), fDoubleBuffer(0)
225 fUseGL = gStyle->GetCanvasPreferGL();
228 fGLDevice = gGLManager->CreateGLContext(winid);
233 fCanvasImp = gBatchGuiFactory->CreateCanvasImp(
this, name, fCw, fCh);
234 if (!fCanvasImp)
return;
253 TCanvas::TCanvas(
const char *name,
const char *title, Int_t form) : TPad(), fDoubleBuffer(0)
256 fUseGL = gStyle->GetCanvasPreferGL();
258 Constructor(name, title, form);
271 void TCanvas::Constructor(
const char *name,
const char *title, Int_t form)
275 static Int_t ww = 500;
276 static Int_t wh = 500;
277 arr[1] =
this; arr[2] = (
void*)name; arr[3] = (
void*)title; arr[4] =&ww; arr[5] = &wh;
278 if ((*gThreadXAR)(
"CANV", 6, arr, 0))
return;
291 TCanvas *old = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(name);
292 if (old && old->IsOnHeap()) {
293 Warning(
"Constructor",
"Deleting canvas with same name: %s",name);
296 if (gROOT->IsBatch()) {
297 fWindowTopX = fWindowTopY = 0;
299 fWindowWidth = gStyle->GetCanvasDefW();
300 fWindowHeight = gStyle->GetCanvasDefH();
307 fCanvasImp = gBatchGuiFactory->CreateCanvasImp(
this, name, fCw, fCh);
308 if (!fCanvasImp)
return;
311 Float_t cx = gStyle->GetScreenFactor();
312 if (form < 1 || form > 5) form = 1;
314 UInt_t uh = UInt_t(cx*gStyle->GetCanvasDefH());
315 UInt_t uw = UInt_t(cx*gStyle->GetCanvasDefW());
316 Int_t ux = Int_t(cx*gStyle->GetCanvasDefX());
317 Int_t uy = Int_t(cx*gStyle->GetCanvasDefY());
318 fCanvasImp = gGuiFactory->CreateCanvasImp(
this, name, ux, uy, uw, uh);
322 if (form == 2) fCanvasImp = gGuiFactory->CreateCanvasImp(
this, name, 20, 20, UInt_t(cx*500), UInt_t(cx*500));
323 if (form == 3) fCanvasImp = gGuiFactory->CreateCanvasImp(
this, name, 30, 30, UInt_t(cx*500), UInt_t(cx*500));
324 if (form == 4) fCanvasImp = gGuiFactory->CreateCanvasImp(
this, name, 40, 40, UInt_t(cx*500), UInt_t(cx*500));
325 if (form == 5) fCanvasImp = gGuiFactory->CreateCanvasImp(
this, name, 50, 50, UInt_t(cx*500), UInt_t(cx*500));
326 if (!fCanvasImp)
return;
328 if (!gROOT->IsBatch() && fCanvasID == -1)
329 fCanvasID = fCanvasImp->InitWindow();
331 fCanvasImp->ShowMenuBar(TestBit(kMenuBar));
356 TCanvas::TCanvas(
const char *name,
const char *title, Int_t ww, Int_t wh) : TPad(), fDoubleBuffer(0)
359 fUseGL = gStyle->GetCanvasPreferGL();
361 Constructor(name, title, ww, wh);
373 void TCanvas::Constructor(
const char *name,
const char *title, Int_t ww, Int_t wh)
377 arr[1] =
this; arr[2] = (
void*)name; arr[3] = (
void*)title; arr[4] =&ww; arr[5] = &wh;
378 if ((*gThreadXAR)(
"CANV", 6, arr, 0))
return;
390 TCanvas *old = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(name);
391 if (old && old->IsOnHeap()) {
392 Warning(
"Constructor",
"Deleting canvas with same name: %s",name);
395 if (gROOT->IsBatch()) {
396 fWindowTopX = fWindowTopY = 0;
401 fCanvasImp = gBatchGuiFactory->CreateCanvasImp(
this, name, fCw, fCh);
402 if (!fCanvasImp)
return;
405 Float_t cx = gStyle->GetScreenFactor();
406 fCanvasImp = gGuiFactory->CreateCanvasImp(
this, name, UInt_t(cx*ww), UInt_t(cx*wh));
407 if (!fCanvasImp)
return;
409 if (!gROOT->IsBatch() && fCanvasID == -1)
410 fCanvasID = fCanvasImp->InitWindow();
412 fCanvasImp->ShowMenuBar(TestBit(kMenuBar));
438 TCanvas::TCanvas(
const char *name,
const char *title, Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh)
439 : TPad(), fDoubleBuffer(0)
442 fUseGL = gStyle->GetCanvasPreferGL();
444 Constructor(name, title, wtopx, wtopy, ww, wh);
457 void TCanvas::Constructor(
const char *name,
const char *title, Int_t wtopx,
458 Int_t wtopy, Int_t ww, Int_t wh)
462 arr[1] =
this; arr[2] = (
void*)name; arr[3] = (
void*)title;
463 arr[4] = &wtopx; arr[5] = &wtopy; arr[6] = &ww; arr[7] = &wh;
464 if ((*gThreadXAR)(
"CANV", 8, arr, 0))
return;
476 TCanvas *old = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(name);
477 if (old && old->IsOnHeap()) {
478 Warning(
"Constructor",
"Deleting canvas with same name: %s",name);
481 if (gROOT->IsBatch()) {
482 fWindowTopX = fWindowTopY = 0;
487 fCanvasImp = gBatchGuiFactory->CreateCanvasImp(
this, name, fCw, fCh);
488 if (!fCanvasImp)
return;
491 Float_t cx = gStyle->GetScreenFactor();
492 fCanvasImp = gGuiFactory->CreateCanvasImp(
this, name, Int_t(cx*wtopx), Int_t(cx*wtopy), UInt_t(cx*ww), UInt_t(cx*wh));
493 if (!fCanvasImp)
return;
495 if (!gROOT->IsBatch() && fCanvasID == -1)
496 fCanvasID = fCanvasImp->InitWindow();
498 fCanvasImp->ShowMenuBar(TestBit(kMenuBar));
520 TApplication::CreateApplication();
526 gApplication->InitializeGraphics();
529 fHighLightColor = gEnv->GetValue(
"Canvas.HighLightColor", kRed);
530 SetBit(kMoveOpaque, gEnv->GetValue(
"Canvas.MoveOpaque", 0));
531 SetBit(kResizeOpaque, gEnv->GetValue(
"Canvas.ResizeOpaque", 0));
532 if (gEnv->GetValue(
"Canvas.ShowEventStatus", kFALSE)) SetBit(kShowEventStatus);
533 if (gEnv->GetValue(
"Canvas.ShowToolTips", kFALSE)) SetBit(kShowToolTips);
534 if (gEnv->GetValue(
"Canvas.ShowToolBar", kFALSE)) SetBit(kShowToolBar);
535 if (gEnv->GetValue(
"Canvas.ShowEditor", kFALSE)) SetBit(kShowEditor);
536 if (gEnv->GetValue(
"Canvas.AutoExec", kTRUE)) SetBit(kAutoExec);
541 fXsizeReal = kDefaultCanvasSize;
542 fYsizeReal = kDefaultCanvasSize;
544 fDISPLAY =
"$DISPLAY";
552 fClickSelectedPad= 0;
564 void TCanvas::Build()
567 if (fCanvasID == -1 && fCanvasImp)
568 fCanvasID = fCanvasImp->InitWindow();
569 if (fCanvasID == -1)
return;
571 if (fCw !=0 && fCh !=0) {
572 if (fCw < fCh) fXsizeReal = fYsizeReal*Float_t(fCw)/Float_t(fCh);
573 else fYsizeReal = fXsizeReal*Float_t(fCh)/Float_t(fCw);
579 fMother = (TPad*)gPad;
585 }
else if (IsWeb()) {
592 gVirtualX->SelectWindow(fCanvasID);
593 gVirtualX->SetFillColor(1);
594 gVirtualX->SetLineColor(1);
595 gVirtualX->SetMarkerColor(1);
596 gVirtualX->SetTextColor(1);
598 gVirtualX->ClearWindow();
604 fCanvasImp->GetWindowGeometry(fWindowTopX, fWindowTopY,
605 fWindowWidth, fWindowHeight);
609 gVirtualX->GetGeometry(fCanvasID, dum1, dum2, fCw, fCh);
611 fContextMenu =
new TContextMenu(
"ContextMenu");
614 gROOT->GetListOfCanvases()->Add(
this);
617 fPrimitives =
new TList;
618 SetFillColor(gStyle->GetCanvasColor());
620 SetGrid(gStyle->GetPadGridX(),gStyle->GetPadGridY());
621 SetTicks(gStyle->GetPadTickX(),gStyle->GetPadTickY());
622 SetLogx(gStyle->GetOptLogx());
623 SetLogy(gStyle->GetOptLogy());
624 SetLogz(gStyle->GetOptLogz());
625 SetBottomMargin(gStyle->GetPadBottomMargin());
626 SetTopMargin(gStyle->GetPadTopMargin());
627 SetLeftMargin(gStyle->GetPadLeftMargin());
628 SetRightMargin(gStyle->GetPadRightMargin());
629 SetBorderSize(gStyle->GetCanvasBorderSize());
630 SetBorderMode(gStyle->GetCanvasBorderMode());
631 fBorderMode=gStyle->GetCanvasBorderMode();
635 TVirtualPadPainter *vpp = GetCanvasPainter();
636 if (vpp) vpp->SelectDrawable(fPixmapID);
637 PaintBorder(GetFillColor(), kTRUE);
642 if (TestBit(kMenuBar) && fCanvasImp) {
643 if (TestBit(kShowEventStatus)) fCanvasImp->ShowStatusBar(kTRUE);
645 if (TestBit(kShowToolBar)) fCanvasImp->ShowToolBar(kTRUE);
646 if (TestBit(kShowEditor)) fCanvasImp->ShowEditor(kTRUE);
647 if (TestBit(kShowToolTips)) fCanvasImp->ShowToolTips(kTRUE);
662 void TCanvas::Browse(TBrowser *b)
666 if (fgIsFolder) fPrimitives->Browse(b);
672 void TCanvas::Destructor()
677 if ((*gThreadXAR)(
"CDEL", 2, arr, 0))
return;
680 if (!TestBit(kNotDeleted))
return;
682 if (fContextMenu) {
delete fContextMenu; fContextMenu = 0; }
696 TVirtualPad *TCanvas::cd(Int_t subpadnumber)
698 if (fCanvasID == -1)
return 0;
700 TPad::cd(subpadnumber);
705 gVirtualX->SelectWindow(fCanvasID);
715 void TCanvas::Clear(Option_t *option)
717 if (fCanvasID == -1)
return;
719 R__LOCKGUARD(gROOTMutex);
721 TString opt = option;
723 if (opt.Contains(
"d")) {
728 TIter next(fPrimitives);
730 while ((obj=next())) {
742 fClickSelectedPad = 0;
748 void TCanvas::Cleared(TVirtualPad *pad)
750 Emit(
"Cleared(TVirtualPad*)", (Long_t)pad);
756 void TCanvas::Closed()
766 void TCanvas::Close(Option_t *option)
768 TPad *padsave = (TPad*)gPad;
769 TCanvas *cansave = 0;
770 if (padsave) cansave = (TCanvas*)gPad->GetCanvas();
772 if (fCanvasID != -1) {
774 if ((!gROOT->IsLineProcessing()) && (!gVirtualX->IsCmdThread())) {
775 gInterpreter->Execute(
this, IsA(),
"Close", option);
779 R__LOCKGUARD(gROOTMutex);
781 FeedbackMode(kFALSE);
787 gVirtualX->SelectWindow(fCanvasID);
789 DeleteCanvasPainter();
797 gROOT->GetListOfCanvases()->Remove(
this);
800 SafeDelete(fCanvasImp);
803 if (cansave ==
this) {
804 gPad = (TCanvas *) gROOT->GetListOfCanvases()->First();
815 void TCanvas::CopyPixmaps()
833 void TCanvas::Draw(Option_t *)
839 gApplication->InitializeGraphics();
843 TCanvas *old = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(GetName());
848 if (old) { gROOT->GetListOfCanvases()->Remove(old);
delete old;}
850 if (fWindowWidth == 0) {
851 if (fCw !=0) fWindowWidth = fCw+4;
852 else fWindowWidth = 800;
854 if (fWindowHeight == 0) {
855 if (fCh !=0) fWindowHeight = fCh+28;
856 else fWindowHeight = 600;
858 if (gROOT->IsBatch()) {
859 fCanvasImp = gBatchGuiFactory->CreateCanvasImp(
this, GetName(), fWindowWidth, fWindowHeight);
860 if (!fCanvasImp)
return;
864 fCanvasImp = gGuiFactory->CreateCanvasImp(
this, GetName(), fWindowTopX, fWindowTopY,
865 fWindowWidth, fWindowHeight);
866 if (!fCanvasImp)
return;
867 fCanvasImp->ShowMenuBar(TestBit(kMenuBar));
871 fCanvasImp->SetWindowTitle(fTitle);
880 TObject *TCanvas::DrawClone(Option_t *option)
const
882 TCanvas *newCanvas = (TCanvas*)Clone();
883 newCanvas->SetName();
885 newCanvas->Draw(option);
897 TObject *TCanvas::DrawClonePad()
899 TPad *padsav = (TPad*)gPad;
900 TPad *selpad = (TPad*)gROOT->GetSelectedPad();
902 if (pad ==
this) pad = selpad;
903 if (padsav == 0 || pad == 0 || pad ==
this) {
904 TCanvas *newCanvas = (TCanvas*)DrawClone();
905 newCanvas->SetWindowSize(GetWindowWidth(),GetWindowHeight());
908 if (fCanvasID == -1) {
909 fCanvasImp = gGuiFactory->CreateCanvasImp(
this, GetName(), fWindowTopX, fWindowTopY,
910 fWindowWidth, fWindowHeight);
911 if (!fCanvasImp)
return 0;
912 fCanvasImp->ShowMenuBar(TestBit(kMenuBar));
913 fCanvasID = fCanvasImp->InitWindow();
916 TObject *obj, *clone;
918 pad->Range(fX1,fY1,fX2,fY2);
919 pad->SetTickx(GetTickx());
920 pad->SetTicky(GetTicky());
921 pad->SetGridx(GetGridx());
922 pad->SetGridy(GetGridy());
923 pad->SetLogx(GetLogx());
924 pad->SetLogy(GetLogy());
925 pad->SetLogz(GetLogz());
926 pad->SetBorderSize(GetBorderSize());
927 pad->SetBorderMode(GetBorderMode());
928 TAttLine::Copy((TAttLine&)*pad);
929 TAttFill::Copy((TAttFill&)*pad);
930 TAttPad::Copy((TAttPad&)*pad);
933 TIter next(GetListOfPrimitives());
934 while ((obj=next())) {
936 clone = obj->Clone();
937 pad->GetListOfPrimitives()->Add(clone,next.GetOption());
942 if (padsav) padsav->cd();
952 void TCanvas::DrawEventStatus(Int_t event, Int_t px, Int_t py, TObject *selected)
954 const Int_t kTMAX=256;
955 static char atext[kTMAX];
957 if (!TestBit(kShowEventStatus) || !selected)
return;
959 if (!fCanvasImp)
return;
961 TVirtualPad* savepad;
963 gPad = GetSelectedPad();
965 fCanvasImp->SetStatusText(selected->GetTitle(),0);
966 fCanvasImp->SetStatusText(selected->GetName(),1);
967 if (event == kKeyPress)
968 snprintf(atext, kTMAX,
"%c", (
char) px);
970 snprintf(atext, kTMAX,
"%d,%d", px, py);
971 fCanvasImp->SetStatusText(atext,2);
975 if ( selected->InheritsFrom(
"TH1") )
976 xaxis = ((TH1*)selected)->GetXaxis();
977 else if ( selected->InheritsFrom(
"TGraph") )
978 xaxis = ((TGraph*)selected)->GetXaxis();
979 else if ( selected->InheritsFrom(
"TAxis") )
980 xaxis = (TAxis*)selected;
981 if ( xaxis != NULL && xaxis->GetTimeDisplay()) {
982 TString objinfo = selected->GetObjectInfo(px,py);
985 if (objinfo.Contains(
"x=") && objinfo.Contains(
"y=") ) {
987 TString time_format(xaxis->GetTimeFormat());
989 Int_t idF = time_format.Index(
"%F");
991 Int_t lnF = time_format.Length();
993 if (lnF - idF == 21) {
994 time_format = time_format(idF+2, lnF);
995 TDatime dtoff(time_format);
996 toff = dtoff.Convert();
999 toff = (UInt_t)gStyle->GetTimeOffset();
1001 TDatime dt((UInt_t)gPad->AbsPixeltoX(px) + toff);
1002 snprintf(atext, kTMAX,
"%s, y=%g",
1003 dt.AsSQLString(),gPad->AbsPixeltoY(py));
1004 fCanvasImp->SetStatusText(atext,3);
1010 fCanvasImp->SetStatusText(selected->GetObjectInfo(px,py),3);
1018 void TCanvas::EditorBar()
1020 TVirtualPadEditor::GetPadEditor();
1027 void TCanvas::EmbedInto(Int_t winid, Int_t ww, Int_t wh)
1030 if(fCanvasImp)
return;
1042 fCanvasImp = gBatchGuiFactory->CreateCanvasImp(
this, GetName(), fCw, fCh);
1043 if (!fCanvasImp)
return;
1053 void TCanvas::EnterLeave(TPad *prevSelPad, TObject *prevSelObj)
1055 if (prevSelObj == fSelected)
return;
1057 TPad *padsav = (TPad *)gPad;
1058 Int_t sevent = fEvent;
1062 prevSelObj->ExecuteEvent(kMouseLeave, fEventX, fEventY);
1063 fEvent = kMouseLeave;
1065 ProcessedEvent(kMouseLeave, fEventX, fEventY, prevSelObj);
1068 gPad = fSelectedPad;
1071 fSelected->ExecuteEvent(kMouseEnter, fEventX, fEventY);
1072 fEvent = kMouseEnter;
1074 ProcessedEvent(kMouseEnter, fEventX, fEventY, fSelected);
1090 void TCanvas::ExecuteEvent(Int_t event, Int_t px, Int_t py)
1092 if (gROOT->GetEditorMode()) {
1093 TPad::ExecuteEvent(event,px,py);
1108 void TCanvas::FeedbackMode(Bool_t set)
1112 gVirtualX->SetDrawMode(TVirtualX::kInvert);
1115 gVirtualX->SetDrawMode(TVirtualX::kCopy);
1122 void TCanvas::Flush()
1124 if ((fCanvasID == -1) || IsWeb())
return;
1126 TPad *padsav = (TPad*)gPad;
1130 gVirtualX->SelectWindow(fCanvasID);
1133 gVirtualX->UpdateWindow(1);
1135 TVirtualPS *tvps = gVirtualPS;
1137 gGLManager->MakeCurrent(fGLDevice);
1138 fPainter->InitPainter();
1140 if (padsav && padsav->GetCanvas() ==
this) {
1142 padsav->HighLight(padsav->GetHighLightColor());
1145 fPainter->LockPainter();
1146 gGLManager->Flush(fGLDevice);
1150 if (padsav) padsav->cd();
1156 void TCanvas::UseCurrentStyle()
1158 if ((!gROOT->IsLineProcessing()) && (!gVirtualX->IsCmdThread())) {
1159 gInterpreter->Execute(
this, IsA(),
"UseCurrentStyle",
"");
1163 R__LOCKGUARD(gROOTMutex);
1165 TPad::UseCurrentStyle();
1167 if (gStyle->IsReading()) {
1168 SetFillColor(gStyle->GetCanvasColor());
1169 fBorderSize = gStyle->GetCanvasBorderSize();
1170 fBorderMode = gStyle->GetCanvasBorderMode();
1172 gStyle->SetCanvasColor(GetFillColor());
1173 gStyle->SetCanvasBorderSize(fBorderSize);
1174 gStyle->SetCanvasBorderMode(fBorderMode);
1181 Int_t TCanvas::GetWindowTopX()
1183 if (fCanvasImp) fCanvasImp->GetWindowGeometry(fWindowTopX, fWindowTopY,
1184 fWindowWidth,fWindowHeight);
1192 Int_t TCanvas::GetWindowTopY()
1194 if (fCanvasImp) fCanvasImp->GetWindowGeometry(fWindowTopX, fWindowTopY,
1195 fWindowWidth,fWindowHeight);
1205 void TCanvas::HandleInput(EEventType event, Int_t px, Int_t py)
1208 TPad *prevSelPad = (TPad*) fSelectedPad;
1209 TObject *prevSelObj = fSelected;
1211 fPadSave = (TPad*)gPad;
1222 pad = Pick(px, py, prevSelObj);
1225 EnterLeave(prevSelPad, prevSelObj);
1232 fSelected->ExecuteEvent(event, px, py);
1240 if (!fDoubleBuffer) FeedbackMode(kTRUE);
1247 TObject *sobj = fSelected;
1248 TPad *spad = fSelectedPad;
1251 EnterLeave(prevSelPad, prevSelObj);
1253 fSelectedPad = spad;
1254 if (!fDoubleBuffer) FeedbackMode(kFALSE);
1258 case kButton1Double:
1264 pad = Pick(px, py, prevSelObj);
1271 FeedbackMode(kTRUE);
1272 fSelected->ExecuteEvent(event, px, py);
1279 case kArrowKeyPress:
1280 case kArrowKeyRelease:
1281 case kButton1Motion:
1282 case kButton1ShiftMotion:
1284 gPad = fSelectedPad;
1286 fSelected->ExecuteEvent(event, px, py);
1287 gVirtualX->Update();
1288 if (fSelected && !fSelected->InheritsFrom(TAxis::Class())) {
1289 Bool_t resize = kFALSE;
1290 if (fSelected->InheritsFrom(TBox::Class()))
1291 resize = ((TBox*)fSelected)->IsBeingResized();
1292 if (fSelected->InheritsFrom(TVirtualPad::Class()))
1293 resize = ((TVirtualPad*)fSelected)->IsBeingResized();
1295 if ((!resize && TestBit(kMoveOpaque)) || (resize && TestBit(kResizeOpaque))) {
1298 FeedbackMode(kTRUE);
1310 gPad = fSelectedPad;
1312 fSelected->ExecuteEvent(event, px, py);
1331 pad = Pick(px, py, prevSelObj);
1337 FeedbackMode(kTRUE);
1339 if (fSelected) fSelected->Pop();
1342 printf(
"Current Pad: %s / %s\n", pad->GetName(), pad->GetTitle());
1346 TIter next(gROOT->GetListOfCanvases());
1348 while ((tc = (TCanvas *)next()))
1357 case kButton2Motion:
1361 gPad = fSelectedPad;
1363 fSelected->ExecuteEvent(event, px, py);
1368 case kButton2Double:
1375 pad = Pick(px, py, prevSelObj);
1378 if (!fDoubleBuffer) FeedbackMode(kFALSE);
1380 if (fContextMenu && fSelected && !fSelected->TestBit(kNoContextMenu) &&
1381 !pad->TestBit(kNoContextMenu) && !TestBit(kNoContextMenu))
1382 fContextMenu->Popup(px, py, fSelected,
this, pad);
1386 case kButton3Motion:
1390 if (!fDoubleBuffer) FeedbackMode(kTRUE);
1393 case kButton3Double:
1397 if (!fSelectedPad || !fSelected)
return;
1398 gPad = fSelectedPad;
1400 fSelected->ExecuteEvent(event, px, py);
1408 pad = Pick(px, py, prevSelObj);
1412 EnterLeave(prevSelPad, prevSelObj);
1418 fSelected->ExecuteEvent(event, px, py);
1425 pad = Pick(px, py, prevSelObj);
1430 fSelected->ExecuteEvent(event, px, py);
1437 if (fPadSave && event != kButton2Down)
1440 if (event != kMouseLeave) {
1441 ProcessedEvent(event, px, py, fSelected);
1442 DrawEventStatus(event, px, py, fSelected);
1449 Bool_t TCanvas::IsFolder()
const
1457 void TCanvas::ls(Option_t *option)
const
1459 TROOT::IndentLevel();
1460 std::cout <<
"Canvas Name=" <<GetName()<<
" Title="<<GetTitle()<<
" Option="<<option<<std::endl;
1461 TROOT::IncreaseDirLevel();
1463 TROOT::DecreaseDirLevel();
1469 TCanvas *TCanvas::MakeDefCanvas()
1471 const char *defcanvas = gROOT->GetDefCanvasName();
1474 auto lc = (TList*)gROOT->GetListOfCanvases();
1475 if (lc->FindObject(defcanvas)) {
1476 Int_t n = lc->GetSize() + 1;
1477 cdef =
new char[strlen(defcanvas)+15];
1479 strlcpy(cdef,Form(
"%s_n%d", defcanvas, n++),strlen(defcanvas)+15);
1480 }
while (lc->FindObject(cdef));
1482 cdef = StrDup(Form(
"%s",defcanvas));
1484 TCanvas *c =
new TCanvas(cdef, cdef, 1);
1486 ::Info(
"TCanvas::MakeDefCanvas",
" created default TCanvas with name %s",cdef);
1500 void TCanvas::MoveOpaque(Int_t set)
1502 SetBit(kMoveOpaque,set);
1508 void TCanvas::Paint(Option_t *option)
1511 TPad::Paint(option);
1518 TPad *TCanvas::Pick(Int_t px, Int_t py, TObject *prevSelObj)
1520 TObjLink *pickobj = 0;
1526 TPad *pad = Pick(px, py, pickobj);
1534 fSelected = pickobj->GetObject();
1535 fSelectedOpt = pickobj->GetOption();
1540 if (fSelected != prevSelObj)
1541 Picked(fSelectedPad, fSelected, fEvent);
1543 if ((fEvent == kButton1Down) || (fEvent == kButton2Down) || (fEvent == kButton3Down)) {
1544 if (fSelected && !fSelected->InheritsFrom(TView::Class())) {
1545 fClickSelected = fSelected;
1546 fClickSelectedPad = fSelectedPad;
1547 Selected(fSelectedPad, fSelected, fEvent);
1558 void TCanvas::Picked(TPad *pad, TObject *obj, Int_t event)
1562 args[0] = (Long_t) pad;
1563 args[1] = (Long_t) obj;
1566 Emit(
"Picked(TPad*,TObject*,Int_t)", args);
1577 void TCanvas::Highlighted(TVirtualPad *pad, TObject *obj, Int_t x, Int_t y)
1581 args[0] = (Long_t) pad;
1582 args[1] = (Long_t) obj;
1586 Emit(
"Highlighted(TVirtualPad*,TObject*,Int_t,Int_t)", args);
1596 void TCanvas::HighlightConnect(
const char *slot)
1598 Connect(
"Highlighted(TVirtualPad*,TObject*,Int_t,Int_t)", 0, 0, slot);
1604 void TCanvas::Selected(TVirtualPad *pad, TObject *obj, Int_t event)
1608 args[0] = (Long_t) pad;
1609 args[1] = (Long_t) obj;
1612 Emit(
"Selected(TVirtualPad*,TObject*,Int_t)", args);
1618 void TCanvas::ProcessedEvent(Int_t event, Int_t x, Int_t y, TObject *obj)
1625 args[3] = (Long_t) obj;
1627 Emit(
"ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", args);
1633 void TCanvas::Resize(Option_t *)
1635 if (fCanvasID == -1)
return;
1637 if ((!gROOT->IsLineProcessing()) && (!gVirtualX->IsCmdThread())) {
1638 gInterpreter->Execute(
this, IsA(),
"Resize",
"");
1642 R__LOCKGUARD(gROOTMutex);
1644 TPad *padsav = (TPad*)gPad;
1648 gVirtualX->SelectWindow(fCanvasID);
1649 gVirtualX->ResizeWindow(fCanvasID);
1652 fCanvasImp->GetWindowGeometry(fWindowTopX, fWindowTopY,
1653 fWindowWidth, fWindowHeight);
1657 gVirtualX->GetGeometry(fCanvasID, dum1, dum2, fCw, fCh);
1660 if (fXsizeUser && fYsizeUser) {
1663 Double_t rxy = fXsizeUser/fYsizeUser;
1665 UInt_t twh = UInt_t(Double_t(fCw)/rxy);
1667 nww = UInt_t(Double_t(fCh)*rxy);
1671 nww = fCw; nwh = twh;
1674 nwh = fCh; nww = UInt_t(Double_t(fCh)/rxy);
1677 UInt_t twh = UInt_t(Double_t(fCw)*rxy);
1679 nwh = UInt_t(Double_t(fCw)/rxy);
1683 nww = fCw; nwh = twh;
1686 nwh = fCh; nww = UInt_t(Double_t(fCh)*rxy);
1694 fYsizeReal = kDefaultCanvasSize;
1695 fXsizeReal = fYsizeReal*Double_t(fCw)/Double_t(fCh);
1698 fXsizeReal = kDefaultCanvasSize;
1699 fYsizeReal = fXsizeReal*Double_t(fCh)/Double_t(fCw);
1705 if (padsav) padsav->cd();
1717 void TCanvas::ResizeOpaque(Int_t set)
1719 SetBit(kResizeOpaque,set);
1725 void TCanvas::RunAutoExec()
1727 if (!TestBit(kAutoExec))
return;
1729 ((TPad*)gPad)->AutoExec();
1736 void TCanvas::SavePrimitive(std::ostream &out, Option_t *option )
1739 if (gStyle->GetOptFit()) {
1740 out<<
" gStyle->SetOptFit(1);"<<std::endl;
1742 if (!gStyle->GetOptStat()) {
1743 out<<
" gStyle->SetOptStat(0);"<<std::endl;
1745 if (!gStyle->GetOptTitle()) {
1746 out<<
" gStyle->SetOptTitle(0);"<<std::endl;
1748 if (gROOT->GetEditHistograms()) {
1749 out<<
" gROOT->SetEditHistograms();"<<std::endl;
1751 if (GetShowEventStatus()) {
1752 out<<
" "<<GetName()<<
"->ToggleEventStatus();"<<std::endl;
1754 if (GetShowToolTips()) {
1755 out<<
" "<<GetName()<<
"->ToggleToolTips();"<<std::endl;
1757 if (GetShowToolBar()) {
1758 out<<
" "<<GetName()<<
"->ToggleToolBar();"<<std::endl;
1760 if (GetHighLightColor() != 5) {
1761 if (GetHighLightColor() > 228) {
1762 TColor::SaveColor(out, GetHighLightColor());
1763 out<<
" "<<GetName()<<
"->SetHighLightColor(ci);" << std::endl;
1765 out<<
" "<<GetName()<<
"->SetHighLightColor("<<GetHighLightColor()<<
");"<<std::endl;
1770 TPad::SavePrimitive(out,option);
1781 void TCanvas::SaveSource(
const char *filename, Option_t *option)
1784 TIter next(gROOT->GetListOfClasses());
1786 while((cl = (TClass*)next())) {
1787 cl->ResetBit(TClass::kClassSaved);
1792 Int_t lenfile = strlen(filename);
1795 const char *cname = GetName();
1796 Bool_t invalid = kFALSE;
1800 fname = (
char*)filename;
1801 out.open(fname, std::ios::out);
1803 Int_t nch = strlen(cname);
1805 strlcpy(lcname,cname,10);
1806 for (Int_t k=1;k<=nch;k++) {
if (lcname[nch-k] ==
' ') lcname[nch-k] = 0;}
1807 if (lcname[0] == 0) {invalid = kTRUE; strlcpy(lcname,
"c1",10); nch = 2;}
1810 fname =
new char[nch+3];
1811 strlcpy(fname,cname,nch+3);
1812 strncat(fname,
".C",3);
1813 out.open(fname, std::ios::out);
1816 Error(
"SaveSource",
"Cannot open file: %s",fname);
1817 if (!lenfile)
delete [] fname;
1822 Int_t precision = gEnv->GetValue(
"Canvas.SavePrecision",7);
1823 out.precision(precision);
1827 Float_t cx = gStyle->GetScreenFactor();
1831 Error(
"SaveSource",
"Cannot open TCanvas");
1834 UInt_t editorWidth = fCanvasImp->GetWindowGeometry(topx,topy,w,h);
1835 w = UInt_t((fWindowWidth - editorWidth)/cx);
1836 h = UInt_t((fWindowHeight)/cx);
1837 topx = GetWindowTopX();
1838 topy = GetWindowTopY();
1841 w = GetWw()+4; h = GetWh()+4;
1845 TString mname(fname);
1850 Int_t p = mname.Last(
'.');
1851 Int_t s = mname.Last(
'/')+1;
1855 TString first(mname(s,s+1));
1856 if (!first.IsDigit()) out <<
"void " << mname(s,p-s) <<
"()" << std::endl;
1858 out <<
"{"<<std::endl;
1859 out <<
"//=========Macro generated from canvas: "<<GetName()<<
"/"<<GetTitle()<<std::endl;
1860 out <<
"//========= ("<<t.AsString()<<
") by ROOT version "<<gROOT->GetVersion()<<std::endl;
1862 if (gStyle->GetCanvasPreferGL())
1863 out <<std::endl<<
" gStyle->SetCanvasPreferGL(kTRUE);"<<std::endl<<std::endl;
1866 if (InheritsFrom(TDialogCanvas::Class())) {
1867 out<<
" "<<ClassName()<<
" *"<<cname<<
" = new "<<ClassName()<<
"("<<quote<<GetName()
1868 <<quote<<
", "<<quote<<GetTitle()<<quote<<
","<<w<<
","<<h<<
");"<<std::endl;
1871 out<<
" TCanvas *"<<cname<<
" = new TCanvas("<<quote<<GetName()<<quote<<
", "<<quote<<GetTitle()
1874 out<<
",-"<<topx<<
","<<topy<<
","<<w<<
","<<h<<
");"<<std::endl;
1876 out<<
","<<topx<<
","<<topy<<
","<<w<<
","<<h<<
");"<<std::endl;
1879 if (gStyle->GetOptFit()) {
1880 out<<
" gStyle->SetOptFit(1);"<<std::endl;
1882 if (!gStyle->GetOptStat()) {
1883 out<<
" gStyle->SetOptStat(0);"<<std::endl;
1885 if (!gStyle->GetOptTitle()) {
1886 out<<
" gStyle->SetOptTitle(0);"<<std::endl;
1888 if (gROOT->GetEditHistograms()) {
1889 out<<
" gROOT->SetEditHistograms();"<<std::endl;
1891 if (GetShowEventStatus()) {
1892 out<<
" "<<GetName()<<
"->ToggleEventStatus();"<<std::endl;
1894 if (GetShowToolTips()) {
1895 out<<
" "<<GetName()<<
"->ToggleToolTips();"<<std::endl;
1897 if (GetHighLightColor() != 5) {
1898 if (GetHighLightColor() > 228) {
1899 TColor::SaveColor(out, GetHighLightColor());
1900 out<<
" "<<GetName()<<
"->SetHighLightColor(ci);" << std::endl;
1902 out<<
" "<<GetName()<<
"->SetHighLightColor("<<GetHighLightColor()<<
");"<<std::endl;
1907 if (invalid) SetName(
"c1");
1908 TPad::SavePrimitive(out,option);
1910 out<<
" "<<GetName()<<
"->SetSelected("<<GetName()<<
");"<<std::endl;
1911 if (GetShowToolBar()) {
1912 out<<
" "<<GetName()<<
"->ToggleToolBar();"<<std::endl;
1914 if (invalid) SetName(
" ");
1916 out <<
"}"<<std::endl;
1918 Info(
"SaveSource",
"C++ Macro file: %s has been generated", fname);
1922 while((cl = (TClass*)next())) {
1923 cl->ResetBit(TClass::kClassSaved);
1925 if (!lenfile)
delete [] fname;
1932 void TCanvas::SetBatch(Bool_t batch)
1934 if (gROOT->IsBatch() || IsWeb())
1948 void TCanvas::SetCanvasSize(UInt_t ww, UInt_t wh)
1951 fCanvasImp->SetCanvasSize(ww, wh);
1961 void TCanvas::SetCursor(ECursor cursor)
1963 if (IsBatch())
return;
1964 gVirtualX->SetCursor(fCanvasID, cursor);
1970 void TCanvas::SetDoubleBuffer(Int_t mode)
1972 if (IsBatch())
return;
1973 fDoubleBuffer = mode;
1974 gVirtualX->SetDoubleBuffer(fCanvasID, mode);
1978 if (fDoubleBuffer) {
1979 if (fPixmapID != -1) fPainter->SelectDrawable(fPixmapID);
1981 if (fCanvasID != -1) fPainter->SelectDrawable(fCanvasID);
1987 void TCanvas::SetFixedAspectRatio(Bool_t fixed)
1990 if (!fFixedAspectRatio) {
1992 fAspectRatio = Double_t(fCw) / fCh;
1994 Error(
"SetAspectRatio",
"cannot fix aspect ratio, height of canvas is 0");
1997 fFixedAspectRatio = kTRUE;
2000 fFixedAspectRatio = kFALSE;
2009 void TCanvas::SetFolder(Bool_t isfolder)
2011 fgIsFolder = isfolder;
2017 void TCanvas::SetName(
const char *name)
2019 if (!name || !name[0]) {
2020 const char *defcanvas = gROOT->GetDefCanvasName();
2022 auto lc = (TList*)gROOT->GetListOfCanvases();
2023 if (lc->FindObject(defcanvas)) {
2024 cdef = Form(
"%s_n%d",defcanvas,lc->GetSize()+1);
2026 cdef = Form(
"%s",defcanvas);
2032 if (gPad && TestBit(kMustCleanup)) gPad->Modified();
2038 void TCanvas::SetSelected(TObject *obj)
2041 if (obj) obj->SetBit(kMustCleanup);
2047 void TCanvas::SetTitle(
const char *title)
2050 if (fCanvasImp) fCanvasImp->SetWindowTitle(title);
2073 void TCanvas::Size(Float_t xsize, Float_t ysize)
2084 void TCanvas::Streamer(TBuffer &b)
2087 if (b.IsReading()) {
2088 Version_t v = b.ReadVersion(&R__s, &R__c);
2091 if (v>7) b.ClassBegin(TCanvas::IsA());
2092 if (v>7) b.ClassMember(
"TPad");
2096 TObjArray *colors = (TObjArray*)fPrimitives->FindObject(
"ListOfColors");
2100 while ((colold = (TColor*)next())) {
2103 if (colold) cn = colold->GetNumber();
2104 TColor *colcur = gROOT->GetColor(cn);
2106 colcur->SetRGB(colold->GetRed(),colold->GetGreen(),colold->GetBlue());
2108 colcur =
new TColor(cn,colold->GetRed(),
2112 if (!colcur)
return;
2117 TObjArray *currentpalette = (TObjArray*)fPrimitives->FindObject(
"CurrentColorPalette");
2118 if (currentpalette) {
2119 TIter nextpal(currentpalette);
2120 Int_t n = currentpalette->GetEntries();
2121 TArrayI palcolors(n);
2124 while ((col = (TColor*)nextpal())) palcolors[i++] = col->GetNumber();
2125 gStyle->SetPalette(n,palcolors.GetArray());
2126 fPrimitives->Remove(currentpalette);
2127 delete currentpalette;
2129 fPrimitives->Remove(colors);
2134 if (v>7) b.ClassMember(
"fDISPLAY",
"TString");
2135 fDISPLAY.Streamer(b);
2136 if (v>7) b.ClassMember(
"fDoubleBuffer",
"Int_t");
2138 if (v>7) b.ClassMember(
"fRetained",
"Bool_t");
2140 if (v>7) b.ClassMember(
"fXsizeUser",
"Size_t");
2142 if (v>7) b.ClassMember(
"fYsizeUser",
"Size_t");
2144 if (v>7) b.ClassMember(
"fXsizeReal",
"Size_t");
2146 if (v>7) b.ClassMember(
"fYsizeReal",
"Size_t");
2149 if (v>7) b.ClassMember(
"fWindowTopX",
"Int_t");
2151 if (v>7) b.ClassMember(
"fWindowTopY",
"Int_t");
2154 if (v>7) b.ClassMember(
"fWindowWidth",
"UInt_t");
2156 if (v>7) b.ClassMember(
"fWindowHeight",
"UInt_t");
2159 if (v>7) b.ClassMember(
"fCw",
"UInt_t");
2161 if (v>7) b.ClassMember(
"fCh",
"UInt_t");
2165 fWindowHeight = fCh;
2167 if (v>7) b.ClassMember(
"fCatt",
"TAttCanvas");
2170 if (v>7) b.ClassMember(
"kMoveOpaque",
"Bool_t");
2171 b >> dummy;
if (dummy) MoveOpaque(1);
2172 if (v>7) b.ClassMember(
"kResizeOpaque",
"Bool_t");
2173 b >> dummy;
if (dummy) ResizeOpaque(1);
2174 if (v>7) b.ClassMember(
"fHighLightColor",
"Color_t");
2175 b >> fHighLightColor;
2176 if (v>7) b.ClassMember(
"fBatch",
"Bool_t");
2179 if (v>7) b.ClassMember(
"kShowEventStatus",
"Bool_t");
2180 b >> dummy;
if (dummy) SetBit(kShowEventStatus);
2183 if (v>7) b.ClassMember(
"kAutoExec",
"Bool_t");
2184 b >> dummy;
if (dummy) SetBit(kAutoExec);
2186 if (v>7) b.ClassMember(
"kMenuBar",
"Bool_t");
2187 b >> dummy;
if (dummy) SetBit(kMenuBar);
2188 fBatch = gROOT->IsBatch();
2189 if (v>7) b.ClassEnd(TCanvas::IsA());
2190 b.CheckByteCount(R__s, R__c, TCanvas::IsA());
2196 TObjArray *colors = 0;
2197 TObjArray *CurrentColorPalette = 0;
2198 if (TColor::DefinedColors()) {
2199 if (!b.CheckObject(gROOT->GetListOfColors(),TObjArray::Class())) {
2200 colors = (TObjArray*)gROOT->GetListOfColors();
2201 fPrimitives->Add(colors);
2204 TArrayI pal = TColor::GetPalette();
2205 Int_t palsize = pal.GetSize();
2206 CurrentColorPalette =
new TObjArray();
2207 CurrentColorPalette->SetName(
"CurrentColorPalette");
2208 for (Int_t i=0; i<palsize; i++) CurrentColorPalette->Add(gROOT->GetColor(pal[i]));
2209 fPrimitives->Add(CurrentColorPalette);
2212 R__c = b.WriteVersion(TCanvas::IsA(), kTRUE);
2213 b.ClassBegin(TCanvas::IsA());
2214 b.ClassMember(
"TPad");
2216 if (colors) fPrimitives->Remove(colors);
2217 if (CurrentColorPalette) { fPrimitives->Remove(CurrentColorPalette);
delete CurrentColorPalette; }
2218 b.ClassMember(
"fDISPLAY",
"TString");
2219 fDISPLAY.Streamer(b);
2220 b.ClassMember(
"fDoubleBuffer",
"Int_t");
2222 b.ClassMember(
"fRetained",
"Bool_t");
2224 b.ClassMember(
"fXsizeUser",
"Size_t");
2226 b.ClassMember(
"fYsizeUser",
"Size_t");
2228 b.ClassMember(
"fXsizeReal",
"Size_t");
2230 b.ClassMember(
"fYsizeReal",
"Size_t");
2232 UInt_t w = fWindowWidth, h = fWindowHeight;
2233 Int_t topx = fWindowTopX, topy = fWindowTopY;
2234 UInt_t editorWidth = 0;
2235 if(fCanvasImp) editorWidth = fCanvasImp->GetWindowGeometry(topx,topy,w,h);
2236 b.ClassMember(
"fWindowTopX",
"Int_t");
2238 b.ClassMember(
"fWindowTopY",
"Int_t");
2240 b.ClassMember(
"fWindowWidth",
"UInt_t");
2241 b << (UInt_t)(w-editorWidth);
2242 b.ClassMember(
"fWindowHeight",
"UInt_t");
2244 b.ClassMember(
"fCw",
"UInt_t");
2246 b.ClassMember(
"fCh",
"UInt_t");
2248 b.ClassMember(
"fCatt",
"TAttCanvas");
2250 b.ClassMember(
"kMoveOpaque",
"Bool_t");
2251 b << TestBit(kMoveOpaque);
2252 b.ClassMember(
"kResizeOpaque",
"Bool_t");
2253 b << TestBit(kResizeOpaque);
2254 b.ClassMember(
"fHighLightColor",
"Color_t");
2255 b << fHighLightColor;
2256 b.ClassMember(
"fBatch",
"Bool_t");
2258 b.ClassMember(
"kShowEventStatus",
"Bool_t");
2259 b << TestBit(kShowEventStatus);
2260 b.ClassMember(
"kAutoExec",
"Bool_t");
2261 b << TestBit(kAutoExec);
2262 b.ClassMember(
"kMenuBar",
"Bool_t");
2263 b << TestBit(kMenuBar);
2264 b.ClassEnd(TCanvas::IsA());
2265 b.SetByteCount(R__c, kTRUE);
2272 void TCanvas::ToggleAutoExec()
2274 Bool_t autoExec = TestBit(kAutoExec);
2275 SetBit(kAutoExec,!autoExec);
2281 void TCanvas::ToggleEventStatus()
2283 Bool_t showEventStatus = !TestBit(kShowEventStatus);
2284 SetBit(kShowEventStatus,showEventStatus);
2286 if (fCanvasImp) fCanvasImp->ShowStatusBar(showEventStatus);
2292 void TCanvas::ToggleToolBar()
2294 Bool_t showToolBar = !TestBit(kShowToolBar);
2295 SetBit(kShowToolBar,showToolBar);
2297 if (fCanvasImp) fCanvasImp->ShowToolBar(showToolBar);
2303 void TCanvas::ToggleEditor()
2305 Bool_t showEditor = !TestBit(kShowEditor);
2306 SetBit(kShowEditor,showEditor);
2308 if (fCanvasImp) fCanvasImp->ShowEditor(showEditor);
2314 void TCanvas::ToggleToolTips()
2316 Bool_t showToolTips = !TestBit(kShowToolTips);
2317 SetBit(kShowToolTips, showToolTips);
2319 if (fCanvasImp) fCanvasImp->ShowToolTips(showToolTips);
2326 Bool_t TCanvas::SupportAlpha()
2328 return gPad && (gVirtualX->InheritsFrom(
"TGQuartz") ||
2329 gPad->GetGLDevice() != -1);
2332 extern "C" void ROOT_TCanvas_Update(
void* TheCanvas) {
2333 static_cast<TCanvas*
>(TheCanvas)->Update();
2339 void TCanvas::Update()
2341 if (fUpdating)
return;
2343 if (fPixmapID == -1)
return;
2345 static const union CastFromFuncToVoidPtr_t {
2346 CastFromFuncToVoidPtr_t(): fFuncPtr(ROOT_TCanvas_Update) {}
2347 void (*fFuncPtr)(
void*);
2349 } castFromFuncToVoidPtr;
2354 arr[2] = castFromFuncToVoidPtr.fVoidPtr;
2355 if ((*gThreadXAR)(
"CUPD", 3, arr, 0))
return;
2358 if (!fCanvasImp)
return;
2360 if (!gVirtualX->IsCmdThread()) {
2364 gInterpreter->Execute(
this, IsA(),
"Update",
"");
2368 R__LOCKGUARD(gROOTMutex);
2372 if (!fCanvasImp->PerformUpdate()) {
2374 if (!IsBatch()) FeedbackMode(kFALSE);
2376 if (!UseGL()) PaintModified();
2389 void TCanvas::DisconnectWidget()
2398 Bool_t TCanvas::IsGrayscale()
2400 return TestBit(kIsGrayscale);
2407 void TCanvas::SetGrayscale(Bool_t set )
2409 if (IsGrayscale() == set)
return;
2410 SetBit(kIsGrayscale, set);
2421 void TCanvas::CreatePainter()
2425 if (!UseGL() || fBatch) {
2427 if (fCanvasImp) fPainter = fCanvasImp->CreatePadPainter();
2428 if (!fPainter) fPainter =
new TPadPainter;
2430 fPainter = TVirtualPadPainter::PadPainter(
"gl");
2432 Error(
"CreatePainter",
"GL Painter creation failed! Will use default!");
2433 fPainter =
new TPadPainter;
2442 TVirtualPadPainter *TCanvas::GetCanvasPainter()
2444 if (!fPainter) CreatePainter();
2452 void TCanvas::DeleteCanvasPainter()
2454 if (fGLDevice != -1) {
2459 gGLManager->MakeCurrent(fGLDevice);
2465 if (fGLDevice != -1) {
2466 gGLManager->DeleteGLContext(fGLDevice);