Skip to content
Snippets Groups Projects
Commit 4cb64bdf authored by calrama's avatar calrama
Browse files

Add and enforce formating style

parent fb47ed5f
No related branches found
No related tags found
No related merge requests found
Pipeline #62074 passed
Pipeline: backgroundsubtraction_tracker

#62077

    Pipeline: biotracker

    #62076

      ---
      Language: Cpp
      Standard: Cpp11
      UseTab: Never
      TabWidth: 4
      IndentWidth: 4
      AccessModifierOffset: -4
      ContinuationIndentWidth: 4
      ColumnLimit: 79
      ConstructorInitializerIndentWidth: 0
      BinPackArguments: false
      BinPackParameters: false
      AlignAfterOpenBracket: Align
      AlignConsecutiveAssignments: true
      AlignConsecutiveDeclarations: true
      AlignOperands: true
      AlignEscapedNewlines: Right
      AlignTrailingComments: true
      AllowAllArgumentsOnNextLine: false
      AllowAllConstructorInitializersOnNextLine: false
      ConstructorInitializerAllOnOneLineOrOnePerLine: false
      AllowAllParametersOfDeclarationOnNextLine: false
      AllowShortBlocksOnASingleLine: false
      AllowShortCaseLabelsOnASingleLine: false
      AllowShortFunctionsOnASingleLine: None
      AllowShortIfStatementsOnASingleLine: Never
      AllowShortLoopsOnASingleLine: false
      AlwaysBreakAfterReturnType: None
      AlwaysBreakBeforeMultilineStrings: true
      AlwaysBreakTemplateDeclarations: Yes
      BreakBeforeBraces: Custom
      BraceWrapping:
      AfterClass: true
      AfterControlStatement: false
      AfterEnum: true
      AfterFunction: true
      AfterNamespace: true
      AfterObjCDeclaration: true
      AfterStruct: true
      AfterUnion: true
      AfterExternBlock: true
      BeforeCatch: false
      BeforeElse: false
      IndentBraces: false
      SplitEmptyFunction: true
      SplitEmptyRecord: true
      SplitEmptyNamespace: true
      BreakBeforeBinaryOperators: None
      BreakBeforeInheritanceComma: false
      BreakInheritanceList: BeforeColon
      BreakBeforeTernaryOperators: true
      BreakConstructorInitializers: BeforeComma
      BreakAfterJavaFieldAnnotations: false
      BreakStringLiterals: true
      CompactNamespaces: false
      Cpp11BracedListStyle: true
      DerivePointerAlignment: false
      DisableFormat: false
      ExperimentalAutoDetectBinPacking: false
      FixNamespaceComments: false
      IndentCaseLabels: false
      IndentPPDirectives: BeforeHash
      IndentWrappedFunctionNames: true
      KeepEmptyLinesAtTheStartOfBlocks: true
      MaxEmptyLinesToKeep: 1
      NamespaceIndentation: All
      PointerAlignment: Left
      ReflowComments: true
      SortIncludes: false
      SortUsingDeclarations: true
      SpaceAfterCStyleCast: true
      SpaceAfterTemplateKeyword: false
      SpaceBeforeAssignmentOperators: true
      SpaceBeforeCpp11BracedList: false
      SpaceBeforeCtorInitializerColon: true
      SpaceBeforeInheritanceColon: true
      SpaceBeforeParens: ControlStatements
      SpaceBeforeRangeBasedForLoopColon: true
      SpaceInEmptyParentheses: false
      SpacesBeforeTrailingComments: 1
      SpacesInAngles: false
      SpacesInContainerLiterals: false
      SpacesInCStyleCastParentheses: false
      SpacesInParentheses: false
      SpacesInSquareBrackets: false
      PenaltyBreakAssignment: 100
      PenaltyBreakBeforeFirstCallParameter: 19
      PenaltyBreakComment: 300
      PenaltyBreakFirstLessLess: 120
      PenaltyBreakString: 1000
      PenaltyBreakTemplateDeclaration: 10
      PenaltyExcessCharacter: 1000000
      PenaltyReturnTypeOnItsOwnLine: 1000
      CommentPragmas: ''
      MacroBlockBegin: ''
      MacroBlockEnd: ''
      ForEachMacros:
      - foreach
      - Q_FOREACH
      - BOOST_FOREACH
      StatementMacros:
      - Q_UNUSED
      - QT_REQUIRE_VERSION
      ...
      root = true
      [*]
      charset = utf-8
      end_of_line = lf
      trim_trailing_whitespace = true
      insert_final_newline = true
      [*.{c,h,cc,hh,cpp,hpp,cxx,hxx}]
      indent_style = space
      indent_size = 4
      [*.py]
      indent_style = space
      indent_size = 4
      [*.yml]
      indent_style = space
      indent_size = 2
      #include "IConfig.h" #include "IConfig.h"
      #include <QStandardPaths> #include <QStandardPaths>
      QString IConfig::configLocation = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation); QString IConfig::configLocation = QStandardPaths::writableLocation(
      QString IConfig::dataLocation = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); QStandardPaths::AppConfigLocation);
      QString IConfig::dataLocation = QStandardPaths::writableLocation(
      QStandardPaths::AppDataLocation);
      cv::Mat IConfig::asMat(QString str){ cv::Mat IConfig::asMat(QString str)
      {
      return asMat(str.toStdString()); return asMat(str.toStdString());
      } }
      std::vector<std::string> explode(std::string const & s, char delim) std::vector<std::string> explode(std::string const& s, char delim)
      { {
      std::vector<std::string> result; std::vector<std::string> result;
      std::istringstream iss(s); std::istringstream iss(s);
      for (std::string token; std::getline(iss, token, delim); ) for (std::string token; std::getline(iss, token, delim);) {
      { result.push_back(std::move(token));
      result.push_back(std::move(token)); }
      }
      return result; return result;
      } }
      cv::Mat IConfig::asMat(std::string str){ cv::Mat IConfig::asMat(std::string str)
      std::vector<std::string> row = explode(str, ';'); {
      std::vector<std::string> row = explode(str, ';');
      std::vector<std::string> cols = explode(row[0], '#'); std::vector<std::string> cols = explode(row[0], '#');
      cv::Mat m(row.size(), cols.size(), CV_32F); cv::Mat m(row.size(), cols.size(), CV_32F);
      ...@@ -37,15 +40,16 @@ cv::Mat IConfig::asMat(std::string str){ ...@@ -37,15 +40,16 @@ cv::Mat IConfig::asMat(std::string str){
      return m; return m;
      }; };
      std::string IConfig::asStdString(cv::Mat m)
      std::string IConfig::asStdString(cv::Mat m){ {
      return asQString(m).toStdString(); return asQString(m).toStdString();
      } }
      QString IConfig::asQString(cv::Mat m){ QString IConfig::asQString(cv::Mat m)
      {
      std::string result; std::string result;
      int w = m.size().width; int w = m.size().width;
      int h = m.size().height; int h = m.size().height;
      for (int i = 0; i < h; i++) { for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) { for (int j = 0; j < w; j++) {
      result += std::to_string(m.at<float>(i, j)); result += std::to_string(m.at<float>(i, j));
      ...@@ -56,4 +60,3 @@ QString IConfig::asQString(cv::Mat m){ ...@@ -56,4 +60,3 @@ QString IConfig::asQString(cv::Mat m){
      } }
      return QString(result.c_str()); return QString(result.c_str());
      }; };
      ...@@ -2,18 +2,17 @@ ...@@ -2,18 +2,17 @@
      #include <QString> #include <QString>
      #include <opencv2/opencv.hpp> #include <opencv2/opencv.hpp>
      class IConfig class IConfig
      { {
      public: public:
      static QString configLocation; static QString configLocation;
      static QString dataLocation; static QString dataLocation;
      virtual void load(QString dir, QString file = "sampleConfig.ini") = 0; virtual void load(QString dir, QString file = "sampleConfig.ini") = 0;
      virtual void save(QString dir, QString file) = 0; virtual void save(QString dir, QString file) = 0;
      static cv::Mat asMat(QString str); static cv::Mat asMat(QString str);
      static cv::Mat asMat(std::string str); static cv::Mat asMat(std::string str);
      static std::string asStdString(cv::Mat m); static std::string asStdString(cv::Mat m);
      static QString asQString(cv::Mat m); static QString asQString(cv::Mat m);
      }; };
      ...@@ -5,32 +5,34 @@ ...@@ -5,32 +5,34 @@
      TrackedComponentFactory::TrackedComponentFactory() TrackedComponentFactory::TrackedComponentFactory()
      { {
      } }
      TrackedComponentFactory::~TrackedComponentFactory() TrackedComponentFactory::~TrackedComponentFactory()
      { {
      } }
      QList<QString> TrackedComponentFactory::getElementTypes() { QList<QString> TrackedComponentFactory::getElementTypes()
      return QList<QString>{ "TrackedElement" }; {
      return QList<QString>{"TrackedElement"};
      } }
      IModelTrackedComponent *TrackedComponentFactory::createTrackedElement(QString name) IModelTrackedComponent* TrackedComponentFactory::createTrackedElement(
      QString name)
      { {
      return new TrackedElement(this, "n.a."); return new TrackedElement(this, "n.a.");
      } }
      IModelTrackedComponent *TrackedComponentFactory::createTrackedObject(QString name) IModelTrackedComponent* TrackedComponentFactory::createTrackedObject(
      QString name)
      { {
      TrackedTrajectory *t = new TrackedTrajectory(); TrackedTrajectory* t = new TrackedTrajectory();
      TrackedElement *e = new TrackedElement(this, "n.a.", 0); TrackedElement* e = new TrackedElement(this, "n.a.", 0);
      t->add(e, 0); t->add(e, 0);
      return t; return t;
      } }
      IModelTrackedComponent *TrackedComponentFactory::createTrackedTrajectory(QString name) IModelTrackedComponent* TrackedComponentFactory::createTrackedTrajectory(
      QString name)
      { {
      return new TrackedTrajectory(); return new TrackedTrajectory();
      } }
      ...@@ -12,8 +12,9 @@ public: ...@@ -12,8 +12,9 @@ public:
      virtual QList<QString> getElementTypes() override; virtual QList<QString> getElementTypes() override;
      // ITrackedComponentFactory interface // ITrackedComponentFactory interface
      protected: protected:
      virtual IModelTrackedComponent *createTrackedElement(QString name) override; virtual IModelTrackedComponent* createTrackedElement(
      virtual IModelTrackedComponent *createTrackedObject(QString name) override; QString name) override;
      virtual IModelTrackedComponent *createTrackedTrajectory(QString name) override; virtual IModelTrackedComponent* createTrackedObject(QString name) override;
      virtual IModelTrackedComponent* createTrackedTrajectory(
      QString name) override;
      }; };
      ...@@ -4,73 +4,79 @@ ...@@ -4,73 +4,79 @@
      #include "QBrush" #include "QBrush"
      #include "QPainter" #include "QPainter"
      TrackedElement::TrackedElement(QObject *parent, QString name, int id) : TrackedElement::TrackedElement(QObject* parent, QString name, int id)
      IModelTrackedPoint(parent), : IModelTrackedPoint(parent)
      _name(name), , _name(name)
      _id(id) , _id(id)
      { {
      _x = 0; _x = 0;
      _y = 0; _y = 0;
      _xpx = 0; _xpx = 0;
      _xpx = 0; _xpx = 0;
      _valid = false; _valid = false;
      _fixed = false; _fixed = false;
      _coordU = "px"; _coordU = "px";
      } }
      QString TrackedElement::getName() QString TrackedElement::getName()
      { {
      return _name; return _name;
      } }
      void TrackedElement::setPoint(cv::Point2f p) void TrackedElement::setPoint(cv::Point2f p)
      { {
      _x = p.x; _x = p.x;
      _y = p.y; _y = p.y;
      _valid = true; _valid = true;
      Q_EMIT notifyView(); Q_EMIT notifyView();
      } }
      cv::Point2f TrackedElement::getPoint() cv::Point2f TrackedElement::getPoint()
      { {
      return cv::Point2f(_x, _y); return cv::Point2f(_x, _y);
      } }
      void TrackedElement::setX(float val) { void TrackedElement::setX(float val)
      _x = val; {
      _x = val;
      }; };
      void TrackedElement::setY(float val) { void TrackedElement::setY(float val)
      _y = val; {
      _y = val;
      }; };
      void TrackedElement::setXpx(float val) { void TrackedElement::setXpx(float val)
      _xpx = val; {
      _xpx = val;
      }; };
      void TrackedElement::setYpx(float val) { void TrackedElement::setYpx(float val)
      _ypx = val; {
      _ypx = val;
      }; };
      float TrackedElement::getX() { float TrackedElement::getX()
      {
      return _x; return _x;
      } }
      float TrackedElement::getY() { float TrackedElement::getY()
      {
      return _y; return _y;
      } }
      float TrackedElement::getXpx() { float TrackedElement::getXpx()
      {
      return _xpx; return _xpx;
      } }
      float TrackedElement::getYpx() { float TrackedElement::getYpx()
      {
      return _ypx; return _ypx;
      } }
      void TrackedElement::operate() void TrackedElement::operate()
      { {
      qDebug() << "I am TrackedElement " << _name; qDebug() << "I am TrackedElement " << _name;
      } }
      ...@@ -8,103 +8,189 @@ ...@@ -8,103 +8,189 @@
      #include <ctime> #include <ctime>
      /** /**
      * This class is an example of how a TrackedComponent could be defined. * This class is an example of how a TrackedComponent could be defined.
      * This class inherits from the IModelTrackedComponent class and is therefor part of the Composite Pattern. * This class inherits from the IModelTrackedComponent class and is therefor
      * This class represents the Leaf class in the Composite Pattern. * part of the Composite Pattern. This class represents the Leaf class in the
      * Objects of this class have a QObject as parent. * Composite Pattern. Objects of this class have a QObject as parent.
      */ */
      class TrackedElement : public IModelTrackedPoint class TrackedElement : public IModelTrackedPoint
      { {
      Q_OBJECT Q_OBJECT
      public: public:
      TrackedElement(QObject *parent = 0, QString name = "n.a.", int id = 0); TrackedElement(QObject* parent = 0, QString name = "n.a.", int id = 0);
      virtual ~TrackedElement() {}; virtual ~TrackedElement(){};
      virtual QString getName(); virtual QString getName();
      virtual QString getCoordinateUnit() override { return _coordU; }; virtual QString getCoordinateUnit() override
      {
      virtual void setCoordinateUnit(QString unit) override { _coordU = unit; }; return _coordU;
      };
      virtual void setCoordinateUnit(QString unit) override
      {
      _coordU = unit;
      };
      virtual void setX(float val) override; virtual void setX(float val) override;
      virtual void setY(float val) override; virtual void setY(float val) override;
      virtual void setW(float w) override {}; virtual void setW(float w) override{};
      virtual void setH(float h) override {}; virtual void setH(float h) override{};
      virtual void setXpx(float val) override; virtual void setXpx(float val) override;
      virtual void setYpx(float val) override; virtual void setYpx(float val) override;
      virtual void setWpx(float w) override {}; virtual void setWpx(float w) override{};
      virtual void setHpx(float h) override {}; virtual void setHpx(float h) override{};
      virtual void setRad(float r) override {}; virtual void setRad(float r) override{};
      virtual void setDeg(float d) override{}; virtual void setDeg(float d) override{};
      virtual void setId(int val) override { _id = val; }; virtual void setId(int val) override
      virtual void setTime(std::chrono::system_clock::time_point t) { {
      _id = val;
      };
      virtual void setTime(std::chrono::system_clock::time_point t)
      {
      _timeSysclck = t; _timeSysclck = t;
      }; };
      virtual void setTime(qint64 t) override { virtual void setTime(qint64 t) override
      long long ll = t / 1000; {
      long long ll = t / 1000;
      std::time_t tm(ll); std::time_t tm(ll);
      _timeSysclck = std::chrono::system_clock::from_time_t(tm); _timeSysclck = std::chrono::system_clock::from_time_t(tm);
      }; };
      virtual void setTimeString(QString t) override { _timeString = t; }; virtual void setTimeString(QString t) override
      virtual void setValid(bool v) override { _valid = v; }; {
      virtual void setFixed(bool f) override { _fixed = f; }; _timeString = t;
      };
      virtual void setValid(bool v) override
      {
      _valid = v;
      };
      virtual void setFixed(bool f) override
      {
      _fixed = f;
      };
      virtual float getX() override; virtual float getX() override;
      virtual float getY() override; virtual float getY() override;
      virtual float getXpx() override; virtual float getXpx() override;
      virtual float getYpx() override; virtual float getYpx() override;
      virtual float getW() override { return 0; }; virtual float getW() override
      virtual float getH() override { return 0; }; {
      virtual float getWpx() override { return 0; }; return 0;
      virtual float getHpx() override { return 0; }; };
      virtual float getRad() override { return 0; }; virtual float getH() override
      virtual float getDeg() override { return 0; }; {
      virtual int getId() override { return _id; }; return 0;
      virtual qint64 getTime() override { };
      qint64 q(std::chrono::duration_cast<std::chrono::milliseconds>(_timeSysclck.time_since_epoch()).count()); virtual float getWpx() override
      {
      return 0;
      };
      virtual float getHpx() override
      {
      return 0;
      };
      virtual float getRad() override
      {
      return 0;
      };
      virtual float getDeg() override
      {
      return 0;
      };
      virtual int getId() override
      {
      return _id;
      };
      virtual qint64 getTime() override
      {
      qint64 q(std::chrono::duration_cast<std::chrono::milliseconds>(
      _timeSysclck.time_since_epoch())
      .count());
      return q; return q;
      }; };
      virtual QString getTimeString() override { virtual QString getTimeString() override
      {
      std::time_t t = std::chrono::system_clock::to_time_t(_timeSysclck); std::time_t t = std::chrono::system_clock::to_time_t(_timeSysclck);
      QDateTime dt; QDateTime dt;
      dt.setTime_t(t); dt.setTime_t(t);
      _timeString = dt.toString(); _timeString = dt.toString();
      return _timeString; return _timeString;
      }; };
      virtual bool getValid() override { return _valid; }; virtual bool getValid() override
      virtual bool getFixed() override { return _fixed; }; {
      return _valid;
      };
      virtual bool getFixed() override
      {
      return _fixed;
      };
      virtual bool hasX() override { return true; }; virtual bool hasX() override
      virtual bool hasY() override { return true; }; {
      virtual bool hasW() override { return false; }; return true;
      virtual bool hasH() override { return false; }; };
      virtual bool hasXpx() override { return false; }; virtual bool hasY() override
      virtual bool hasYpx() override { return false; }; {
      virtual bool hasWpx() override { return false; }; return true;
      virtual bool hasHpx() override { return false; }; };
      virtual bool hasRad() override { return false; }; virtual bool hasW() override
      virtual bool hasDeg() override { return false; }; {
      virtual bool hasTime() override { return true; }; return false;
      virtual bool hasTimeString() override { return true; }; };
      virtual bool hasH() override
      {
      return false;
      };
      virtual bool hasXpx() override
      {
      return false;
      };
      virtual bool hasYpx() override
      {
      return false;
      };
      virtual bool hasWpx() override
      {
      return false;
      };
      virtual bool hasHpx() override
      {
      return false;
      };
      virtual bool hasRad() override
      {
      return false;
      };
      virtual bool hasDeg() override
      {
      return false;
      };
      virtual bool hasTime() override
      {
      return true;
      };
      virtual bool hasTimeString() override
      {
      return true;
      };
      virtual void setPoint(cv::Point2f p); virtual void setPoint(cv::Point2f p);
      virtual cv::Point2f getPoint(); virtual cv::Point2f getPoint();
      // ITrackedPoint interface // ITrackedPoint interface
      public: public:
      void operate() override; void operate() override;
      private: private:
      std::chrono::system_clock::time_point _timeSysclck; std::chrono::system_clock::time_point _timeSysclck;
      QString _name; QString _name;
      QString _timeString; /**< timestamp a formatted as string */ QString _timeString; /**< timestamp a formatted as string */
      float _x; float _x;
      float _y; float _y;
      float _xpx; float _xpx;
      float _ypx; float _ypx;
      int _id; int _id;
      bool _valid; bool _valid;
      bool _fixed; bool _fixed;
      QString _coordU; QString _coordU;
      }; };
      ...@@ -2,48 +2,47 @@ ...@@ -2,48 +2,47 @@
      #include "QDebug" #include "QDebug"
      #include "TrackedElement.h" #include "TrackedElement.h"
      TrackedTrajectory::TrackedTrajectory(QObject *parent, QString name) : TrackedTrajectory::TrackedTrajectory(QObject* parent, QString name)
      IModelTrackedTrajectory(parent), : IModelTrackedTrajectory(parent)
      name(name) , name(name)
      { {
      setFixed(false); setFixed(false);
      setValid(true); setValid(true);
      } }
      void TrackedTrajectory::operate() void TrackedTrajectory::operate()
      { {
      qDebug() << "Printing all TrackedElements in TrackedObject " << name; qDebug() << "Printing all TrackedElements in TrackedObject " << name;
      qDebug() << "========================= Begin =========================="; qDebug() << "========================= Begin ==========================";
      for (int i = 0; i < _TrackedComponents.size(); ++i) { for (int i = 0; i < _TrackedComponents.size(); ++i) {
      dynamic_cast<TrackedElement *>(_TrackedComponents.at(i))->operate(); dynamic_cast<TrackedElement*>(_TrackedComponents.at(i))->operate();
      } }
      qDebug() << "======================== End ========================="; qDebug() << "======================== End =========================";
      } }
      void TrackedTrajectory::add(IModelTrackedComponent *comp, int pos) void TrackedTrajectory::add(IModelTrackedComponent* comp, int pos)
      { {
      if (pos < 0) { if (pos < 0) {
      _TrackedComponents.append(comp); _TrackedComponents.append(comp);
      } } else if (_TrackedComponents.size() <= pos) {
      else if (_TrackedComponents.size() <= pos) { while (_TrackedComponents.size() < pos)
      while (_TrackedComponents.size() < pos) _TrackedComponents.append(0);
      _TrackedComponents.append(0);
      _TrackedComponents.append(comp); _TrackedComponents.append(comp);
      } } else {
      else { _TrackedComponents[pos] = comp;
      _TrackedComponents[pos] = comp; }
      }
      } }
      bool TrackedTrajectory::remove(IModelTrackedComponent *comp) bool TrackedTrajectory::remove(IModelTrackedComponent* comp)
      { {
      return _TrackedComponents.removeOne(comp); //Do not actually remove, just invalidate / replace by dummy return _TrackedComponents.removeOne(
      comp); // Do not actually remove, just invalidate / replace by dummy
      } }
      void TrackedTrajectory::clear() void TrackedTrajectory::clear()
      { {
      foreach(IModelTrackedComponent* el, _TrackedComponents) { foreach (IModelTrackedComponent* el, _TrackedComponents) {
      if (dynamic_cast<IModelTrackedTrajectory*>(el)) if (dynamic_cast<IModelTrackedTrajectory*>(el))
      dynamic_cast<IModelTrackedTrajectory*>(el)->clear(); dynamic_cast<IModelTrackedTrajectory*>(el)->clear();
      } }
      ...@@ -52,18 +51,19 @@ void TrackedTrajectory::clear() ...@@ -52,18 +51,19 @@ void TrackedTrajectory::clear()
      IModelTrackedComponent* TrackedTrajectory::getChild(int index) IModelTrackedComponent* TrackedTrajectory::getChild(int index)
      { {
      return (_TrackedComponents.size() > index ? _TrackedComponents.at(index) : nullptr); return (_TrackedComponents.size() > index ? _TrackedComponents.at(index)
      : nullptr);
      } }
      IModelTrackedComponent* TrackedTrajectory::getLastChild() IModelTrackedComponent* TrackedTrajectory::getLastChild()
      { {
      return _TrackedComponents.at(_TrackedComponents.size()-1); return _TrackedComponents.at(_TrackedComponents.size() - 1);
      } }
      IModelTrackedComponent* TrackedTrajectory::getValidChild(int index) IModelTrackedComponent* TrackedTrajectory::getValidChild(int index)
      { {
      int c = 0; int c = 0;
      foreach(IModelTrackedComponent* el, _TrackedComponents) { foreach (IModelTrackedComponent* el, _TrackedComponents) {
      if (el) { if (el) {
      if (c == index && el->getValid()) if (c == index && el->getValid())
      return el; return el;
      ...@@ -82,7 +82,7 @@ int TrackedTrajectory::size() ...@@ -82,7 +82,7 @@ int TrackedTrajectory::size()
      int TrackedTrajectory::validCount() int TrackedTrajectory::validCount()
      { {
      int c = 0; int c = 0;
      foreach(IModelTrackedComponent* el, _TrackedComponents){ foreach (IModelTrackedComponent* el, _TrackedComponents) {
      if (el) if (el)
      c += el->getValid() ? 1 : 0; c += el->getValid() ? 1 : 0;
      } }
      ......
      ...@@ -5,50 +5,52 @@ ...@@ -5,50 +5,52 @@
      #include "QString" #include "QString"
      /** /**
      * This class inherits from the IModelTrackedTrajectory class and is therefor part of the Composite Pattern. * This class inherits from the IModelTrackedTrajectory class and is therefor
      * This class represents the Composite class. * part of the Composite Pattern. This class represents the Composite class.
      * This class is responsibility for the handling of Leaf objects. * This class is responsibility for the handling of Leaf objects.
      * Internaly this class uses a QList for storing Leaf object. * Internaly this class uses a QList for storing Leaf object.
      * *
      * Objects of this class have a QObject as parent. * Objects of this class have a QObject as parent.
      */ */
      class TrackedTrajectory : public IModelTrackedTrajectory { class TrackedTrajectory : public IModelTrackedTrajectory
      Q_OBJECT {
      Q_OBJECT
      public: public:
      TrackedTrajectory(QObject *parent = 0, QString name = "n.a."); TrackedTrajectory(QObject* parent = 0, QString name = "n.a.");
      virtual ~TrackedTrajectory() {}; virtual ~TrackedTrajectory(){};
      // ITrackedComponent interface // ITrackedComponent interface
      public: public:
      void operate() override; void operate() override;
      // ITrackedObject interface // ITrackedObject interface
      public: public:
      virtual void add(IModelTrackedComponent *comp, int pos = -1) override; virtual void add(IModelTrackedComponent* comp, int pos = -1) override;
      virtual bool remove(IModelTrackedComponent *comp) override; virtual bool remove(IModelTrackedComponent* comp) override;
      virtual void clear() override; virtual void clear() override;
      virtual IModelTrackedComponent *getChild(int index) override; virtual IModelTrackedComponent* getChild(int index) override;
      virtual IModelTrackedComponent *getValidChild(int index) override; virtual IModelTrackedComponent* getValidChild(int index) override;
      virtual IModelTrackedComponent *getLastChild() override; virtual IModelTrackedComponent* getLastChild() override;
      virtual int size() override; virtual int size() override;
      virtual int validCount() override; virtual int validCount() override;
      virtual QList<IModelTrackedComponent*> getChildNodes() override { virtual QList<IModelTrackedComponent*> getChildNodes() override
      {
      return _TrackedComponents; return _TrackedComponents;
      } }
      virtual void setChildNodes(QList<IModelTrackedComponent*> n) override { virtual void setChildNodes(QList<IModelTrackedComponent*> n) override
      {
      _TrackedComponents = n; _TrackedComponents = n;
      } }
      virtual bool hasChildNodes() override { virtual bool hasChildNodes() override
      {
      return !_TrackedComponents.empty(); return !_TrackedComponents.empty();
      } }
      protected: protected:
      QList<IModelTrackedComponent*> _TrackedComponents; QList<IModelTrackedComponent*> _TrackedComponents;
      QString name; QString name;
      }; };
      #include "Utility/misc.h" #include "Utility/misc.h"
      #include <QPoint> // QPoint #include <QPoint> // QPoint
      #include <QString> #include <QString>
      #include <QStringList> #include <QStringList>
      #include <QCoreApplication> #include <QCoreApplication>
      int BioTrackerUtilsMisc::split(std::string &txt, std::vector<std::string> &strs, char ch) int BioTrackerUtilsMisc::split(std::string& txt,
      std::vector<std::string>& strs,
      char ch)
      { {
      std::string::size_type pos = txt.find(ch); std::string::size_type pos = txt.find(ch);
      std::string::size_type initialPos = 0; std::string::size_type initialPos = 0;
      strs.clear(); strs.clear();
      // Decompose statement // Decompose statement
      while (pos != std::string::npos) { while (pos != std::string::npos) {
      strs.push_back(txt.substr(initialPos, pos - initialPos)); strs.push_back(txt.substr(initialPos, pos - initialPos));
      initialPos = pos + 1; initialPos = pos + 1;
      pos = txt.find(ch, initialPos); pos = txt.find(ch, initialPos);
      } }
      // Add the last one // Add the last one
      strs.push_back(txt.substr(initialPos, std::min(pos, txt.size()) - initialPos + 1)); strs.push_back(
      txt.substr(initialPos, std::min(pos, txt.size()) - initialPos + 1));
      return strs.size(); return strs.size();
      } }
      std::string BioTrackerUtilsMisc::getTimeAndDate(std::string prefix, std::string suffix) std::string BioTrackerUtilsMisc::getTimeAndDate(std::string prefix,
      std::string suffix)
      { {
      // time_t timetitle; // time_t timetitle;
      // std::string timeInfo = prefix; // std::string timeInfo = prefix;
      // time(&timetitle); // time(&timetitle);
      // std::string t = ctime(&timetitle); // std::string t = ctime(&timetitle);
      // for (int i = 0; i < t.size(); i++) // for (int i = 0; i < t.size(); i++)
      // if (t[i] == ' ' || t[i] == ':') // if (t[i] == ' ' || t[i] == ':')
      // t[i] = '_'; // t[i] = '_';
      // timeInfo += t.substr(0, t.size() - 1); // timeInfo += t.substr(0, t.size() - 1);
      // timeInfo += suffix; // timeInfo += suffix;
      // return timeInfo; // return timeInfo;
      time_t rawtime; time_t rawtime;
      struct tm * timeinfo; struct tm* timeinfo;
      time ( &rawtime ); time(&rawtime);
      timeinfo = localtime ( &rawtime ); timeinfo = localtime(&rawtime);
      char t[30]; char t[30];
      strftime(t, 30, "%Y-%m-%dT%H_%M_%S", timeinfo); // strftime(t, 30, "%Y-%m-%dT%H_%M_%S", timeinfo); //
      std::string out = prefix; std::string out = prefix;
      std::string timeStampF(t); std::string timeStampF(t);
      out += timeStampF; out += timeStampF;
      out += "_"; out += "_";
      out += std::to_string(QCoreApplication::applicationPid()); out += std::to_string(QCoreApplication::applicationPid());
      out += suffix; out += suffix;
      return out; return out;
      } }
      std::vector<cv::Point> BioTrackerUtilsMisc::stringToCVPointVec(std::string arena) { std::vector<cv::Point> BioTrackerUtilsMisc::stringToCVPointVec(
      std::vector<cv::Point> pts; std::string arena)
      {
      QString qarena(arena.c_str()); std::vector<cv::Point> pts;
      QStringList corners = qarena.split(";");
      for (int i = 0; i < corners.size(); i++) { QString qarena(arena.c_str());
      QString cur = corners.at(i); QStringList corners = qarena.split(";");
      QStringList p = cur.split(","); for (int i = 0; i < corners.size(); i++) {
      pts.push_back(cv::Point(p.at(0).toInt(), p.at(1).toInt())); QString cur = corners.at(i);
      } QStringList p = cur.split(",");
      return pts; pts.push_back(cv::Point(p.at(0).toInt(), p.at(1).toInt()));
      }
      return pts;
      } }
      std::vector<cv::Point> BioTrackerUtilsMisc::QVecToCvVec(std::vector<QPoint> q)
      std::vector<cv::Point> BioTrackerUtilsMisc::QVecToCvVec(std::vector<QPoint> q) { {
      std::vector<cv::Point> v; std::vector<cv::Point> v;
      for (int i = 0; i < q.size(); i++) for (int i = 0; i < q.size(); i++)
      v.push_back(cv::Point(q[i].x(), q[i].y())); v.push_back(cv::Point(q[i].x(), q[i].y()));
      return v; return v;
      } }
      std::vector<QPoint> BioTrackerUtilsMisc::CvVecToQVec(std::vector<cv::Point> q) { std::vector<QPoint> BioTrackerUtilsMisc::CvVecToQVec(std::vector<cv::Point> q)
      std::vector<QPoint> v; {
      for (int i = 0; i < q.size(); i++) std::vector<QPoint> v;
      v.push_back(QPoint(q[i].x, q[i].y)); for (int i = 0; i < q.size(); i++)
      return v; v.push_back(QPoint(q[i].x, q[i].y));
      return v;
      } }
      std::string BioTrackerUtilsMisc::cvPointsToString(std::vector<cv::Point> ac) { std::string BioTrackerUtilsMisc::cvPointsToString(std::vector<cv::Point> ac)
      {
      std::string arena = ""; std::string arena = "";
      for (int i = 0; i < ac.size(); i++) for (int i = 0; i < ac.size(); i++)
      arena += (std::to_string(ac[i].x) + "," + std::to_string(ac[i].y) + ";"); arena += (std::to_string(ac[i].x) + "," + std::to_string(ac[i].y) +
      return arena.substr(0, arena.size() - 1); ";");
      return arena.substr(0, arena.size() - 1);
      } }
      ...@@ -5,12 +5,13 @@ ...@@ -5,12 +5,13 @@
      #include <opencv2/opencv.hpp> #include <opencv2/opencv.hpp>
      #include <QPoint> #include <QPoint>
      namespace BioTrackerUtilsMisc{ namespace BioTrackerUtilsMisc
      int split(std::string &txt, std::vector<std::string> &strs, char ch); {
      int split(std::string& txt, std::vector<std::string>& strs, char ch);
      std::string getTimeAndDate(std::string prefix, std::string suffix); std::string getTimeAndDate(std::string prefix, std::string suffix);
      std::vector<cv::Point> stringToCVPointVec(std::string arena); std::vector<cv::Point> stringToCVPointVec(std::string arena);
      std::vector<cv::Point> QVecToCvVec(std::vector<QPoint> q); std::vector<cv::Point> QVecToCvVec(std::vector<QPoint> q);
      std::string cvPointsToString(std::vector<cv::Point> ac); std::string cvPointsToString(std::vector<cv::Point> ac);
      std::vector<QPoint> CvVecToQVec(std::vector<cv::Point> q); std::vector<QPoint> CvVecToQVec(std::vector<cv::Point> q);
      } }
      #endif #endif
      \ No newline at end of file
      0% Loading or .
      You are about to add 0 people to the discussion. Proceed with caution.
      Please register or to comment