Changeset 156 for osgVisual


Ignore:
Timestamp:
Nov 12, 2010, 9:13:14 AM (13 years ago)
Author:
Torben Dannhauer
Message:
 
Location:
osgVisual
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • osgVisual/bin/osgVisualConfig.xml

    r155 r156  
    1818  <module name="sky_silverlining" enabled="yes"></module>
    1919  <module name="vista2d" enabled="yes">
    20     <vista2d filename="D:\osgVisual\osgVisual\bin\hud.v" paintBackground="no" position_x="800" position_y="450" zoom="0.5"></vista2d>
     20    <vista2d filename="D:\osgVisual\osgVisual\bin\altimeterSimple.v" paintBackground="no" position_x="1" position_y="1" zoom="1.0" playanimation="yes"></vista2d>
    2121  </module>
    2222  <module name="dataio" enabled="yes">
  • osgVisual/include/vista2D/visual_vista2D.h

    r155 r156  
    8282         * @return : True if successful.
    8383         */
    84         static bool init( osg::CoordinateSystemNode *sceneGraphRoot_, std::string configFileName );
     84        bool init( osg::CoordinateSystemNode *sceneGraphRoot_, std::string configFileName );
    8585
    8686        /**
     
    101101private:
    102102
    103         static bool processXMLConfiguration(std::string& configFileName, std::string& vistaProjectfile, bool& paintBackground, int& position_x, int& position_y, float& zoom);
     103        bool processXMLConfiguration();
    104104
    105105        /**
    106106         * \brief This function initialized the visual_vista2D object after instantiation by createVistaOverlay()
    107107         */
    108         void startVista2D(std::string vistaProjectfile, bool paintBackground, int posX, int posY, float zoom);
     108        void startVista2D();
    109109
    110110        /**
    111111         * \brief This function implements the pure OpenGL draw by calling Vista2D's draw funtion.
    112112         *
    113          * Because Visrta2D manipulates OpenGLs stateset, this function saves the
     113         * Because Vista2D manipulates OpenGLs stateset, this function saves the
    114114         * OSG statset at the beginning and restores it after the drawing of Vista2D
    115115         *
     
    123123        Vista2D::VistaView* view;
    124124
    125         ///**
    126         // * XML config filename
    127         // */
    128         //std::string configFileName;
     125        /**
     126        * XML config filename
     127        */
     128        std::string configFileName;
    129129
    130         ///**
    131         // * Filename of the Vista2D project file.
    132         // */
    133         //std::string filename;
     130        /**
     131        * Filename of the Vista2D project file.
     132        */
     133        std::string vistaProjectfile;
    134134
    135         ///**
    136         // * Should the background of the Vista2D project be painted?
    137         // */
    138         //bool paintBackground;
     135        /**
     136        * Should the background of the Vista2D project be painted?
     137        */
     138        bool paintBackground;
    139139
    140         ///**
    141         // * X-Position to draw.
    142         // */
    143         //int position_x;
     140        /**
     141        * X-Position to draw.
     142        */
     143        int position_x;
    144144
    145         ///**
    146         // * Y-Position to draw.
    147         // */
    148         //int position_y;
     145        /**
     146        * Y-Position to draw.
     147        */
     148        int position_y;
    149149
    150         ///**
    151         // * Zoom factor to draw the project.
    152         // */
    153         //double zoom;
     150        /**
     151         * Zoom factor to draw the project.
     152         */
     153        double zoom;
     154
     155        /**
     156         * Flag if Vista2D should animate the project according to it's data sources.
     157         */
     158        bool playanimation;
    154159};
    155160
  • osgVisual/src/core/visual_core.cpp

    r155 r156  
    513513        visual_dataIO::getInstance()->setSlotData("TestSlot1", osgVisual::dataIO_slot::TO_OBJ, 0.12345);
    514514
    515 
    516         // Vista2D Test:
    517         visual_vista2D::init(rootNode, configFilename );
    518 }
     515}
  • osgVisual/src/vista2D/visual_vista2D.cpp

    r155 r156  
    2626   // Create a Vista2D View
    2727   view = new Vista2D::VistaView();
     28
     29        vistaProjectfile = "";
     30        paintBackground = false;
     31        playanimation = false;
     32        position_x = 0;
     33        position_y = 0;
     34        zoom = 1;
    2835}
    2936
    3037visual_vista2D::~visual_vista2D(void)
    3138{
    32 }
    33 
    34 void visual_vista2D::startVista2D(std::string vistaProjectfile, bool paintBackground, int posX, int posY, float zoom)
     39        view->stopView();
     40}
     41
     42void visual_vista2D::startVista2D()
    3543{
    3644    /***************
     
    3947        view->load( vistaProjectfile );
    4048    view->setBackgroundMode(paintBackground);   // don't paint background
    41         view->setPosition( posX, posY);
     49        view->setPosition( position_x, position_y);
    4250        view->setZoom( zoom );
    4351
     
    4654    self running datasource
    4755    ***************/
    48     view->startView (true);
    49 
    50 }
    51 
    52 bool visual_vista2D::processXMLConfiguration(std::string& configFileName, std::string& vistaProjectfile, bool& paintBackground, int& position_x, int& position_y, float& zoom)
     56    view->startView (playanimation);
     57}
     58
     59bool visual_vista2D::processXMLConfiguration()
    5360{
    5461        // Init XML
     
    109116                                                std::stringstream sstr(attr_value);
    110117                                                sstr >> zoom;
     118                                        }
     119
     120                                        if( attr_name == "playanimation" )
     121                                        {
     122                                                playanimation = (attr_value == "yes") ? true : false;
    111123                                        }
    112124
     
    133145        OSG_NOTIFY (osg::ALWAYS ) << "visual_vista2D initialize..";  // The sentence is finished by the init result...
    134146
    135         std::string vistaProjectfile = "";
    136         bool paintBackground = false;
    137         int position_x = 0;
    138         int position_y = 0;
    139         float zoom = 1;
     147        this->configFileName = configFileName;
    140148
    141149        // Process XML configuration
    142         if(!processXMLConfiguration(configFileName, vistaProjectfile, paintBackground, position_x, position_y, zoom))
     150        if(!processXMLConfiguration())
    143151                return false;   // Abort vista2D initialization.
    144152
     
    184192
    185193        // Add Payload: Vista2D                 
    186         osg::ref_ptr<visual_vista2D> vista2D = new visual_vista2D();
    187         vista2D->startVista2D(vistaProjectfile, paintBackground, position_x, position_y, zoom);
    188 
    189         vista2D.get()->setUseDisplayList( false );
    190         vista2Dgeode->addDrawable( vista2D.get() );
     194        startVista2D();
     195
     196        // Add this class to the scene Graph
     197        this->setUseDisplayList( false );
     198        vista2Dgeode->addDrawable( this );
    191199
    192200        sceneGraphRoot_->addChild( vista2DProjectionMatrix );
Note: See TracChangeset for help on using the changeset viewer.