Commit 0b4f2d6a authored by Jan Möbius's avatar Jan Möbius

Made DrawMode an extra class

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@8549 383ad7c9-94d9-4d36-a494-682f7c89f535
parent de5bf5bc
......@@ -58,7 +58,7 @@
//== CLASS DEFINITION =========================================================
/// Convert a drawmode to a vector of QStrings
std::vector< QString > drawModeToList(unsigned int _drawMode) {
std::vector< QString > drawModeToList(ACG::SceneGraph::DrawModes::DrawMode _drawMode) {
std::vector< QString > draw_modes;
if ( _drawMode & ACG::SceneGraph::DrawModes::DEFAULT )
......@@ -112,9 +112,9 @@ std::vector< QString > drawModeToList(unsigned int _drawMode) {
}
/// Convert a vector of QStrings to a draw mode
unsigned int ListToDrawMode ( std::vector< QString > _draw_modes ) {
ACG::SceneGraph::DrawModes::DrawMode listToDrawMode( std::vector< QString > _draw_modes ) {
unsigned int drawMode = 0 ;
ACG::SceneGraph::DrawModes::DrawMode drawMode( ACG::SceneGraph::DrawModes::NONE );
for ( uint i = 0 ; i < _draw_modes.size() ; ++i ) {
if( _draw_modes[i] == "DEFAULT" ) {
......@@ -169,9 +169,9 @@ unsigned int ListToDrawMode ( std::vector< QString > _draw_modes ) {
}
/// Convert a vector of DrawMode-Descriptions to a draw mode
unsigned int descriptionsToDrawMode ( std::vector< QString > _draw_modes ) {
ACG::SceneGraph::DrawModes::DrawMode descriptionsToDrawMode ( std::vector< QString > _draw_modes ) {
unsigned int drawMode = 0 ;
ACG::SceneGraph::DrawModes::DrawMode drawMode( ACG::SceneGraph::DrawModes::NONE );
for ( uint i = 0 ; i < _draw_modes.size() ; ++i ) {
if( _draw_modes[i] == "Default" ) {
......@@ -226,7 +226,7 @@ unsigned int descriptionsToDrawMode ( std::vector< QString > _draw_modes ) {
}
/// Convert a drawmode to a vector of QStrings
std::vector< QString > drawModeToDescriptions(unsigned int _drawMode) {
std::vector< QString > drawModeToDescriptions(ACG::SceneGraph::DrawModes::DrawMode _drawMode) {
std::vector< QString > draw_modes;
if ( _drawMode & ACG::SceneGraph::DrawModes::DEFAULT )
......
......@@ -65,17 +65,29 @@
//== CLASS DEFINITION =========================================================
/** \brief convert a drawMode to a List of the drawmode names
*
*/
DLLEXPORT
std::vector< QString > drawModeToList(unsigned int _drawMode);
std::vector< QString > drawModeToList(ACG::SceneGraph::DrawModes::DrawMode _drawMode);
/** \brief convert a drawMode name list to a drawmode
*
*/
DLLEXPORT
unsigned int ListToDrawMode ( std::vector< QString > _draw_modes );
ACG::SceneGraph::DrawModes::DrawMode listToDrawMode ( std::vector< QString > _draw_modes );
/** \brief convert a drawMode to a List of the drawmode readable descriptions
*
*/
DLLEXPORT
std::vector< QString > drawModeToDescriptions(unsigned int _drawMode);
std::vector< QString > drawModeToDescriptions(ACG::SceneGraph::DrawModes::DrawMode _drawMode);
/** \brief convert a List of the drawmode readable descriptions to a drawMode
*
*/
DLLEXPORT
unsigned int descriptionsToDrawMode ( std::vector< QString > _draw_modes );
ACG::SceneGraph::DrawModes::DrawMode descriptionsToDrawMode ( std::vector< QString > _draw_modes );
//=============================================================================
#endif // DRAWMODECONVERTER_HH defined
......
......@@ -403,7 +403,7 @@ QPoint mapToLocal( const QPoint _point ) {
return examiner_widgets_[activeExaminer_]->glMapFromGlobal(_point);
}
void setDrawMode( const unsigned int _mode , int _viewer) {
void setDrawMode( const ACG::SceneGraph::DrawModes::DrawMode _mode , int _viewer) {
if ( _viewer == ACTIVE_VIEWER )
viewerProperties(activeExaminer()).drawMode(_mode);
......@@ -422,7 +422,7 @@ void setDrawMode( const unsigned int _mode , int _viewer) {
* The DrawModes are defined at ACG/Scenegraph/DrawModes.hh \n
* They can be combined.
*/
unsigned int drawMode( int _viewer ) {
ACG::SceneGraph::DrawModes::DrawMode drawMode( int _viewer ) {
if ( _viewer == ACTIVE_VIEWER ) {
return viewerProperties(activeExaminer()).drawMode();
} else if ( _viewer == ALL_VIEWERS )
......
......@@ -61,6 +61,7 @@
#include <OpenFlipper/common/Types.hh>
#include <ACG/Scenegraph/SceneGraph.hh>
#include <ACG/Scenegraph/DrawModes.hh>
#include <ACG/GL/GLState.hh>
#include <OpenFlipper/common/ViewerProperties.hh>
......@@ -324,7 +325,7 @@ void perspectiveProjection( int _viewer = ALL_VIEWERS );
* 0..3 Choose viewer explicitly
*/
DLLEXPORT
void setDrawMode( const unsigned int _mode , int _viewer = ALL_VIEWERS);
void setDrawMode( const ACG::SceneGraph::DrawModes::DrawMode _mode , int _viewer = ALL_VIEWERS);
/** \brief Get the current draw Mode of a Viewer
*
......@@ -334,7 +335,7 @@ void setDrawMode( const unsigned int _mode , int _viewer = ALL_VIEWERS);
* 0..3 Choose viewer explicitly
*/
DLLEXPORT
unsigned int drawMode( int _viewer = ACTIVE_VIEWER );
ACG::SceneGraph::DrawModes::DrawMode drawMode( int _viewer = ACTIVE_VIEWER );
/** \brief Set the background color of the examiner widget.
......
......@@ -273,7 +273,7 @@ void Core::readApplicationOptions(INIFile& _ini) {
for (int i=0; i < 4/*PluginFunctions::viewers()*/; i++ ){
if( _ini.get_entry(draw_modes, "Options", "DefaultDrawModes" + QString::number(i) ) )
OpenFlipper::Options::defaultDrawMode( ListToDrawMode(draw_modes), i );
OpenFlipper::Options::defaultDrawMode( listToDrawMode(draw_modes), i );
if( _ini.get_entry(mode, "Options", "DefaultProjectionMode" + QString::number(i) ) )
OpenFlipper::Options::defaultProjectionMode( mode, i );
......
......@@ -102,8 +102,8 @@ class DLLEXPORT DataType {
bool operator<( const unsigned int& _i );
bool operator<( const DataType& _i ) const;
DataType operator|=( const unsigned int& _i );
DataType operator|=( const DataType& _i );
DataType& operator|=( const unsigned int& _i );
DataType& operator|=( const DataType& _i );
bool operator&( const unsigned int& _i );
bool operator&( const DataType& _i ) const;
......
......@@ -151,7 +151,7 @@ static bool restrictFrameRate_ = false;
static int maxFrameRate_ = 35;
/// Store the defaultDrawMode_ mode
static std::vector<uint> defaultDrawMode_ = std::vector<uint> (4, ACG::SceneGraph::DrawModes::SOLID_SMOOTH_SHADED);
static std::vector<ACG::SceneGraph::DrawModes::DrawMode> defaultDrawMode_ = std::vector<ACG::SceneGraph::DrawModes::DrawMode> (4, ACG::SceneGraph::DrawModes::SOLID_SMOOTH_SHADED);
/// Store the defaultProjectionMode_ mode
static std::vector<int> defaultProjectionMode_ = std::vector<int> (4, 1);
......@@ -512,11 +512,11 @@ int maxFrameRate(){
return maxFrameRate_;
}
void defaultDrawMode( uint _mode, int _viewer){
void defaultDrawMode( ACG::SceneGraph::DrawModes::DrawMode _mode, int _viewer){
defaultDrawMode_[_viewer] = _mode;
}
uint defaultDrawMode(int _viewer){
ACG::SceneGraph::DrawModes::DrawMode defaultDrawMode(int _viewer){
return defaultDrawMode_[_viewer];
}
......
......@@ -59,6 +59,7 @@
#define OPTIONS_HH
#include <OpenFlipper/common/GlobalDefines.hh>
#include <ACG/Scenegraph/DrawModes.hh>
#include <QDir>
#include <QStringList>
#include <QColor>
......@@ -452,11 +453,11 @@ QString helpDirStr();
/// Store defaultDrawMode setting
DLLEXPORT
void defaultDrawMode( uint _mode, int _viewer );
void defaultDrawMode( ACG::SceneGraph::DrawModes::DrawMode _mode, int _viewer );
/// get defaultDrawMode setting
DLLEXPORT
uint defaultDrawMode( int _viewer );
ACG::SceneGraph::DrawModes::DrawMode defaultDrawMode( int _viewer );
/// Store defaultProjectionMode setting
DLLEXPORT
......
......@@ -370,12 +370,14 @@ bool DataType::operator&( const DataType& _i ) const {
//===========================================
DataType DataType::operator|=( const unsigned int& _i ) {
return (field |= _i);
DataType& DataType::operator|=( const unsigned int& _i ) {
field |= _i;
return (*this);
}
DataType DataType::operator|=( const DataType& _i ) {
return ( field |= _i.field);
DataType& DataType::operator|=( const DataType& _i ) {
field |= _i.field ;
return (*this);
}
//===========================================
......
......@@ -64,6 +64,7 @@
#include <OpenFlipper/common/GlobalDefines.hh>
#include <ACG/Math/VectorT.hh>
#include <ACG/Scenegraph/SceneGraph.hh>
#include <ACG/Scenegraph/DrawModes.hh>
#include <ACG/GL/GLState.hh>
// forward declaration
......@@ -100,14 +101,14 @@ namespace Viewer {
public:
/// set draw mode (No test if this mode is available!)
void drawMode(unsigned int _mode) { currentDrawMode_ = _mode; emit updated(); };
void drawMode(ACG::SceneGraph::DrawModes::DrawMode _mode) { currentDrawMode_ = _mode; emit updated(); };
/// get current draw mode
unsigned int drawMode() { return currentDrawMode_; };
ACG::SceneGraph::DrawModes::DrawMode drawMode() { return currentDrawMode_; };
private:
unsigned int currentDrawMode_;
ACG::SceneGraph::DrawModes::DrawMode currentDrawMode_;
/** @} */
......
......@@ -634,22 +634,22 @@ void CoreWidget::slotUpdateViewerDrawMenu() {
// Get currently active drawModes (first viewer only )
// TODO: create combination from all viewers!
int activeDrawModes = PluginFunctions::drawMode();
ACG::SceneGraph::DrawModes::DrawMode activeDrawModes = PluginFunctions::drawMode();
// Convert to ids
std::vector< unsigned int > availDrawModeIds;
availDrawModeIds = ACG::SceneGraph::DrawModes::getDrawModeIDs( availableGlobalDrawModes_ );
std::vector< ACG::SceneGraph::DrawModes::DrawMode > availDrawModeIds;
availDrawModeIds = availableGlobalDrawModes_.getAtomicDrawModes() ;
viewerDrawMenu_->clear();
for ( unsigned int i = 0; i < availDrawModeIds.size(); ++i )
{
unsigned int id = availDrawModeIds[i];
std::string descr = ACG::SceneGraph::DrawModes::description( id );
ACG::SceneGraph::DrawModes::DrawMode id = availDrawModeIds[i];
std::string descr = id.description();
QAction * action = new QAction( descr.c_str(), drawGroupViewer_ );
action->setCheckable( true );
action->setChecked( ACG::SceneGraph::DrawModes::containsId( activeDrawModes, id ) );
action->setChecked( activeDrawModes.containsAtomicDrawMode(id) );
}
viewerDrawMenu_->addActions( drawGroupViewer_->actions() );
......@@ -661,12 +661,12 @@ void CoreWidget::slotViewerDrawMenu(QAction * _action) {
//======================================================================================
// Get the mode toggled
//======================================================================================
unsigned int mode = 0;
std::vector< unsigned int > availDrawModeIds;
availDrawModeIds = ACG::SceneGraph::DrawModes::getDrawModeIDs( availableGlobalDrawModes_ );
ACG::SceneGraph::DrawModes::DrawMode mode = 0;
std::vector< ACG::SceneGraph::DrawModes::DrawMode > availDrawModeIds;
availDrawModeIds = availableGlobalDrawModes_.getAtomicDrawModes();
for ( unsigned int i = 0; i < availDrawModeIds.size(); ++i )
{
QString descr = QString( ACG::SceneGraph::DrawModes::description( availDrawModeIds[i] ).c_str() );
QString descr = QString( availDrawModeIds[i].description().c_str() );
if ( descr == _action->text() ) {
mode = availDrawModeIds[i];
......
......@@ -95,6 +95,8 @@
#include <ACG/QtWidgets/QtSceneGraphWidget.hh>
#include <ACG/Scenegraph/DrawModes.hh>
#include <OpenFlipper/INIFile/INIFile.hh>
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
......@@ -634,9 +636,9 @@ public:
/// Action to globally set multisampling
QAction* globalMultisamplingAction_;
int activeDrawModes_;
ACG::SceneGraph::DrawModes::DrawMode activeDrawModes_;
int availableGlobalDrawModes_;
ACG::SceneGraph::DrawModes::DrawMode availableGlobalDrawModes_;
/** @} */
......
......@@ -655,24 +655,24 @@ void CoreWidget::slotUpdateGlobalDrawMenu() {
// Get currently active drawModes (first viewer only )
// TODO: create combination from all viewers!
activeDrawModes_ = INT_MAX;
for ( int i = 0 ; i < PluginFunctions::viewers(); ++i )
activeDrawModes_ = PluginFunctions::drawMode(0);
for ( int i = 1 ; i < PluginFunctions::viewers(); ++i )
activeDrawModes_ &= PluginFunctions::drawMode(i);
// Convert to ids
std::vector< unsigned int > availDrawModeIds;
availDrawModeIds = ACG::SceneGraph::DrawModes::getDrawModeIDs( availableGlobalDrawModes_ );
std::vector< ACG::SceneGraph::DrawModes::DrawMode > availDrawModeIds;
availDrawModeIds = availableGlobalDrawModes_.getAtomicDrawModes() ;
globalDrawMenu_->clear();
for ( unsigned int i = 0; i < availDrawModeIds.size(); ++i )
{
unsigned int id = availDrawModeIds[i];
std::string descr = ACG::SceneGraph::DrawModes::description( id );
ACG::SceneGraph::DrawModes::DrawMode id = availDrawModeIds[i];
std::string descr = id.description();
QAction * action = new QAction( descr.c_str(), drawGroup_ );
action->setCheckable( true );
action->setChecked( ACG::SceneGraph::DrawModes::containsId( activeDrawModes_, id ) );
action->setChecked( activeDrawModes_.containsAtomicDrawMode(id) );
}
globalDrawMenu_->addActions( drawGroup_->actions() );
......@@ -684,12 +684,12 @@ void CoreWidget::slotGlobalDrawMenu(QAction * _action) {
//======================================================================================
// Get the mode toggled
//======================================================================================
unsigned int mode = 0;
std::vector< unsigned int > availDrawModeIds;
availDrawModeIds = ACG::SceneGraph::DrawModes::getDrawModeIDs( availableGlobalDrawModes_ );
ACG::SceneGraph::DrawModes::DrawMode mode(ACG::SceneGraph::DrawModes::NONE);
std::vector< ACG::SceneGraph::DrawModes::DrawMode > availDrawModeIds;
availDrawModeIds = availableGlobalDrawModes_.getAtomicDrawModes();
for ( unsigned int i = 0; i < availDrawModeIds.size(); ++i )
{
QString descr = QString( ACG::SceneGraph::DrawModes::description( availDrawModeIds[i] ).c_str() );
QString descr = QString( ( availDrawModeIds[i].description() ).c_str() );
if ( descr == _action->text() ) {
mode = availDrawModeIds[i];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment