Is it possible to set a pad non-editable but still being able to change the scale of a TGraph with the mouse?
Usually, when people try to change the scale of graphs they accidentally “hit” the graph with the mouse and move it around unwantedly.
Yes, thank you. But when people are not very carful clicking around in the graph things like shown in the attached picture will happen.
Maybe an idea for future root versions to set only special features editable like only axis scaling but not moving.
Yes, I did and with SetEditable(kFALSE) nothing can be manipulated anymore. Though, I still would like to be able to zoom in or out (scale) the graph with the mouse so the user can magnify a region of interest but not accidantely move the graph around or manipulate data points.
I thought there could be something like TGraph->GetYaxis->SetEditable(kTRUE) which the would then only set the y-axis editable.
Thank you very much.
Though, as you can see in the picture I can scale but also move the graph aroung and change its size. That’s what I want to avoid. Just scaling is neccessary. Everything else will confuse the users.
Hi delos,
I guess I see your point now:
You agree that with the macro I sent the graph or its points cant be moved anymore?
However the frame can still be changed.
To avoid that the underlying boxes kCannotMove bit must be set:
#include "TCanvas.h"
#include "TGraph.h"
#include "TFrame.h"
void tgraph()
{
TCanvas *c =new TCanvas();
TGraph * g = new TGraph(3);
g->SetPoint(0, 1, 1);
g->SetPoint(1, 2, 2);
g->SetPoint(2, 3, 1);
c->SetEditable(kTRUE);
g->SetEditable(kFALSE);
g->Draw("AL");
c->Modified(); // make sure canvas and graph are painted
c->Update(); // before the following line of code
c->GetFrame()->SetBit(TBox::kCannotMove);
}
This c->GetFrame()->SetBit(TBox::kCannotMove); looks interesting and I tried. Though, The graphs can still be moved. I must say that I still have to go through the complete code to make sure I invoke this command a the right position. I’ll keep you updated. The difference probably is that I use pads (TPad).