From: <ip...@us...> - 2007-06-22 15:36:44
|
Revision: 2139 http://hugin.svn.sourceforge.net/hugin/?rev=2139&view=rev Author: ippei Date: 2007-06-22 08:36:38 -0700 (Fri, 22 Jun 2007) Log Message: ----------- algorithms interface almost finished; I think I just leave the rest till later Modified Paths: -------------- hugin/branches/ippei/src/hugin_base/appbase/ProgressDisplay.h hugin/branches/ippei/src/hugin_base/appbase/ProgressDisplayOld.h Added Paths: ----------- hugin/branches/ippei/src/hugin_base/appbase/ProgressReportOld.h Modified: hugin/branches/ippei/src/hugin_base/appbase/ProgressDisplay.h =================================================================== --- hugin/branches/ippei/src/hugin_base/appbase/ProgressDisplay.h 2007-06-21 21:11:32 UTC (rev 2138) +++ hugin/branches/ippei/src/hugin_base/appbase/ProgressDisplay.h 2007-06-22 15:36:38 UTC (rev 2139) @@ -66,8 +66,6 @@ /// bool propagatesProgress; - std::string message; - /// bool measuresProgress() { return maxProgress == 0; }; @@ -77,14 +75,12 @@ // -- Const/Destructors -- protected: - /// virtual ProgressDisplay() : o_newSubtaskProgress(0) {}; public: - /// virtual ~ProgressDisplay(); @@ -92,7 +88,6 @@ // -- task interface -- protected: - /// void startSubtaskWithTask(const ProgressTask& newSubtask) { @@ -102,7 +97,6 @@ } public: - /// void setParentProgressOfNewSubtasks(double subtaskTotalProgress, bool propagatesProgress = false) { @@ -182,6 +176,12 @@ } /// + void increaseSubtaskProgressBy(const double& deltaValue) + { + updateSubtaskProgress(getSubtaskProgress() + deltaValue); + } + + /// void finishSubtask() { subtaskFinished(); @@ -202,7 +202,6 @@ // -- callback interface -- protected: - /** Template method, updates the display. * You should override this method with your code of updating the display. * The default implementation does nothing. @@ -223,7 +222,6 @@ // -- utility methods -- protected: - /// void propagateProgress(const double& newProgress) { @@ -261,7 +259,6 @@ // -- accessable variables -- protected: - /// std::vector<ProgressTask> o_subtasks; @@ -269,12 +266,9 @@ double o_newSubtaskProgress; bool o_newSubtaskPropagates; -} +}; - - - /** a progress display to print stuff to stdout (doesn't work properly on the * windows console. */ Modified: hugin/branches/ippei/src/hugin_base/appbase/ProgressDisplayOld.h =================================================================== --- hugin/branches/ippei/src/hugin_base/appbase/ProgressDisplayOld.h 2007-06-21 21:11:32 UTC (rev 2138) +++ hugin/branches/ippei/src/hugin_base/appbase/ProgressDisplayOld.h 2007-06-22 15:36:38 UTC (rev 2139) @@ -1,5 +1,5 @@ // -*- c-basic-offset: 4 -*- -/** @file ProgressDisplay.h +/** @file ProgressDisplayOld.h * * @author Pablo d'Angelo <pab...@we...> * @@ -21,22 +21,17 @@ * */ -#ifndef POGRESSDISPLAY_H -#define POGRESSDISPLAY_H +#ifndef POGRESSDISPLAYOLD_H +#define POGRESSDISPLAYOLD_H #include <string> #include <vector> -#include <iostream> -#include <sstream> -#include <cassert> -// [TODO] ProgressReport class and adaptor - - namespace AppBase { + /** desribes a subprogess task */ struct ProgressTask { @@ -93,7 +88,6 @@ }; - /** The progress display is used to report progress to another * part of the program. @@ -211,22 +205,55 @@ std::vector<ProgressTask> tasks; double m_minProgressStep; }; - + + /** * */ + class DummyMultiProgressDispaly : public MultiProgressDisplay + { + void pushTask(const vigra_ext::ProgressTask & task) {}; + void popTask() {}; + void setShortMessage(const std::string & msg) {}; + void setMessage(const std::string & msg) {}; + void setProgress(double progress) {}; + void increase() {}; + + virtual void updateProgressDisplay() {}; + virtual void taskAdded() {}; + virtual void taskRemove() {}; + }; + + + /** + * + */ class MultiProgressDisplayAdaptor : MultiProgressDisplay { + public: - + /// ProgressDisplayAdaptor(ProgressDisplay& myProgressDisplay) - : vigra_ext::MultiProgressDisplay(0.0), o_progressDisplay(myProgressDisplay) + : MultiProgressDisplay(0.0), o_progressDisplay(myProgressDisplay) {}; - + + /// virtual ~ProgressDisplayAdaptor() {}; - + /// + static ProgressReporter newMultiProgressDisplay(ProgressDisplay* myProgressDisplay) + { + if(myProgressDisplay != NULL) + return new ProgressDisplayAdaptor(*myProgressDisplay, maxProgress); + else + return new DummyMultiProgressDispaly(maxProgress); + } + + + + public: + /// void taskAdded() { o_progressDisplay.setParentProgressOfNewSubtasks(tasks.back().subStepProgress, true); @@ -254,25 +281,7 @@ }; - /** - * - */ - class DummyMultiProgressDispaly : public MultiProgressDisplay - { - void pushTask(const vigra_ext::ProgressTask & task) {}; - void popTask() {}; - void setShortMessage(const std::string & msg) {}; - void setMessage(const std::string & msg) {}; - void setProgress(double progress) {}; - void increase() {}; - - virtual void updateProgressDisplay() {}; - virtual void taskAdded() {}; - virtual void taskRemove() {}; - }; - - } // namespace -#endif // _UTILS_H +#endif // POGRESSDISPLAYOLD_H Added: hugin/branches/ippei/src/hugin_base/appbase/ProgressReportOld.h =================================================================== --- hugin/branches/ippei/src/hugin_base/appbase/ProgressReportOld.h (rev 0) +++ hugin/branches/ippei/src/hugin_base/appbase/ProgressReportOld.h 2007-06-22 15:36:38 UTC (rev 2139) @@ -0,0 +1,121 @@ +// -*- c-basic-offset: 4 -*- +/** @file ProgressDisplayOld.h + * + * @author Pablo d'Angelo <pab...@we...> + * + * $Id: utils.h 1952 2007-04-15 20:57:55Z dangelo $ + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this software; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef POGRESSDISPLAYOLD_H +#define POGRESSDISPLAYOLD_H + +#include <string> +#include <vector> + + +namespace AppBase +{ + + /** + * + */ + class ProgressReporter + { + public: + ProgressReporter(double maxProgress = 1.0); + virtual ~ProgressReporter() {}; + virtual void setMessage(const std::string & msg) = 0; + virtual bool increaseProgress(double delta) = 0; + + virtual bool increaseProgress(double delta, const std::string & msg) + { + setMessage(msg); + return increaseProgress(double delta); + } + }; + + + /** + * + */ + class DummyProgressReport : public ProgressReport + { + public: + DummyProgressReport(double maxProgress = 1.0) + : ProgressReport(maxProgress); + + ~ProgressReporter() {}; + + void setMessage(const std::string & msg) {}; + bool increaseProgress(double delta) { return true; }; + }; + + + /** + * + */ + class ProgressReporterAdaptor : ProgressReporter + { + public: + /// + ProgressReporterAdaptor(ProgressDisplay& myProgressDisplay, const double& maxProgress) + : ProgressReporter(maxProgress), o_progressDisplay(myProgressDisplay) + { + o_progressDisplay.startSubtask(maxProgress); + }; + + /// + virtual ~ProgressReporterAdaptor() + { + o_progressDisplay.subtaskFinished(); + }; + + /// + static ProgressReporter newProgressReporter(ProgressDisplay* myProgressDisplay, const double& maxProgress) + { + if(myProgressDisplay != NULL) + return new ProgressReporterAdaptor(*myProgressDisplay, maxProgress); + else + return new DummyProgressReport(maxProgress); + } + + + public: + /// + bool increaseProgress(double delta) + { + o_progressDisplay.increaseSubtaskProgressBy(delta); + return !o_progressDisplay.wasCanceled(); + }; + + /// + void setMessage(const std::string & msg) + { + o_progressDisplay.setSubtaskMessage(msg); + } + + + protected: + ProgressDisplay& o_progressDisplay; + }; + + +} // namespace + + +#endif // POGRESSDISPLAYOLD_H This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |