MIDAS
Loading...
Searching...
No Matches
RMidasFrame Class Reference
Inheritance diagram for RMidasFrame:
Collaboration diagram for RMidasFrame:

Public Member Functions

 RMidasFrame (const TGWindow *p, UInt_t w, UInt_t h, char *host="localhost")
 
 ~RMidasFrame ()
 
void CloseWindow ()
 
Bool_t ProcessMessage (Long_t msg, Long_t param1, Long_t param2)
 

Private Member Functions

int ConnectServer ()
 
void GetHistoList ()
 
void GetHisto (const char *name)
 
void ClearHisto (const char *name)
 

Private Attributes

TGMenuBarfMenuBar
 
TGPopupMenufMenuFile
 
TGTabfTab
 
TGCompositeFramefTabHisto
 
TGCompositeFramefTabStatus
 
TGHorizontalFramefHorz1
 
TGHorizontalFramefHorz2
 
TGHorizontalFramefHorz3
 
TGListBoxfListBox
 
TRootEmbeddedCanvasfCanvas
 
TGTextButtonfBUpdate
 
TGTextButtonfBClear
 
char fHost [256]
 
TSocketfSock
 
TObjArrayfHistoNames
 
TH1fHisto
 

Detailed Description

Definition at line 233 of file rmidas.c.

Constructor & Destructor Documentation

◆ RMidasFrame()

RMidasFrame::RMidasFrame ( const TGWindow p,
UInt_t  w,
UInt_t  h,
char host = "localhost" 
)

Definition at line 389 of file rmidas.c.

390 :TGMainFrame(p, w, h)
391{
392 /* save host name */
393 if (host)
394 strcpy(fHost, host);
395 else
396 fHost[0] = 0;
397 fSock = NULL;
398
399 /* Create Menus */
400 fMenuFile = new TGPopupMenu(fClient->GetRoot());
401 fMenuFile->AddEntry("&Connect to ...", M_FILE_CONNECT);
402 fMenuFile->AddEntry("E&xit", M_FILE_EXIT);
403 fMenuFile->Associate(this);
404
405 fMenuBar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
406 fMenuBar->AddPopup("&File", fMenuFile,
407 new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
408
411
412 /* Create tab widget */
413 fTab = new TGTab(this, 600, 400);
414
415 /*---- histo tab ----*/
416
417 TGCompositeFrame *tf = fTab->AddTab("Histo");
419
420 /* Create a horizonal frame containing histo selection tree and canvas */
421 fHorz1 = new TGHorizontalFrame(fTabHisto, 600, 400);
422 fTabHisto->AddFrame(fHorz1,
423 new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 3, 3, 3, 0));
424
425 /* Create ListBox widget */
426 fListBox = new TGListBox(fHorz1, 1);
427 fListBox->Resize(100, 400);
428 fListBox->Associate(this);
429 fHorz1->AddFrame(fListBox, new TGLayoutHints(kLHintsExpandY, 0, 0, 0, 0));
430
431 /* Create an embedded canvas and add to the main frame, centered in x and y */
432 fCanvas = new TRootEmbeddedCanvas("Canvas", fHorz1, 400, 400);
433 fHorz1->AddFrame(fCanvas,
434 new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
435
436 /* Create a horizonal frame containing text buttons */
437 fHorz2 = new TGHorizontalFrame(fTabHisto, 600, 30);
438 fTabHisto->AddFrame(fHorz2, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
439
440 /* Create "Update" button */
441 fBUpdate = new TGTextButton(fHorz2, "Update", B_UPDATE);
442 fBUpdate->Associate(this);
443 fHorz2->AddFrame(fBUpdate, new TGLayoutHints(kLHintsCenterX, 10, 10, 4, 4));
444
445 /* Create "Clear" button */
446 fBClear = new TGTextButton(fHorz2, "Clear", B_CLEAR);
447 fBClear->Associate(this);
448 fHorz2->AddFrame(fBClear, new TGLayoutHints(kLHintsCenterX, 10, 10, 4, 4));
449
450 tf->AddFrame(fTabHisto, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 0, 0, 0));
451
452 /*---- status tab ----*/
453
454 tf = fTab->AddTab("Status");
456 /*
457 fHorz3 = new TGHorizontalFrame(fTabStatus, 600, 400);
458 fTabStatus->AddFrame(fHorz3, new TGLayoutHints(kLHintsExpandX|kLHintsExpandY, 0, 0, 0, 0));
459 fHorz3->AddFrame(new TGLabel(fTabStatus, "Test"), new TGLayoutHints(kLHintsExpandX|kLHintsExpandY, 0, 0, 0, 0));
460 */
461 fTabStatus->
462 AddFrame(new TGLabel(fTabStatus, "Here will come the experiment status display"),
463 new TGLayoutHints(kLHintsTop, 100, 100, 100, 0));
464 tf->AddFrame(fTabStatus, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 0, 0, 0));
465
466 /*--------------------*/
467
469
470 SetWindowName("RMidas");
471
474 MapWindow();
475
476 fHisto = 0;
477 fHistoNames = 0;
478
479 /* connect to MRootServer */
481}
TGHorizontalFrame * fHorz1
Definition rmidas.c:243
TRootEmbeddedCanvas * fCanvas
Definition rmidas.c:248
char fHost[256]
Definition rmidas.c:253
TGTab * fTab
Definition rmidas.c:239
TGCompositeFrame * fTabHisto
Definition rmidas.c:240
TObjArray * fHistoNames
Definition rmidas.c:256
TGHorizontalFrame * fHorz2
Definition rmidas.c:244
TGCompositeFrame * fTabStatus
Definition rmidas.c:241
TGPopupMenu * fMenuFile
Definition rmidas.c:237
TSocket * fSock
Definition rmidas.c:254
TGTextButton * fBClear
Definition rmidas.c:251
int ConnectServer()
Definition rmidas.c:274
TH1 * fHisto
Definition rmidas.c:257
TGMenuBar * fMenuBar
Definition rmidas.c:236
TGListBox * fListBox
Definition rmidas.c:247
TGTextButton * fBUpdate
Definition rmidas.c:250
@ B_CLEAR
Definition rmidas.c:228
@ M_FILE_CONNECT
Definition rmidas.c:226
@ B_UPDATE
Definition rmidas.c:227
@ M_FILE_EXIT
Definition rmidas.c:225
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
Definition rmidas.h:24
Here is the call graph for this function:

◆ ~RMidasFrame()

RMidasFrame::~RMidasFrame ( )

Definition at line 545 of file rmidas.c.

546{
547 // Clean up
548
549 delete fMenuBar;
550 delete fMenuFile;
551 delete fHisto;
552 delete fHistoNames;
553 delete fSock;
554 delete fBUpdate;
555 delete fHorz1;
556 delete fHorz2;
557 delete fCanvas;
558}

Member Function Documentation

◆ ClearHisto()

void RMidasFrame::ClearHisto ( const char name)
private

Definition at line 378 of file rmidas.c.

379{
380 char str[32];
381
382 sprintf(str, "CLEAR %s", name);
383 fSock->Send(str);
384 fSock->Recv(str, sizeof(str));
385}
#define name(x)
Definition midas_macro.h:24
char str[256]
Definition odbhist.cxx:33
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CloseWindow()

void RMidasFrame::CloseWindow ( )

Definition at line 483 of file rmidas.c.

484{
485 // Got close message for this MainFrame. Terminate the application
486 // or returns from the TApplication event loop (depending on the
487 // argument specified in TApplication::Run()).
488
489 gApplication->Terminate(0);
490}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ConnectServer()

int RMidasFrame::ConnectServer ( )
private

Definition at line 274 of file rmidas.c.

275{
276 char str[80];
277
278 if (fSock) {
279 /* disconnect first */
280 fSock->Close();
281 delete fSock;
282 fSock = NULL;
283
284 SetWindowName("RMidas");
285
286 fListBox->RemoveEntries(0, 999);
287 }
288
289 if (fHost[0] == 0) {
290 new TGTextDialog(gClient->GetRoot(), this, 100, 100, "&Host name:", fHost);
291 }
292
293 /* Connect to RMidasServ */
294 fSock = new TSocket(fHost, 9090);
295
296 if (!fSock->IsValid()) {
297 sprintf(str, "Cannot connect to RMidas server on host %s, port 9090\n", fHost);
298 new TGMsgBox(gClient->GetRoot(), this, "Error", str, kMBIconExclamation, 0, NULL);
299
300 SetWindowName("RMidas");
301 return 0;
302 } else {
303 fSock->Recv(str, sizeof(str));
304 if (strncmp(str, "RMSERV", 6)) {
305 sprintf(str, "RMidas server not found on host %s, port 9090\n", fHost);
306 new TGMsgBox(gClient->GetRoot(), this, "Error", str, kMBIconExclamation, 0,
307 NULL);
308
309 fSock->Close();
310 delete fSock;
311 fSock = NULL;
312
313 SetWindowName("RMidas");
314 return 0;
315 } else {
316 sprintf(str, "RMidas connected to %s", fHost);
318 GetHistoList();
319 return 1;
320 }
321 }
322}
void GetHistoList()
Definition rmidas.c:326
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetHisto()

void RMidasFrame::GetHisto ( const char name)
private

Definition at line 351 of file rmidas.c.

352{
353 TMessage *m;
354 char str[32];
355
356 sprintf(str, "GET %s", name);
357 fSock->Send(str);
358 fSock->Recv(m);
359
360 if (fHisto)
361 delete fHisto;
362
363 fHisto = (TH1 *) m->ReadObject(m->GetClass());
364
365 if (!fHisto)
366 printf("Histo \"%s\" not available\n", name);
367 else
368 fHisto->Draw();
369
370 fCanvas->GetCanvas()->Modified();
371 fCanvas->GetCanvas()->Update();
372
373 delete m;
374}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetHistoList()

void RMidasFrame::GetHistoList ( )
private

Definition at line 326 of file rmidas.c.

327{
328 int i;
329
330 fSock->Send("LIST");
331
332 TMessage *m;
333 fSock->Recv(m);
334
335 if (fHistoNames)
336 delete fHistoNames;
337
338 fHistoNames = (TObjArray *) m->ReadObject(m->GetClass());
339
340 for (i = 0; i < fHistoNames->GetLast() + 1; i++)
341 fListBox->AddEntry((const char *) ((TObjString *) (fHistoNames->At(i)))->String(),
342 i);
343
344 fListBox->MapSubwindows();
345 fListBox->Layout();
346 delete m;
347}
INT i
Definition mdump.cxx:32
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ProcessMessage()

Bool_t RMidasFrame::ProcessMessage ( Long_t  msg,
Long_t  param1,
Long_t  param2 
)

Definition at line 492 of file rmidas.c.

493{
494 // Process messages coming from widgets associated with the dialog.
495
496 switch (GET_MSG(msg)) {
497 case kC_COMMAND:
498
499 switch (GET_SUBMSG(msg)) {
500 case kCM_MENU:
501 switch (param1) {
502 case M_FILE_EXIT:
503 CloseWindow();
504 break;
505
506 case M_FILE_CONNECT:
507 fHost[0] = 0;
509 break;
510 }
511 break;
512
513 case kCM_BUTTON:
514 switch (param1) {
515 case B_UPDATE:
516 if (fHisto)
517 GetHisto((char *) fHisto->GetName());
518 break;
519
520 case B_CLEAR:
521 if (fHisto) {
522 ClearHisto((char *) fHisto->GetName());
523 GetHisto((char *) fHisto->GetName());
524 }
525 break;
526 }
527 break;
528
529 case kCM_LISTBOX:
530 GetHisto((const char *) ((TObjString *) (fHistoNames->At(param2)))->String());
531 break;
532
533
534 case kCM_TAB:
535 //printf("Tab item %ld activated\n", param1);
536 break;
537 }
538 break;
539
540 }
541
542 return kTRUE;
543}
void GetHisto(const char *name)
Definition rmidas.c:351
void ClearHisto(const char *name)
Definition rmidas.c:378
void CloseWindow()
Definition rmidas.c:483
Here is the call graph for this function:

Member Data Documentation

◆ fBClear

TGTextButton* RMidasFrame::fBClear
private

Definition at line 251 of file rmidas.c.

◆ fBUpdate

TGTextButton* RMidasFrame::fBUpdate
private

Definition at line 250 of file rmidas.c.

◆ fCanvas

TRootEmbeddedCanvas* RMidasFrame::fCanvas
private

Definition at line 248 of file rmidas.c.

◆ fHisto

TH1* RMidasFrame::fHisto
private

Definition at line 257 of file rmidas.c.

◆ fHistoNames

TObjArray* RMidasFrame::fHistoNames
private

Definition at line 256 of file rmidas.c.

◆ fHorz1

TGHorizontalFrame* RMidasFrame::fHorz1
private

Definition at line 243 of file rmidas.c.

◆ fHorz2

TGHorizontalFrame* RMidasFrame::fHorz2
private

Definition at line 244 of file rmidas.c.

◆ fHorz3

TGHorizontalFrame* RMidasFrame::fHorz3
private

Definition at line 245 of file rmidas.c.

◆ fHost

char RMidasFrame::fHost[256]
private

Definition at line 253 of file rmidas.c.

◆ fListBox

TGListBox* RMidasFrame::fListBox
private

Definition at line 247 of file rmidas.c.

◆ fMenuBar

TGMenuBar* RMidasFrame::fMenuBar
private

Definition at line 236 of file rmidas.c.

◆ fMenuFile

TGPopupMenu* RMidasFrame::fMenuFile
private

Definition at line 237 of file rmidas.c.

◆ fSock

TSocket* RMidasFrame::fSock
private

Definition at line 254 of file rmidas.c.

◆ fTab

TGTab* RMidasFrame::fTab
private

Definition at line 239 of file rmidas.c.

◆ fTabHisto

TGCompositeFrame* RMidasFrame::fTabHisto
private

Definition at line 240 of file rmidas.c.

◆ fTabStatus

TGCompositeFrame* RMidasFrame::fTabStatus
private

Definition at line 241 of file rmidas.c.


The documentation for this class was generated from the following file: