FSUDAQ/programSetting.cpp

90 lines
3.4 KiB
C++
Raw Normal View History

#include <TApplication.h>
#include <TGClient.h>
#include <TCanvas.h>
#include <TF1.h>
#include <TRandom.h>
#include <TRootEmbeddedCanvas.h>
#include <TGTableContainer.h>
#include <TGFileDialog.h>
#include "programSetting.h"
std::string ProgramSetting::IP = "http://fsunuc.physics.fsu.edu/influx/";
std::string ProgramSetting::databaseName = "testing";
std::string ProgramSetting::DataSavingPath = "/home/catrina/FSUDAQ/";
ProgramSetting::ProgramSetting(const TGWindow *p){
fMain = new TGMainFrame(p, 600, 400);
fMain->SetWindowName("Program Setting");
fMain->Connect("CloseWindow()", "ProgramSetting", this, "CloseWindow()");
TGVerticalFrame * vframe = new TGVerticalFrame(fMain); fMain->AddFrame(vframe);
{///============== Database
TGGroupFrame * gfDatabase = new TGGroupFrame(vframe, "Database Setting", kHorizontalFrame); vframe->AddFrame(gfDatabase, new TGLayoutHints(kLHintsExpandY | kLHintsExpandX , 5, 5, 5, 5));
TGVerticalFrame * vfDB = new TGVerticalFrame(gfDatabase); gfDatabase->AddFrame(vfDB);
TGHorizontalFrame * hfDB1 = new TGHorizontalFrame(vfDB); vfDB->AddFrame(hfDB1);
TGLabel * lbIP = new TGLabel(hfDB1, "IP :"); hfDB1->AddFrame(lbIP, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 5,5,3,3));
txtIP = new TGTextEntry(hfDB1, IP.c_str()); hfDB1->AddFrame(txtIP, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 5,5,3,3));
txtIP->Resize(300, 20);
txtIP->Connect("ReturnPressed()", "ProgramSetting", this, "SetDataBase()");
TGHorizontalFrame * hfDB2 = new TGHorizontalFrame(vfDB); vfDB->AddFrame(hfDB2);
TGLabel * lbDBName = new TGLabel(hfDB2, "DB Name :"); hfDB2->AddFrame(lbDBName, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 5,5,3,3));
txtDBName = new TGTextEntry(hfDB2, databaseName.c_str()); hfDB2->AddFrame(txtDBName, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 5,5,3,3));
txtDBName->Connect("ReturnPressed()", "ProgramSetting", this, "SetDataBase()");
}
{///============== Data Saving Path
TGGroupFrame * gfData = new TGGroupFrame(vframe, "Data Storage", kHorizontalFrame); vframe->AddFrame(gfData, new TGLayoutHints(kLHintsExpandY | kLHintsExpandY , 5, 5, 5, 5));
TGVerticalFrame * vfData = new TGVerticalFrame(gfData); gfData->AddFrame(vfData);
TGHorizontalFrame * hfData = new TGHorizontalFrame(vfData); vfData->AddFrame(hfData);
TGLabel * lbDataPath = new TGLabel(hfData, "Data Absolute Path :"); hfData->AddFrame(lbDataPath, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 5,5,3,3));
txtDataPath = new TGTextEntry(hfData, DataSavingPath.c_str()); hfData->AddFrame(txtDataPath, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 5,5,3,3));
txtDataPath->Connect("ReturnPressed()", "ProgramSetting", this, "SetDataPath()");
txtDataPath->Resize(300, 20);
}
{///============== Read Time event building
}
fMain->MapSubwindows();
fMain->Resize(fMain->GetDefaultSize());
fMain->MapWindow();
}
ProgramSetting::~ProgramSetting(){
delete txtIP;
delete txtDBName;
2022-10-26 14:55:06 -04:00
delete txtDataPath;
fMain->Cleanup();
delete fMain;
}
void ProgramSetting::SetDataBase(){
IP = txtIP->GetText();
databaseName = txtDBName->GetText();
printf("IP: %s\n", IP.c_str());
printf("Name: %s\n", databaseName.c_str());
}
void ProgramSetting::SetDataPath(){
DataSavingPath = txtDataPath->GetText();
printf("DataSavingPath : %s\n", DataSavingPath.c_str());
}