LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
evdb::ParameterSetEditFrame Class Reference

A frame for editing a single paramter set. More...

#include "ParameterSetEditDialog.h"

Public Member Functions

 ParameterSetEditFrame (TGCompositeFrame *mother, unsigned int psetid)
 
 ~ParameterSetEditFrame ()
 
std::string AsFHICL () const
 
void HandleMouseWheel (Event_t *event)
 
void Modified ()
 
void Finalize ()
 

Public Attributes

TGCompositeFrame * fTopFrame
 
TGCanvas * fCanvas
 
TGLayoutHints * fCanvasH
 
TGCompositeFrame * fContainer
 
TGTableLayout * fLayout
 
std::vector< TGHorizontalFrame * > fLHS
 
std::vector< TGHorizontalFrame * > fRHS
 
std::vector< TGTableLayoutHints * > fLHSHints
 
std::vector< TGTableLayoutHints * > fRHSHints
 
std::vector< ParameterSetEditRow * > fRow
 
unsigned int fParameterSetID
 
bool fIsModified
 

Detailed Description

A frame for editing a single paramter set.

===================================================================

Definition at line 169 of file ParameterSetEditDialog.h.

Constructor & Destructor Documentation

ParameterSetEditFrame::ParameterSetEditFrame ( TGCompositeFrame *  mother,
unsigned int  psetid 
)

Definition at line 675 of file ParameterSetEditDialog.cxx.

References fCanvas, fCanvasH, fContainer, fLayout, fLHS, fLHSHints, fRHS, fRHSHints, fRow, fhicl::ParameterSet::get_names(), evdb::ServiceTable::GetParameterSet(), evdb::ServiceTable::Instance(), and util::size().

677  : fParameterSetID(psetid), fIsModified(false)
678 {
679  fCanvas = new TGCanvas(mother, kWidth - 6, kHeight - 50);
680  fCanvasH = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY);
681  mother->AddFrame(fCanvas, fCanvasH);
682 
683  fContainer = new TGCompositeFrame(fCanvas->GetViewPort());
684  fCanvas->SetContainer(fContainer);
685 
686  // Locate the parameter set connected to this frame
687  const ServiceTable& st = ServiceTable::Instance();
688  const fhicl::ParameterSet& pset = st.GetParameterSet(psetid);
689  std::vector<std::string> keys = pset.get_names();
690  std::size_t const nkey = size(keys);
691 
692  // Count the number of "non system" parameters - each of these will
693  // need an row in the dialog window.
694  unsigned int nparam = 0;
695  for (auto const& key : keys) {
696  if (!((key == "service_type"s) || (key == "module_type"s) ||
697  (key == "module_label"s))) {
698  ++nparam;
699  }
700  }
701 
702  //
703  // Build the layout
704  //
705  fLayout = new TGTableLayout(fContainer, nparam, 2);
706  fContainer->SetLayoutManager(fLayout);
707 
708  for (std::size_t i = 0, j = 0; i < nkey; ++i) {
709  if (!((keys[i] == "service_type") || (keys[i] == "module_type") ||
710  (keys[i] == "module_label"))) {
711 
712  TGHorizontalFrame* lhs = new TGHorizontalFrame(fContainer);
713  TGHorizontalFrame* rhs = new TGHorizontalFrame(fContainer);
714 
715  TGTableLayoutHints* lhsh = new TGTableLayoutHints(0, 1, j, j + 1);
716  TGTableLayoutHints* rhsh = new TGTableLayoutHints(1, 2, j, j + 1);
717 
718  fContainer->AddFrame(lhs, lhsh);
719  fContainer->AddFrame(rhs, rhsh);
720 
721  fLHS.push_back(lhs);
722  fRHS.push_back(rhs);
723  fLHSHints.push_back(lhsh);
724  fRHSHints.push_back(rhsh);
725 
726  fRow.push_back(new ParameterSetEditRow(this, lhs, rhs, pset, keys[i]));
727  ++j;
728  }
729  }
730 
731  fCanvas->Connect("ProcessedEvent(Event_t*)",
732  "evdb::ParameterSetEditFrame",
733  this,
734  "HandleMouseWheel(Event_t*)");
735 
736  fCanvas->Resize();
737 }
static ServiceTable & Instance()
std::vector< ParameterSetEditRow * > fRow
Collection of Services used in the event display.
Definition: ServiceTable.h:36
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:101
std::vector< TGTableLayoutHints * > fRHSHints
std::vector< TGHorizontalFrame * > fLHS
std::vector< TGTableLayoutHints * > fLHSHints
std::vector< TGHorizontalFrame * > fRHS
A single row for editing a single parameter in a set.
std::vector< std::string > get_names() const
fhicl::ParameterSet const & GetParameterSet(unsigned int i) const
ParameterSetEditFrame::~ParameterSetEditFrame ( )

Definition at line 741 of file ParameterSetEditDialog.cxx.

References fCanvas, fCanvasH, fLayout, fLHS, fLHSHints, fRHS, fRHSHints, and fRow.

742 {
743  cet::for_all(fRow, std::default_delete<ParameterSetEditRow>{});
744  cet::for_all(fRHSHints, std::default_delete<TGTableLayoutHints>{});
745  cet::for_all(fLHSHints, std::default_delete<TGTableLayoutHints>{});
746  cet::for_all(fRHS, std::default_delete<TGHorizontalFrame>{});
747  cet::for_all(fLHS, std::default_delete<TGHorizontalFrame>{});
748  delete fLayout;
749  //
750  // Parent takes care of delete for fContainer, I think. Anyhow,
751  // trying to delete it causes a seg fault.
752  //
753  // delete fContainer;
754  delete fCanvasH;
755  delete fCanvas;
756 }
std::vector< ParameterSetEditRow * > fRow
std::vector< TGTableLayoutHints * > fRHSHints
std::vector< TGHorizontalFrame * > fLHS
std::vector< TGTableLayoutHints * > fLHSHints
std::vector< TGHorizontalFrame * > fRHS

Member Function Documentation

std::string ParameterSetEditFrame::AsFHICL ( ) const

Definition at line 809 of file ParameterSetEditDialog.cxx.

References fRow.

810 {
811  std::ostringstream s;
812  for (auto row : fRow) {
813  s << row->AsFHICL() << "\n";
814  }
815  return s.str();
816 }
std::vector< ParameterSetEditRow * > fRow
void ParameterSetEditFrame::Finalize ( )

Definition at line 799 of file ParameterSetEditDialog.cxx.

References fRow.

800 {
801  for (auto row : fRow) {
802  row->Finalize();
803  }
804 }
std::vector< ParameterSetEditRow * > fRow
void ParameterSetEditFrame::HandleMouseWheel ( Event_t *  event)

Definition at line 760 of file ParameterSetEditDialog.cxx.

References fCanvas.

761 {
762  // Handle mouse wheel to scroll.
763  if (event->fType != kButtonPress && event->fType != kButtonRelease)
764  return;
765 
766  Int_t page = 0;
767  if (event->fCode == kButton4 || event->fCode == kButton5) {
768  if (!fCanvas)
769  return;
770  if (fCanvas->GetContainer()->GetHeight())
771  page = Int_t(Float_t(fCanvas->GetViewPort()->GetHeight() *
772  fCanvas->GetViewPort()->GetHeight()) /
773  fCanvas->GetContainer()->GetHeight());
774  }
775 
776  if (event->fCode == kButton4) {
777  // scroll up
778  Int_t newpos = fCanvas->GetVsbPosition() - page;
779  if (newpos < 0)
780  newpos = 0;
781  fCanvas->SetVsbPosition(newpos);
782  }
783  if (event->fCode == kButton5) {
784  // scroll down
785  Int_t newpos = fCanvas->GetVsbPosition() + page;
786  fCanvas->SetVsbPosition(newpos);
787  }
788 }
Event finding and building.

Member Data Documentation

TGCanvas* evdb::ParameterSetEditFrame::fCanvas
TGLayoutHints* evdb::ParameterSetEditFrame::fCanvasH

Definition at line 184 of file ParameterSetEditDialog.h.

Referenced by ParameterSetEditFrame(), and ~ParameterSetEditFrame().

TGCompositeFrame* evdb::ParameterSetEditFrame::fContainer

Definition at line 185 of file ParameterSetEditDialog.h.

Referenced by ParameterSetEditFrame().

bool evdb::ParameterSetEditFrame::fIsModified

Definition at line 195 of file ParameterSetEditDialog.h.

Referenced by Modified().

TGTableLayout* evdb::ParameterSetEditFrame::fLayout

Definition at line 186 of file ParameterSetEditDialog.h.

Referenced by ParameterSetEditFrame(), and ~ParameterSetEditFrame().

std::vector<TGHorizontalFrame*> evdb::ParameterSetEditFrame::fLHS

Definition at line 187 of file ParameterSetEditDialog.h.

Referenced by ParameterSetEditFrame(), and ~ParameterSetEditFrame().

std::vector<TGTableLayoutHints*> evdb::ParameterSetEditFrame::fLHSHints

Definition at line 189 of file ParameterSetEditDialog.h.

Referenced by ParameterSetEditFrame(), and ~ParameterSetEditFrame().

unsigned int evdb::ParameterSetEditFrame::fParameterSetID

Definition at line 194 of file ParameterSetEditDialog.h.

std::vector<TGHorizontalFrame*> evdb::ParameterSetEditFrame::fRHS

Definition at line 188 of file ParameterSetEditDialog.h.

Referenced by ParameterSetEditFrame(), and ~ParameterSetEditFrame().

std::vector<TGTableLayoutHints*> evdb::ParameterSetEditFrame::fRHSHints

Definition at line 190 of file ParameterSetEditDialog.h.

Referenced by ParameterSetEditFrame(), and ~ParameterSetEditFrame().

std::vector<ParameterSetEditRow*> evdb::ParameterSetEditFrame::fRow
TGCompositeFrame* evdb::ParameterSetEditFrame::fTopFrame

Definition at line 182 of file ParameterSetEditDialog.h.


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