Simple macro showing capabilities of triple slider.
enum ETestCommandIdentifiers {
HId1,
HId2,
HId3,
HCId1,
HCId2,
HSId1
};
private:
public:
TTripleSliderDemo();
~TTripleSliderDemo() override;
void DoText(
const char *
text);
void DoSlider();
void HandleButtons();
};
{
char buf[32];
AddFrame(fCanvas, fLcan);
fCanvas->GetCanvas()->SetFillColor(33);
fCanvas->GetCanvas()->SetFrameFillColor(41);
fCanvas->GetCanvas()->SetBorderMode(0);
fCanvas->GetCanvas()->SetGrid();
fCanvas->GetCanvas()->SetLogy();
fCheck1->SetToolTipText("Pointer position constrained to slider sides");
fCheck2->SetToolTipText("Pointer position relative to slider position");
fHframe0->Resize(200, 50);
fHslider1->Connect("PointerPositionChanged()", "TTripleSliderDemo", this, "DoSlider()");
fHslider1->Connect("PositionChanged()", "TTripleSliderDemo", this, "DoSlider()");
fHslider1->SetRange(0.05, 5.0);
fHframe1->Resize(200, 25);
fTeh1->SetToolTipText("Minimum (left) Value of Slider");
fTeh2->SetToolTipText("Pointer Position Value");
fTeh3->SetToolTipText("Maximum (right) Value of Slider");
fTbh1->AddText(0, "0.0");
fTbh2->AddText(0, "0.0");
fTbh3->AddText(0, "0.0");
fTeh1->Connect("TextChanged(char*)", "TTripleSliderDemo", this, "DoText(char*)");
fTeh2->Connect("TextChanged(char*)", "TTripleSliderDemo", this, "DoText(char*)");
fTeh3->Connect("TextChanged(char*)", "TTripleSliderDemo", this, "DoText(char*)");
fCheck1->Connect("Clicked()", "TTripleSliderDemo", this, "HandleButtons()");
fCheck2->Connect("Clicked()", "TTripleSliderDemo", this, "HandleButtons()");
fHframe2->Resize(100, 25);
fHframe0->AddFrame(fCheck1, fBfly2);
fHframe0->AddFrame(fCheck2, fBfly2);
fHframe1->AddFrame(fHslider1, fBly);
fHframe2->AddFrame(fTeh1, fBfly2);
fHframe2->AddFrame(fTeh2, fBfly1);
fHframe2->AddFrame(fTeh3, fBfly3);
AddFrame(fHframe0, fBly);
AddFrame(fHframe1, fBly);
AddFrame(fHframe2, fBly);
SetWindowName("Triple Slider Demo");
Resize(GetDefaultSize());
MapWindow();
fFitFcn =
new TF1(
"fFitFcn",
"TMath::LogNormal(x, [0], [1], [2])", 0, 5);
fFitFcn->SetRange(0.0, 2.5);
fFitFcn->SetParameters(1.0, 0, 1);
fFitFcn->SetMinimum(1.0e-3);
fFitFcn->SetMaximum(10.0);
fFitFcn->SetLineColor(
kRed);
fFitFcn->SetLineWidth(1);
fFitFcn->Draw();
fHslider1->SetPosition(0.05, 2.5);
fHslider1->SetPointerPosition(1.0);
sprintf(buf, "%.3f", fHslider1->GetMinPosition());
fTbh1->Clear();
fTbh1->AddText(0, buf);
sprintf(buf, "%.3f", fHslider1->GetPointerPosition());
fTbh2->Clear();
fTbh2->AddText(0, buf);
sprintf(buf, "%.3f", fHslider1->GetMaxPosition());
fTbh3->Clear();
fTbh3->AddText(0, buf);
}
TTripleSliderDemo::~TTripleSliderDemo()
{
Cleanup();
}
void TTripleSliderDemo::CloseWindow()
{
delete this;
}
void TTripleSliderDemo::DoText(const char * )
{
switch (id) {
case HId1: fHslider1->SetPosition((
Float_t)atof(fTbh1->GetString()), (
Float_t)fHslider1->GetMaxPosition());
break;
case HId2: fHslider1->SetPointerPosition((
Float_t)atof(fTbh2->GetString()));
break;
case HId3: fHslider1->SetPosition((
Float_t)fHslider1->GetMinPosition(), (
Float_t)atof(fTbh1->GetString()));
break;
default: break;
}
fFitFcn->SetParameters(fHslider1->GetPointerPosition(), 0, 1);
fFitFcn->SetRange(fHslider1->GetMinPosition() - 0.05, fHslider1->GetMaxPosition());
fFitFcn->Draw();
fCanvas->GetCanvas()->Modified();
fCanvas->GetCanvas()->Update();
}
void TTripleSliderDemo::DoSlider()
{
char buf[32];
sprintf(buf, "%.3f", fHslider1->GetMinPosition());
fTbh1->Clear();
fTbh1->AddText(0, buf);
fTeh1->SetCursorPosition(fTeh1->GetCursorPosition());
fTeh1->Deselect();
sprintf(buf, "%.3f", fHslider1->GetPointerPosition());
fTbh2->Clear();
fTbh2->AddText(0, buf);
fTeh2->SetCursorPosition(fTeh2->GetCursorPosition());
fTeh2->Deselect();
sprintf(buf, "%.3f", fHslider1->GetMaxPosition());
fTbh3->Clear();
fTbh3->AddText(0, buf);
fTeh3->SetCursorPosition(fTeh3->GetCursorPosition());
fTeh3->Deselect();
fFitFcn->SetParameters(fHslider1->GetPointerPosition(), 0, 1);
fFitFcn->SetRange(fHslider1->GetMinPosition() - 0.05, fHslider1->GetMaxPosition());
fFitFcn->Draw();
fCanvas->GetCanvas()->Modified();
fCanvas->GetCanvas()->Update();
}
void TTripleSliderDemo::HandleButtons()
{
switch (id) {
case HCId1: fHslider1->SetConstrained(fCheck1->GetState()); break;
case HCId2: fHslider1->SetRelative(fCheck2->GetState()); break;
default: break;
}
}
void Slider3Demo()
{
new TTripleSliderDemo();
}
#define ClassDef(name, id)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize MapSubwindows
Option_t Option_t TPoint TPoint const char text
R__EXTERN void * gTQSender
A composite frame that layout their children in horizontal way.
This class describes layout hints used by the layout classes.
Defines top level windows that interact with the system Window Manager.
virtual void CloseWindow()
Close and delete main frame.
A text buffer is used in several widgets, like TGTextEntry, TGFileDialog, etc.
A TGTextEntry is a one line text input widget.
TripleSlider inherit from DoubleSlider widgets and allow easy selection of a min, max and pointer val...
This class creates a TGCanvas in which a TCanvas is created.