OpenWalnut  1.4.0
WUI.h
00001 //---------------------------------------------------------------------------
00002 //
00003 // Project: OpenWalnut ( http://www.openwalnut.org )
00004 //
00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
00006 // For more information see http://www.openwalnut.org/copying
00007 //
00008 // This file is part of OpenWalnut.
00009 //
00010 // OpenWalnut is free software: you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as published by
00012 // the Free Software Foundation, either version 3 of the License, or
00013 // (at your option) any later version.
00014 //
00015 // OpenWalnut is distributed in the hope that it will be useful,
00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 // GNU Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public License
00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
00022 //
00023 //---------------------------------------------------------------------------
00024 
00025 #ifndef WUI_H
00026 #define WUI_H
00027 
00028 #include <string>
00029 
00030 #include <boost/shared_ptr.hpp>
00031 
00032 #include "../common/WFlag.h"
00033 #include "../graphicsEngine/WGECamera.h"
00034 #include "WCustomWidget.h"
00035 
00036 class WDataSet;
00037 
00038 /**
00039  * This library implements the user interface for OpenWalnut.
00040  *
00041  * \defgroup ui UI
00042  */
00043 
00044 /**
00045  * This class prescribes the interface to the UI. It basically is an abstract class defining the interface common to all possible
00046  * UI implementations.
00047  *
00048  * \ingroup ui
00049  */
00050 class WUI : public boost::enable_shared_from_this< WUI >
00051 {
00052 public:
00053     /**
00054      * Constructor.
00055      *
00056      * \param argc number of arguments given on command line.
00057      * \param argv arguments given on command line.
00058      */
00059     WUI( int argc, char** argv );
00060 
00061     /**
00062      * Destructor.
00063      */
00064     virtual ~WUI();
00065 
00066     /**
00067      * Returns the init flag.
00068      *
00069      * \return Reference to the flag.
00070      */
00071     virtual const WFlag< bool >& isInitialized() const;
00072 
00073     /**
00074      * Runs the UI. All initialization should be done here.
00075      *
00076      * \return the return code.
00077      */
00078     virtual int run() = 0;
00079 
00080     /**
00081      * Instruct to open a new custom widget. The specified condition should be the shutdown condition of the module, as the function returns only
00082      * if the widget was created. To ensure that the creation is aborted properly if the module shuts down in the meantime, this condition is
00083      * used.
00084      *
00085      * \note this function blocks until the widget was created. Check the resulting pointer for NULL.
00086      *
00087      * \param title the title of the widget
00088      * \param projectionMode the kind of projection which should be used
00089      * \param shutdownCondition a condition enforcing abort of widget creation.
00090      *
00091      * \return the created widget
00092      */
00093     virtual WCustomWidget::SPtr openCustomWidget(
00094             std::string title,
00095             WGECamera::ProjectionMode projectionMode,
00096             boost::shared_ptr< WCondition > shutdownCondition ) = 0;
00097 
00098     /**
00099      * Instruct to close a custom widget.
00100      *
00101      * \param title The title of the widget
00102      */
00103     virtual void closeCustomWidget( std::string title ) = 0;
00104 
00105     /**
00106      * Instruct to close the custom widget.
00107      *
00108      * \param widget the widget to close again.
00109      */
00110     virtual void closeCustomWidget( WCustomWidget::SPtr widget ) = 0;
00111 
00112 protected:
00113     /**
00114      * Flag determining whether the UI is properly initialized.
00115      */
00116     WFlag< bool > m_isInitialized;
00117 
00118     /**
00119      * Number of command line arguments given.
00120      */
00121     int m_argc;
00122 
00123     /**
00124      * Command line arguments given.
00125      */
00126     char** m_argv;
00127 };
00128 
00129 #endif  // WUI_H
00130