Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions gui/webgui6/inc/TWebCanvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ class TWebCanvas : public TCanvasImp {
Long64_t fColorsVersion{0}; ///<! current colors/palette version, checked every time when new snapshot created
UInt_t fColorsHash{0}; ///<! last hash of colors/palette
Bool_t fTF1UseSave{kFALSE}; ///<! use save buffer for TF1/TF2, need when evaluation failed on client side
std::vector<int> fWindowGeometry; ///<! last received window geometry
Bool_t fFixedSize{kFALSE}; ///<! is canvas size fixed

UpdatedSignal_t fUpdatedSignal; ///<! signal emitted when canvas updated or state is changed
PadSignal_t fActivePadChangedSignal; ///<! signal emitted when active pad changed in the canvas
Expand Down Expand Up @@ -230,6 +232,8 @@ class TWebCanvas : public TCanvasImp {
void SetAsyncMode(Bool_t on = kTRUE) { fAsyncMode = on; }
Bool_t IsAsyncMode() const { return fAsyncMode; }

Bool_t IsFixedSize() const { return fFixedSize; }

static TString CreatePadJSON(TPad *pad, Int_t json_compression = 0, Bool_t batchmode = kFALSE);
static TString CreateCanvasJSON(TCanvas *c, Int_t json_compression = 0, Bool_t batchmode = kFALSE);
static Int_t StoreCanvasJSON(TCanvas *c, const char *filename, const char *option = "");
Expand Down
1 change: 1 addition & 0 deletions gui/webgui6/inc/TWebPadOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class TWebPadOptions {
std::string snapid; ///< id of pad
bool active{false}; ///< if pad selected as active
int cw{0}, ch{0}; ///< canvas width and height in pixels
std::vector<int> w; ///< window position and size in pixels, set only for canvas
int logx{0}, logy{0}, logz{0}; ///< pad log properties
int gridx{0}, gridy{0}; ///< pad grid properties
int tickx{0}, ticky{0}; ///< pad ticks properties
Expand Down
6 changes: 5 additions & 1 deletion gui/webgui6/inc/TWebSnapshot.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class TCanvasWebSnapshot : public TPadWebSnapshot {
protected:
std::string fScripts; ///< custom scripts to load
bool fHighlightConnect{false}; ///< does HighlightConnect has connection
bool fFixedSize{false}; ///< if canvas draw size is fixed
public:
TCanvasWebSnapshot(bool readonly = true, bool setids = true, bool batchmode = false) : TPadWebSnapshot(readonly, setids, batchmode) {}

Expand All @@ -111,7 +112,10 @@ class TCanvasWebSnapshot : public TPadWebSnapshot {
void SetHighlightConnect(bool on = true) { fHighlightConnect = on; }
bool GetHighlightConnect() const { return fHighlightConnect; }

ClassDefOverride(TCanvasWebSnapshot, 3) // Canvas painting snapshot, used for JSROOT
void SetFixedSize(bool on = true) { fFixedSize = on; }
bool IsFixedSize() const { return fFixedSize; }

ClassDefOverride(TCanvasWebSnapshot, 4) // Canvas painting snapshot, used for JSROOT
};


Expand Down
72 changes: 53 additions & 19 deletions gui/webgui6/src/TWebCanvas.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,8 @@ void TWebCanvas::CheckDataToSend(unsigned connid)

TCanvasWebSnapshot holder(IsReadOnly(), true, false); // readonly, set ids, batchmode

holder.SetFixedSize(fFixedSize); // set fixed size flag

// scripts send only when canvas drawn for the first time
if (!conn.fSendVersion)
holder.SetScripts(fCustomScripts);
Expand Down Expand Up @@ -892,12 +894,8 @@ void TWebCanvas::ShowWebWindow(const ROOT::Experimental::RWebDisplayArgs &args)
});
}

auto w = Canvas()->GetWw(), h = Canvas()->GetWh();
if (Canvas()->TestBit(TCanvas::kMenuBar)) h += 40;
if (Canvas()->TestBit(TCanvas::kShowEventStatus)) h += 40;
if (Canvas()->TestBit(TCanvas::kShowEditor)) w += 200;

if ((w > 10) && (w < 50000) && (h > 10) && (h < 30000))
auto w = Canvas()->GetWindowWidth(), h = Canvas()->GetWindowHeight();
if ((w > 0) && (w < 50000) && (h > 0) && (h < 30000))
fWindow->SetGeometry(w, h);

if ((args.GetBrowserKind() == ROOT::Experimental::RWebDisplayArgs::kQt5) ||
Expand All @@ -918,6 +916,9 @@ void TWebCanvas::Show()

ROOT::Experimental::RWebDisplayArgs args;
args.SetWidgetKind("TCanvas");
args.SetSize(Canvas()->GetWindowWidth(), Canvas()->GetWindowHeight());
args.SetPos(Canvas()->GetWindowTopX(), Canvas()->GetWindowTopY());

ShowWebWindow(args);
}

Expand Down Expand Up @@ -1009,8 +1010,22 @@ void TWebCanvas::SetWindowTitle(const char *newTitle)
//////////////////////////////////////////////////////////////////////////////////////////
/// Set canvas size of web canvas

void TWebCanvas::SetCanvasSize(UInt_t, UInt_t)
void TWebCanvas::SetCanvasSize(UInt_t cw, UInt_t ch)
{
fFixedSize = kTRUE;
if (IsFirstDrawn()) {
fCtrlMsgs["cw"s] = std::to_string(cw);
fCtrlMsgs["ch"s] = std::to_string(ch);
fCtrlMsgs["fixed_size"s] = "true"s;
}
if ((cw > 0) && (ch > 0)) {
Canvas()->fCw = cw;
Canvas()->fCh = ch;
} else {
// temporary value, will be reported back from client
Canvas()->fCw = Canvas()->fWindowWidth;
Canvas()->fCh = Canvas()->fWindowHeight;
}
}

//////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1054,8 +1069,13 @@ Bool_t TWebCanvas::DecodePadOptions(const std::string &msg, bool process_execs)
AssignStatusBits(r.bits);
Canvas()->fCw = r.cw;
Canvas()->fCh = r.ch;
Canvas()->fWindowWidth = r.cw + 2;
Canvas()->fWindowHeight = r.ch + 25;
if (r.w.size() == 4) {
fWindowGeometry = r.w;
Canvas()->fWindowTopX = fWindowGeometry[0];
Canvas()->fWindowTopY = fWindowGeometry[1];
Canvas()->fWindowWidth = fWindowGeometry[2];
Canvas()->fWindowHeight = fWindowGeometry[3];
}
}

if (r.active && (pad != gPad)) gPad = pad;
Expand Down Expand Up @@ -1660,12 +1680,17 @@ Bool_t TWebCanvas::ProcessData(unsigned connid, const std::string &arg)
}
} else if (arg.compare(0, 8, "RESIZED:") == 0) {
auto arr = TBufferJSON::FromJSON<std::vector<int>>(arg.substr(8));
if (arr && arr->size() == 2) {
if (arr && arr->size() == 7) {
// set members directly to avoid redrawing of the client again
Canvas()->fCw = arr->at(0);
Canvas()->fCh = arr->at(1);
Canvas()->fWindowWidth = arr->at(0) + 2;
Canvas()->fWindowHeight = arr->at(1) + 25;
Canvas()->fCw = arr->at(4);
Canvas()->fCh = arr->at(5);
fFixedSize = arr->at(6) > 0;
arr->resize(4);
fWindowGeometry = *arr;
Canvas()->fWindowTopX = fWindowGeometry[0];
Canvas()->fWindowTopY = fWindowGeometry[1];
Canvas()->fWindowWidth = fWindowGeometry[2];
Canvas()->fWindowHeight = fWindowGeometry[3];
}
} else if (arg.compare(0, 7, "POPOBJ:") == 0) {
auto arr = TBufferJSON::FromJSON<std::vector<std::string>>(arg.substr(7));
Expand Down Expand Up @@ -1758,10 +1783,17 @@ void TWebCanvas::CheckCanvasModified(bool force_modified)

UInt_t TWebCanvas::GetWindowGeometry(Int_t &x, Int_t &y, UInt_t &w, UInt_t &h)
{
x = 0;
y = 0;
w = Canvas()->GetWw() + 4;
h = Canvas()->GetWh() + 28;
if (fWindowGeometry.size() == 4) {
x = fWindowGeometry[0];
y = fWindowGeometry[1];
w = fWindowGeometry[2];
h = fWindowGeometry[3];
} else {
x = 0;
y = 0;
w = Canvas()->GetWw() + 2;
h = Canvas()->GetWh() + 25;
}
return 0;
}

Expand Down Expand Up @@ -2242,9 +2274,11 @@ TCanvasImp *TWebCanvas::NewCanvas(TCanvas *c, const char *name, Int_t x, Int_t y
auto imp = new TWebCanvas(c, name, x, y, width, height, readonly);

if (!gROOT->IsBatch()) {
c->fWindowTopX = x;
c->fWindowTopY = y;
c->fWindowWidth = width;
c->fWindowHeight = height;
c->fCw = width > 2 ? width - 2 : 0;
c->fCw = width;
c->fCh = height > 25 ? height - 25 : 0;
}

Expand Down
Loading