Changeset 155 for osgVisual


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

Legend:

Unmodified
Added
Removed
  • osgVisual/bin/osgVisualConfig.xml

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

    r153 r155  
    1616*/
    1717
     18// Vista 2D
    1819#include "VistaView.h"
    1920
     21// C++ libraries
    2022#include <string>
    2123
     24// XML Parser
     25#include <stdio.h>
     26#include <libxml/parser.h>
     27#include <libxml/tree.h>
     28
     29// OSG Includes
    2230#include <osg/Drawable>
    2331#include <osg/Geode>
     
    2836#include <osgDB/FileUtils>
    2937
     38// osgVisual Includes
     39#include <visual_util.h>
    3040
    3141namespace osgVisual
     
    91101private:
    92102
    93         bool processXMLConfiguration();
     103        static bool processXMLConfiguration(std::string& configFileName, std::string& vistaProjectfile, bool& paintBackground, int& position_x, int& position_y, float& zoom);
    94104
    95105        /**
    96106         * \brief This function initialized the visual_vista2D object after instantiation by createVistaOverlay()
    97107         */
    98         void startVista2D();
     108        void startVista2D(std::string vistaProjectfile, bool paintBackground, int posX, int posY, float zoom);
    99109
    100110        /**
     
    113123        Vista2D::VistaView* view;
    114124
    115         /**
    116         * XML config filename
    117         */
    118         std::string configFileName;
     125        ///**
     126        // * XML config filename
     127        // */
     128        //std::string configFileName;
    119129
    120         /**
    121         * Filename of the Vista2D project file.
    122         */
    123         std::string filename;
     130        ///**
     131        // * Filename of the Vista2D project file.
     132        // */
     133        //std::string filename;
    124134
    125         /**
    126         * Should the background of the Vista2D project be painted?
    127         */
    128         bool paintBackground;
     135        ///**
     136        // * Should the background of the Vista2D project be painted?
     137        // */
     138        //bool paintBackground;
    129139
    130         /**
    131         * X-Position to draw.
    132         */
    133         int position_x;
     140        ///**
     141        // * X-Position to draw.
     142        // */
     143        //int position_x;
    134144
    135         /**
    136         * Y-Position to draw.
    137         */
    138         int position_y;
     145        ///**
     146        // * Y-Position to draw.
     147        // */
     148        //int position_y;
    139149
    140         /**
    141         * Zoom factor to draw the project.
    142         */
    143         double zoom;
     150        ///**
     151        // * Zoom factor to draw the project.
     152        // */
     153        //double zoom;
    144154};
    145155
  • osgVisual/src/core/visual_core.cpp

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

    r153 r155  
    2222visual_vista2D::visual_vista2D(void)
    2323{
     24        OSG_NOTIFY (osg::ALWAYS ) << "visual_vista2D instantiated." << std::endl;
     25
    2426   // Create a Vista2D View
    2527   view = new Vista2D::VistaView();
    26 
    27         filename = "";
    28         paintBackground = false;;
    29         position_x = 600;
    30         position_y = 400;
    31         zoom = 0.5;
    3228}
    3329
     
    3632}
    3733
    38 void visual_vista2D::startVista2D(std::string vista2DFilename_)
     34void visual_vista2D::startVista2D(std::string vistaProjectfile, bool paintBackground, int posX, int posY, float zoom)
    3935{
    4036    /***************
    4137    load view
    4238    ***************/
    43         view->load( filename );
     39        view->load( vistaProjectfile );
    4440    view->setBackgroundMode(paintBackground);   // don't paint background
    45         view->setPosition( position_x,position_y);
     41        view->setPosition( posX, posY);
    4642        view->setZoom( zoom );
    4743
     
    5450}
    5551
    56 bool visual_vista2D::processXMLConfiguration()
     52bool visual_vista2D::processXMLConfiguration(std::string& configFileName, std::string& vistaProjectfile, bool& paintBackground, int& position_x, int& position_y, float& zoom)
    5753{
    5854        // Init XML
    5955        xmlDoc* tmpDoc;
    6056        bool disabled;
    61         xmlNode* config = util::getModuleXMLConfig( configFileName, "vista2D", tmpDoc, disabled );
     57        xmlNode* config = util::getModuleXMLConfig( configFileName, "vista2d", tmpDoc, disabled );
    6258
    6359        if( disabled)
     
    8985                                        if( attr_name == "filename" )
    9086                                        {
    91                                                 filename=attr_value
     87                                                vistaProjectfile=attr_value;
    9288                                        }
    9389
     
    137133        OSG_NOTIFY (osg::ALWAYS ) << "visual_vista2D initialize..";  // The sentence is finished by the init result...
    138134
    139         this->configFileName = configFileName;
    140 
    141         // Analyse XML configuration file
    142                 // Process XML configuration
    143         if(!processXMLConfiguration())
     135        std::string vistaProjectfile = "";
     136        bool paintBackground = false;
     137        int position_x = 0;
     138        int position_y = 0;
     139        float zoom = 1;
     140
     141        // Process XML configuration
     142        if(!processXMLConfiguration(configFileName, vistaProjectfile, paintBackground, position_x, position_y, zoom))
    144143                return false;   // Abort vista2D initialization.
    145144
    146         // Check if Vista2D file exist
    147         if (! osgDB::fileExists( filename ) )
    148         {
    149                 osg::notify( osg::WARN ) << "WARNING: visual_vista2D::createVistaOverlay - Could not find specified Vista2D projectfile. Skip adding Vista2D project." << std::endl;
     145        // Check if Vista2D project file exists
     146        if ( !osgDB::fileExists(vistaProjectfile) )
     147        {
     148                OSG_ALWAYS << "WARNING: visual_vista2D::init() - Specified vista2D projectfile '"<< vistaProjectfile <<"' does not exist! Skip using Vista2D!" << std::endl;
    150149                return false;
    151150        }
     
    186185        // Add Payload: Vista2D                 
    187186        osg::ref_ptr<visual_vista2D> vista2D = new visual_vista2D();
    188         vista2D->startVista2D( vista2DFilename_ );
     187        vista2D->startVista2D(vistaProjectfile, paintBackground, position_x, position_y, zoom);
    189188
    190189        vista2D.get()->setUseDisplayList( false );
Note: See TracChangeset for help on using the changeset viewer.