Simple macro showing capabilities of the TGSpeedo widget.
protected:
public:
TGShapedMain(
const TGWindow *p,
int w,
int h);
virtual ~TGShapedMain();
TGSpeedo *GetSpeedo()
const {
return fSpeedo; }
Int_t GetActInfo()
const {
return fActInfo; }
void ToggleInfos();
};
TGShapedMain *gMainWindow;
{
fActInfo = 1;
fSpeedo =
new TGSpeedo(
this, 0.0, 100.0,
"CPU",
"[%]");
fSpeedo->Connect("OdoClicked()", "TGShapedMain", this, "ToggleInfos()");
fSpeedo->Connect("LedClicked()", "TGShapedMain", this, "CloseWindow()");
Connect("CloseWindow()", "TGShapedMain", this, "CloseWindow()");
fSpeedo->SetDisplayText("Used RAM", "[MB]");
fTimer->SetCommand("Update()");
fBgnd = fSpeedo->GetPicture();
if (fBgnd) {
gVirtualX->ShapeCombineMask(GetId(), 0, 0, fBgnd->GetMask());
SetBackgroundPixmap(fBgnd->GetPicture());
SetWMSizeHints(fBgnd->GetWidth(), fBgnd->GetHeight(), fBgnd->GetWidth(), fBgnd->GetHeight(), 1, 1);
}
MapSubwindows();
MapWindow();
DontCallClose();
Resize(GetDefaultSize());
SetWMSizeHints(GetDefaultWidth(), GetDefaultHeight(), GetDefaultWidth(), GetDefaultHeight(), 1, 1);
SetWindowName("ROOT CPU Load Meter");
fTimer->TurnOn();
}
void TGShapedMain::ToggleInfos()
{
if (fActInfo < 2)
fActInfo++;
else
fActInfo = 0;
if (fActInfo == 0)
fSpeedo->SetDisplayText("Total RAM", "[MB]");
else if (fActInfo == 1)
fSpeedo->SetDisplayText("Used RAM", "[MB]");
else if (fActInfo == 2)
fSpeedo->SetDisplayText("Free RAM", "[MB]");
}
TGShapedMain::~TGShapedMain()
{
delete fTimer;
delete fSpeedo;
}
void TGShapedMain::CloseWindow()
{
if (fTimer)
fTimer->TurnOff();
DestroyWindow();
}
void Update()
{
prev_load = act_load;
old_memUsage = memUsage;
gSystem->GetCpuInfo(&cpuInfo, 100);
if (gMainWindow->GetActInfo() == 0)
else if (gMainWindow->GetActInfo() == 1)
else if (gMainWindow->GetActInfo() == 2)
if (
fabs(act_load - prev_load) > 0.9) {
prev_load = act_load;
}
if (memUsage != old_memUsage) {
old_memUsage = memUsage;
}
}
void CPUMeter()
{
gMainWindow =
new TGShapedMain(
gClient->GetRoot(), 500, 200);
gSpeedo = gMainWindow->GetSpeedo();
}
int Int_t
Signed integer 4 bytes (int).
float Float_t
Float 4 bytes (float).
#define ClassDef(name, id)
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.
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
TGSpeedo is a widget looking like a speedometer, with a needle, a counter and a small odometer window...
void SetOdoValue(Int_t val)
Set actual value of odo meter.
void SetThresholds(Float_t th1=0.0, Float_t th2=0.0, Float_t th3=0.0)
void SetThresholdColors(EGlowColor col1, EGlowColor col2, EGlowColor col3)
void SetScaleValue(Float_t val)
Set actual scale (needle position) value.
ROOT GUI Window base class.
Handles synchronous and a-synchronous timer events.
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)