From 77db759035c142d829a6ef305521926063560306 Mon Sep 17 00:00:00 2001
From: Dave Casper <dcasper@uci.edu>
Date: Thu, 25 Jul 2019 14:15:00 -0700
Subject: [PATCH 1/2] Prototyping of tcl/tk geometry db editor

---
 .../GeoModel/FaserGeoEditor/CMakeLists.txt    | 44 +++++++++++++++++++
 .../FaserGeoEditor/src/FaserDbMainWindow.cxx  | 37 ++++++++++++++++
 .../FaserGeoEditor/src/FaserDbMainWindow.h    | 25 +++++++++++
 .../FaserGeoEditor/src/FaserGeoEditorApp.cxx  | 24 ++++++++++
 .../FaserGeoEditor/src/FaserGeoEditorApp.h    | 22 ++++++++++
 .../GeoModel/FaserGeoEditor/src/main.cxx      | 21 +++++++++
 6 files changed, 173 insertions(+)
 create mode 100644 DetectorDescription/GeoModel/FaserGeoEditor/CMakeLists.txt
 create mode 100644 DetectorDescription/GeoModel/FaserGeoEditor/src/FaserDbMainWindow.cxx
 create mode 100644 DetectorDescription/GeoModel/FaserGeoEditor/src/FaserDbMainWindow.h
 create mode 100644 DetectorDescription/GeoModel/FaserGeoEditor/src/FaserGeoEditorApp.cxx
 create mode 100644 DetectorDescription/GeoModel/FaserGeoEditor/src/FaserGeoEditorApp.h
 create mode 100644 DetectorDescription/GeoModel/FaserGeoEditor/src/main.cxx

diff --git a/DetectorDescription/GeoModel/FaserGeoEditor/CMakeLists.txt b/DetectorDescription/GeoModel/FaserGeoEditor/CMakeLists.txt
new file mode 100644
index 000000000..1ce8cc6df
--- /dev/null
+++ b/DetectorDescription/GeoModel/FaserGeoEditor/CMakeLists.txt
@@ -0,0 +1,44 @@
+################################################################################
+# Package: FaserGeoEdit
+################################################################################
+# Author: 
+# Author: 
+################################################################################
+
+# Declare the package name:
+atlas_subdir( FaserGeoEditor )
+
+# Declare the package's dependencies:
+#atlas_depends_on_subdirs(
+#   PUBLIC Event/xAOD/xAODBase
+#   PUBLIC graphics/VP1/VP1Base
+#   PUBLIC graphics/VP1/VP1UtilsBase 
+#   )
+
+# External dependencies:
+find_package( Qt5 COMPONENTS Core Sql OpenGL Gui Network PrintSupport Widgets REQUIRED )
+
+# Generate UI files automatically:
+set( CMAKE_AUTOUIC TRUE )
+# Generate MOC files automatically:
+set( CMAKE_AUTOMOC TRUE )
+# Generate resource files automatically:
+set( CMAKE_AUTORCC TRUE )
+
+# Component(s) in the package:
+#atlas_add_library( FaserGeoEditor FaserGeoEditor/*.h src/*.h src/*.cxx src/*.qrc
+#   PUBLIC_HEADERS FaserGeoEditor
+#   PRIVATE_INCLUDE_DIRS 
+#   ${CMAKE_CURRENT_BINARY_DIR}
+#   LINK_LIBRARIES Qt5::Core Qt5::OpenGL Qt5::Gui Qt5::PrintSupport
+#   PRIVATE_LINK_LIBRARIES PathResolver Qt5::Network )
+   
+
+atlas_add_executable( qtTest FaserGeoEditor/*.h src/*.cxx src/*.h
+   PRIVATE_INCLUDE_DIRS ${QT5_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR}
+   LINK_LIBRARIES Qt5::Core Qt5::Sql Qt5::OpenGL Qt5::Gui Qt5::Widgets Qt5::PrintSupport)
+
+# Install files from the package:
+##atlas_install_scripts( share/* ) # installs into bin/
+atlas_install_runtime( share/* ) # install into share/ //TODO: check if we still need this!
+   
diff --git a/DetectorDescription/GeoModel/FaserGeoEditor/src/FaserDbMainWindow.cxx b/DetectorDescription/GeoModel/FaserGeoEditor/src/FaserDbMainWindow.cxx
new file mode 100644
index 000000000..c605a3390
--- /dev/null
+++ b/DetectorDescription/GeoModel/FaserGeoEditor/src/FaserDbMainWindow.cxx
@@ -0,0 +1,37 @@
+#include "FaserDbMainWindow.h"
+
+#include <QTreeView>
+#include <QStandardItemModel>
+#include <QStandardItem>
+#include <iostream>
+
+FaserDbMainWindow::FaserDbMainWindow(QWidget* parent)
+    : QMainWindow(parent)
+    , m_treeView(new QTreeView(this))
+    , m_standardModel(new QStandardItemModel(this))
+{
+    setCentralWidget(m_treeView);
+
+    QStandardItem* root = m_standardModel->invisibleRootItem();
+    QList<QStandardItem*> firstRow = prepareRow("name 1", "leaf 1");
+    root->appendRow(firstRow);
+    QList<QStandardItem*> secondRow = prepareRow("name 2", "leaf 2");
+    root->appendRow(secondRow);
+    QList<QStandardItem*> subRow = prepareRow("subName 1", "subLeaf 1");
+    firstRow.first()->appendRow(subRow);
+
+    m_treeView->setModel(m_standardModel);
+    m_treeView->expandAll();
+}
+
+// FaserDbMainWindow::~FaserDbMainWindow()
+// {
+//     if (m_standardModel != nullptr) delete m_standardModel;
+//     if (m_treeView != nullptr) delete m_treeView;
+// }
+
+QList<QStandardItem*> FaserDbMainWindow::prepareRow(const QString& name, const QString& leaf) const
+{
+    return { new QStandardItem(name),
+             new QStandardItem(leaf)};
+}
\ No newline at end of file
diff --git a/DetectorDescription/GeoModel/FaserGeoEditor/src/FaserDbMainWindow.h b/DetectorDescription/GeoModel/FaserGeoEditor/src/FaserDbMainWindow.h
new file mode 100644
index 000000000..5b6cabbba
--- /dev/null
+++ b/DetectorDescription/GeoModel/FaserGeoEditor/src/FaserDbMainWindow.h
@@ -0,0 +1,25 @@
+// #ifndef GEOMODEL_FASERDBMAINWINDOW_H
+// #define GEOMODEL_FASERDBMAINWINDOW_H 1
+
+#include <QMainWindow>
+// #include <QtGui/QWidget>
+
+QT_BEGIN_NAMESPACE
+class QTreeView; //forward declarations
+class QStandardItemModel;
+class QStandardItem;
+QT_END_NAMESPACE
+
+class FaserDbMainWindow : public QMainWindow
+{
+    Q_OBJECT
+private:
+    QTreeView* m_treeView;
+    QStandardItemModel* m_standardModel;
+    QList<QStandardItem *> prepareRow(const QString& name, const QString& leaf) const;
+public:
+    FaserDbMainWindow(QWidget *parent = nullptr);
+    // virtual ~FaserDbMainWindow();
+};
+
+// #endif
\ No newline at end of file
diff --git a/DetectorDescription/GeoModel/FaserGeoEditor/src/FaserGeoEditorApp.cxx b/DetectorDescription/GeoModel/FaserGeoEditor/src/FaserGeoEditorApp.cxx
new file mode 100644
index 000000000..182cd6d53
--- /dev/null
+++ b/DetectorDescription/GeoModel/FaserGeoEditor/src/FaserGeoEditorApp.cxx
@@ -0,0 +1,24 @@
+#include <iostream>
+#include "FaserGeoEditorApp.h"
+
+FaserGeoEditorApp::FaserGeoEditorApp(int& argc, char** argv) 
+: m_application(argc, argv), m_database(QSqlDatabase::addDatabase("QSQLITE")), m_mainWindow()
+{ 
+// db file name should be first argument after command name; retrieve it
+    auto arguments = m_application.arguments();
+    auto dbName = arguments.at(1);
+    std::cout << "Database name: " << dbName.toLocal8Bit().constData() << std::endl;
+
+    m_database.setDatabaseName(dbName);
+    bool ok = m_database.open();
+    std::cout << "Database open status: " << ok << std::endl;
+
+    auto tables = m_database.tables();
+    for (auto it = tables.constBegin(); it != tables.constEnd(); ++it) std::cout << (*it).toLocal8Bit().constData() << std::endl;
+}
+
+int FaserGeoEditorApp::exec()
+{
+    m_mainWindow.show();
+    return m_application.exec();
+}
\ No newline at end of file
diff --git a/DetectorDescription/GeoModel/FaserGeoEditor/src/FaserGeoEditorApp.h b/DetectorDescription/GeoModel/FaserGeoEditor/src/FaserGeoEditorApp.h
new file mode 100644
index 000000000..da0b5bc02
--- /dev/null
+++ b/DetectorDescription/GeoModel/FaserGeoEditor/src/FaserGeoEditorApp.h
@@ -0,0 +1,22 @@
+#ifndef GEOMODEL_FASERGEOEDITORAPP_H
+#define GEOMODEL_FASERGEOEDITORAPP_H
+
+#include <QStringList>
+#include <QApplication>
+#include <QSqlDatabase>
+#include "FaserDbMainWindow.h"
+
+class FaserGeoEditorApp
+{
+    public:
+        FaserGeoEditorApp(int& argc, char** argv);
+
+        int exec();
+        QSqlDatabase& getDatabase() { return m_database; }
+    private:
+        QApplication m_application;
+        QSqlDatabase m_database;
+        FaserDbMainWindow m_mainWindow;
+};
+
+#endif
\ No newline at end of file
diff --git a/DetectorDescription/GeoModel/FaserGeoEditor/src/main.cxx b/DetectorDescription/GeoModel/FaserGeoEditor/src/main.cxx
new file mode 100644
index 000000000..d9ee9d7ae
--- /dev/null
+++ b/DetectorDescription/GeoModel/FaserGeoEditor/src/main.cxx
@@ -0,0 +1,21 @@
+// main.cpp
+#include "FaserGeoEditorApp.h"
+// #include <QTableView>
+// #include <QStringList>
+// #include <QSqlDatabase>
+// #include <iostream>
+// #include "mymodel.h"
+
+int main(int argc, char *argv[])
+{
+    FaserGeoEditorApp a(argc, argv);
+    // QApplication a(argc, argv);
+
+    // QTableView tableView;
+    // MyModel myModel;
+    // tableView.setModel(&myModel);
+    // tableView.show();
+    // FaserDbMainWindow w;
+    // w.show();
+    return a.exec();
+}
-- 
GitLab


From 9d2699addec9e0d6cb125d28ca420721ed781ea0 Mon Sep 17 00:00:00 2001
From: Dave Casper <dcasper@uci.edu>
Date: Mon, 26 Aug 2019 10:46:58 -0700
Subject: [PATCH 2/2] Fix omitted initializations

---
 .../ScintReadoutGeometry/ScintDetectorDesign.h            | 2 +-
 .../ScintReadoutGeometry/src/ScintDetectorDesign.cxx      | 8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/Scintillator/ScintDetDescr/ScintReadoutGeometry/ScintReadoutGeometry/ScintDetectorDesign.h b/Scintillator/ScintDetDescr/ScintReadoutGeometry/ScintReadoutGeometry/ScintDetectorDesign.h
index b5ab7ac1b..c04fb9d24 100644
--- a/Scintillator/ScintDetDescr/ScintReadoutGeometry/ScintReadoutGeometry/ScintDetectorDesign.h
+++ b/Scintillator/ScintDetDescr/ScintReadoutGeometry/ScintReadoutGeometry/ScintDetectorDesign.h
@@ -152,10 +152,10 @@ private:
     double m_length;    // !< dimnesion in "eta" direction
     int    m_cells;     // !< number of pmts
 
+    ScintDetectorDesign::Edge m_readoutSide;
     ScintDetectorDesign::Axis m_phiAxis;  // which axis in hit frame corresponds to photon flight direction?
     ScintDetectorDesign::Axis m_etaAxis;  // which axis in hit frame is normal to photon flight direction?
     ScintDetectorDesign::Axis m_depthAxis; // which axis in hit frame is depth?
-    ScintDetectorDesign::Edge m_readoutSide;
 
     const Trk::RectangleBounds* m_bounds;
 
diff --git a/Scintillator/ScintDetDescr/ScintReadoutGeometry/src/ScintDetectorDesign.cxx b/Scintillator/ScintDetDescr/ScintReadoutGeometry/src/ScintDetectorDesign.cxx
index fa69388db..3c167351f 100644
--- a/Scintillator/ScintDetDescr/ScintReadoutGeometry/src/ScintDetectorDesign.cxx
+++ b/Scintillator/ScintDetDescr/ScintReadoutGeometry/src/ScintDetectorDesign.cxx
@@ -36,9 +36,13 @@ ScintDetectorDesign::ScintDetectorDesign( const double thickness,
                                           const ScintDetectorDesign::Axis photonDirection,
                                           const ScintDetectorDesign::Axis thicknessDirection ) :
     m_thickness(thickness),
+    m_width{width},
+    m_length{length},
+    m_cells{cells},
+    m_readoutSide(readoutSide),
     m_phiAxis(photonDirection),  /* same as ATLAS SCT for now */
-    m_depthAxis(thicknessDirection),
-    m_readoutSide(readoutSide) {
+    m_depthAxis(thicknessDirection)
+{
         m_etaAxis = static_cast<Axis> ((xAxis + yAxis + zAxis) - (photonDirection + thicknessDirection)); 
         m_bounds = new Trk::RectangleBounds(0.5*width, 0.5*length);
 }
-- 
GitLab