コード例 #1
0
void LuaDebuggerInterface::handleSplitMenuAction(ActionEventDetails* const details)
{
    try
    {
        std::string ValueString = boost::any_cast<std::string>(_SplitButton->getSelectionValue());

        BoostPath IconPath;
        if(ValueString.compare("Horizontal") == 0)
        {
            IconPath = BoostPath(_BaseIconDir / BoostPath("view-split-left-right.png"));
            _CodeTextArea->setIsSplit(true);
            _CodeTextArea->setSplitOrientation(SplitPanel::HORIZONTAL_ORIENTATION);
        }
        else if(ValueString.compare("Vertical") == 0)
        {
            IconPath = BoostPath(_BaseIconDir / BoostPath("view-split-top-bottom.png"));
            _CodeTextArea->setIsSplit(true);
            _CodeTextArea->setSplitOrientation(SplitPanel::VERTICAL_ORIENTATION);
        }
        else
        {
            IconPath = BoostPath(_BaseIconDir / BoostPath("view-split-none.png"));
            _CodeTextArea->setIsSplit(false);
        }

        _SplitButton->setImages(IconPath.string());
    }
    catch (boost::bad_lexical_cast &)
    {
        //Could not convert to string
    }
}
コード例 #2
0
void LuaDebuggerInterface::openScriptButtonAction(void)
{
    //Get a file using the open file dialog
    std::vector<WindowEventProducer::FileDialogFilter> Filters;
    Filters.push_back(WindowEventProducer::FileDialogFilter("Lua File Type","lua"));
    Filters.push_back(WindowEventProducer::FileDialogFilter("All","*"));

    std::vector<BoostPath> FilesToOpen;
    FilesToOpen = _CodeTextArea->
        getParentWindow()->
        getParentDrawingSurface()->
        getEventProducer()->
        openFileDialog("Open Lua Script File.",
                       Filters,
                       BoostPath("Data"),
                       true);

    //Try to open the files
    for(UInt32 i = 0; i < FilesToOpen.size(); ++i)
    {
        if(boost::filesystem::exists(FilesToOpen[i]))
        {
            _CodeTextArea->loadFile(FilesToOpen[i]);
        }
    }
    clearError();
}
コード例 #3
0
    virtual void actionPerformed(const ActionEventUnrecPtr e)
    {
        if(e->getSource() == LoadButton)
        {
            std::cout<<"Loading a file"<<std::endl;
            std::vector<WindowEventProducer::FileDialogFilter> Filters;
            Filters.push_back(WindowEventProducer::FileDialogFilter("All","*"));
            Filters.push_back(WindowEventProducer::FileDialogFilter("Lua Files","lua"));


            std::vector<BoostPath> FilesToOpen;
            FilesToOpen = TutorialWindow->openFileDialog("Open File Window",
                          Filters,
                          BoostPath(".."),
                          false);

            /*for(std::vector<BoostPath>::iterator Itor(FilesToOpen.begin()) ; Itor != FilesToOpen.end(); ++Itor)
            {
                _ContentPanel->addTabWithText(*Itor);
            }*/


            //GetSystemTime(&now);
            //unsigned int t1 = now.wSecond * 1000 + now.wMilliseconds;

            theTextEditor->loadNewFile(FilesToOpen[0]);

            //GetSystemTime(&now);
            //unsigned int t2 = now.wSecond * 1000 + now.wMilliseconds;

            //std::cout<<"\nstart time in milliseconds:"<<t1<<std::endl;    // start time in milliseconds
            //std::cout<<"\nduration in milliseconds:"<<t2-t1<<std::endl;        // end time in milliseconds


            //if(TheDocument)
            //    ExampleTextDomArea->setDocumentModel(TheDocument);
            //else std::cout<<"Failed Loading the Document"<<std::endl;
        }
        else if(e->getSource() == SaveButton)
        {
            std::cout<<"Saving a file"<<std::endl;
            std::vector<WindowEventProducer::FileDialogFilter> Filters;
            Filters.push_back(WindowEventProducer::FileDialogFilter("All","*"));
            Filters.push_back(WindowEventProducer::FileDialogFilter("Lua Files","lua"));

            BoostPath SavePath = TutorialWindow->saveFileDialog("Save File Window",
                                 Filters,
                                 std::string("newFile.lua"),
                                 BoostPath(".."),
                                 true);
            //theTextEditor->saveFile(SavePath);
        }
    }
コード例 #4
0
void LuaDebuggerInterface::saveScriptButtonAction(void)
{
    std::vector<WindowEventProducer::FileDialogFilter> Filters;
    Filters.push_back(WindowEventProducer::FileDialogFilter("Lua File Type","lua"));
    Filters.push_back(WindowEventProducer::FileDialogFilter("All","*"));

    BoostPath SavePath = _CodeTextArea->
        getParentWindow()->
        getParentDrawingSurface()->
        getEventProducer()->
        saveFileDialog("Save Lua Script to?",
                       Filters,
                       std::string("LuaScript.lua"),
                       BoostPath("Data"),
                       true);

    //Try to write the file
    std::ofstream OutFile(SavePath.string().c_str());
    if(OutFile)
    {
        OutFile << _CodeTextArea->getText();
        OutFile.close();
    }
}
コード例 #5
0
void LuaDebuggerInterface::clearScriptButtonAction(void)
{
    _CodeTextArea->clear();
    clearError();
}
コード例 #6
0
void LuaDebuggerInterface::executeScriptButtonAction(void)
{
    clearError();
    TheLuaManager->runScript(_CodeTextArea->getText());
}
コード例 #7
0
void LuaDebuggerInterface::createCodeEditor(void)
{
    //Create the Breakpoint images
    BoostPath BreakpointIconPath(_BaseIconDir / BoostPath("breakpoint.png")),
              BreakpointDisabledIconPath(_BaseIconDir / BoostPath("breakpoint-disabled.png")),
              BreakpointConditionalIconPath(_BaseIconDir / BoostPath("breakpoint-conditional.png")),
              BreakpointConditionalDisabledIconPath(_BaseIconDir / BoostPath("breakpoint-conditional-disabled.png")),
              BreakpointCountIconPath(_BaseIconDir / BoostPath("breakpoint-count.png")),
              BreakpointCountDisabledIconPath(_BaseIconDir / BoostPath("breakpoint-count-disabled.png"));
    
    //Breakpoint Button prototypes
    //Regular Breakpoint
    ButtonRecPtr BreakpointProtoButton = Button::create();
    BreakpointProtoButton->setPreferredSize(Vec2f(18.0f, 18.0f));
    BreakpointProtoButton->setImages(BreakpointIconPath.string());
    BreakpointProtoButton->setDisabledImage(BreakpointDisabledIconPath.string());
    BreakpointProtoButton->setBorders(NULL);
    BreakpointProtoButton->setBackgrounds(NULL);
    BreakpointProtoButton->setForegrounds(NULL);

    //Count Breakpoint
    ButtonRecPtr BreakpointCountProtoButton = Button::create();
    BreakpointCountProtoButton->setPreferredSize(Vec2f(18.0f, 18.0f));
    BreakpointCountProtoButton->setImages(BreakpointCountIconPath.string());
    BreakpointCountProtoButton->setDisabledImage(BreakpointCountDisabledIconPath.string());
    BreakpointCountProtoButton->setBorders(NULL);
    BreakpointCountProtoButton->setBackgrounds(NULL);
    BreakpointCountProtoButton->setForegrounds(NULL);

    //Conditional breakpoint
    ButtonRecPtr BreakpointConditionalProtoButton = Button::create();
    BreakpointConditionalProtoButton->setPreferredSize(Vec2f(18.0f, 18.0f));
    BreakpointConditionalProtoButton->setImages(BreakpointConditionalIconPath.string());
    BreakpointConditionalProtoButton->setDisabledImage(BreakpointConditionalDisabledIconPath.string());
    BreakpointConditionalProtoButton->setBorders(NULL);
    BreakpointConditionalProtoButton->setBackgrounds(NULL);
    BreakpointConditionalProtoButton->setForegrounds(NULL);

    //Create the default font
    _CodeFont = UIFont::create();
    _CodeFont->setFamily("Courier New");
    _CodeFont->setSize(21);
    _CodeFont->setGlyphPixelSize(22);
    _CodeFont->setAntiAliasing(false);

    // Create a TextArea component
    _CodeTextArea = TextEditor::create();
    _CodeTextArea->setIsSplit(false);
    _CodeTextArea->setClipboardVisible(false);
    //_CodeTextArea->getTextDomArea()->setFont(_CodeFont);
    //_CodeTextArea->setGutterWidth(50.0f);
    _CodeTextArea->setText(createDefaultCodeText());

    //_CodeTextArea->connectCaretChanged(boost::bind(&LuaDebuggerInterface::codeAreaCaretChanged,this, _1));
    //_CodeTextArea->connectMouseClicked(boost::bind(&LuaDebuggerInterface::handleCodeAreaMouseClicked,this, _1));

    _MainSplitPanel = SplitPanel::create();
    _MainSplitPanel->setMinComponent(_CodeTextArea);
    _MainSplitPanel->setMaxComponent(_InfoTabPanel);
    _MainSplitPanel->setOrientation(SplitPanel::VERTICAL_ORIENTATION);
    _MainSplitPanel->setDividerPosition(0.7);
    // location from the left/top
    _MainSplitPanel->setDividerSize(4);
    _MainSplitPanel->setMaxDividerPosition(.8);
    _MainSplitPanel->setMinDividerPosition(.2);

    //Code Area Info
    LabelRefPtr LineLabel = Label::create();
    LineLabel->setText("Line:");
    LineLabel->setPreferredSize(Vec2f(40.0f, 30.0f));
    LineLabel->setAlignment(Vec2f(1.0f, 0.5f));

    _LineValueLabel = Label::create();
    _LineValueLabel->setText("");
    _LineValueLabel->setPreferredSize(Vec2f(40.0f, 30.0f));

    LabelRefPtr ColumnLabel = Label::create();
    ColumnLabel->setText("Column:");
    ColumnLabel->setPreferredSize(Vec2f(55.0f, 30.0f));
    ColumnLabel->setAlignment(Vec2f(1.0f, 0.5f));

    _ColumnValueLabel = Label::create();
    _ColumnValueLabel->setText("");
    _ColumnValueLabel->setPreferredSize(Vec2f(40.0f, 30.0f));
    //TextArea Info Panel

    _CodeAreaInfoPanel = Panel::create();

    SpringLayoutRefPtr CodeAreaInfoLayout = SpringLayout::create();

    //ColumnValueLabel
    CodeAreaInfoLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, _ColumnValueLabel, 0, SpringLayoutConstraints::NORTH_EDGE, _CodeAreaInfoPanel);
    CodeAreaInfoLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, _ColumnValueLabel, 0, SpringLayoutConstraints::SOUTH_EDGE, _CodeAreaInfoPanel);
    CodeAreaInfoLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _ColumnValueLabel, 0, SpringLayoutConstraints::EAST_EDGE, _CodeAreaInfoPanel);

    //ColumnLabel    
    CodeAreaInfoLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, ColumnLabel, 0, SpringLayoutConstraints::NORTH_EDGE, _CodeAreaInfoPanel);
    CodeAreaInfoLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, ColumnLabel, 0, SpringLayoutConstraints::SOUTH_EDGE, _CodeAreaInfoPanel);
    CodeAreaInfoLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, ColumnLabel, -1, SpringLayoutConstraints::WEST_EDGE, _ColumnValueLabel);

    //LineValueLabel    
    CodeAreaInfoLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, _LineValueLabel, 0, SpringLayoutConstraints::NORTH_EDGE, _CodeAreaInfoPanel);
    CodeAreaInfoLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, _LineValueLabel, 0, SpringLayoutConstraints::SOUTH_EDGE, _CodeAreaInfoPanel);
    CodeAreaInfoLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _LineValueLabel, -1, SpringLayoutConstraints::WEST_EDGE, ColumnLabel);

    //LineLabel    
    CodeAreaInfoLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, LineLabel, 0, SpringLayoutConstraints::NORTH_EDGE, _CodeAreaInfoPanel);
    CodeAreaInfoLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, LineLabel, 0, SpringLayoutConstraints::SOUTH_EDGE, _CodeAreaInfoPanel);
    CodeAreaInfoLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, LineLabel, -1, SpringLayoutConstraints::WEST_EDGE, _LineValueLabel);

    _CodeAreaInfoPanel->setPreferredSize(Vec2f(400.0f, 22.0f));
    _CodeAreaInfoPanel->pushToChildren(LineLabel);
    _CodeAreaInfoPanel->pushToChildren(_LineValueLabel);
    _CodeAreaInfoPanel->pushToChildren(ColumnLabel);
    _CodeAreaInfoPanel->pushToChildren(_ColumnValueLabel);
    _CodeAreaInfoPanel->setBorders(NULL);
    _CodeAreaInfoPanel->setLayout(CodeAreaInfoLayout);
}
コード例 #8
0
ファイル: 06Editor.cpp プロジェクト: achvas88/OpenSGToolbox
int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc,argv);
    {
        // Set up Window
        WindowEventProducerRecPtr TutorialWindow = createNativeWindow();
        TutorialWindow->initWindow();

        // Create the SimpleSceneManager helper
        SimpleSceneManager sceneManager;
        TutorialWindow->setDisplayCallback(boost::bind(display, &sceneManager));
        TutorialWindow->setReshapeCallback(boost::bind(reshape, _1, &sceneManager));

        // Tell the Manager what to manage
        sceneManager.setWindow(TutorialWindow);


        // Make Torus Node (creates Torus in background of scene)
        NodeRefPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);

        // Make Main Scene Node and add the Torus
        NodeRefPtr scene = Node::create();
        scene->setCore(Group::create());
        scene->addChild(TorusGeometryNode);

        // Create the Graphics
        GraphicsRefPtr TutorialGraphics = Graphics2D::create();

        // Initialize the LookAndFeelManager to enable default settings
        LookAndFeelManager::the()->getLookAndFeel()->init();

	    TextEditorRefPtr theTextEditor = TextEditor::create();
	    theTextEditor->setPreferredSize(Vec2f(1000,700));
        theTextEditor->setIsSplit(false);
        theTextEditor->setClipboardVisible(false);

        //Toggle Button for clipboard
        ToggleButtonRefPtr ClipboardButton = ToggleButton::create();
        ClipboardButton->setPreferredSize(Vec2f(80, 40));
        ClipboardButton->setText("Clipboard");
        ClipboardButton->connectButtonSelected(boost::bind(handleClipboardSelected,
                                                           _1,
                                                           theTextEditor.get()));
        ClipboardButton->connectButtonDeselected(boost::bind(handleClipboardDeselected,
                                                           _1,
                                                           theTextEditor.get()));
        
        //Toggle Button for split panel
        ToggleButtonRefPtr SplitButton = ToggleButton::create();
        SplitButton->setPreferredSize(Vec2f(80, 40));
        SplitButton->setText("Split");
        SplitButton->connectButtonSelected(boost::bind(handleSplitSelected,
                                                           _1,
                                                           theTextEditor.get()));
        SplitButton->connectButtonDeselected(boost::bind(handleSplitDeselected,
                                                           _1,
                                                           theTextEditor.get()));
        
        ButtonRefPtr LoadButton = Button::create();

	    LoadButton->setMinSize(Vec2f(50, 25));
        LoadButton->setMaxSize(Vec2f(200, 100));
        LoadButton->setPreferredSize(Vec2f(80, 40));
        LoadButton->setToolTipText("Click to open a file browser window");
        LoadButton->setText("Load File");

        LoadButton->connectActionPerformed(boost::bind(handleLoadButtonAction, _1, TutorialWindow.get(), theTextEditor.get()));

    	  
	    ButtonRefPtr SaveButton = Button::create();

	    SaveButton->setMinSize(Vec2f(50, 25));
        SaveButton->setMaxSize(Vec2f(200, 100));
        SaveButton->setPreferredSize(Vec2f(80, 40));
        SaveButton->setToolTipText("Click to save the currently opened file");
        SaveButton->setText("Save File");

        SaveButton->connectActionPerformed(boost::bind(handleSaveButtonAction, _1, TutorialWindow.get(),theTextEditor.get()));

        //Button Panel
        LayoutRefPtr ButtonPanelLayout = FlowLayout::create();

        PanelRecPtr ButtonPanel = Panel::createEmpty();
        ButtonPanel->setPreferredSize(Vec2f(300, 300));
        ButtonPanel->setLayout(ButtonPanelLayout);
        ButtonPanel->pushToChildren(LoadButton);
        ButtonPanel->pushToChildren(SaveButton);
        ButtonPanel->pushToChildren(SplitButton);
        ButtonPanel->pushToChildren(ClipboardButton);

        // Create The Main InternalWindow
        // Create Background to be used with the Main InternalWindow
        ColorLayerRefPtr MainInternalWindowBackground = ColorLayer::create();
        MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));

        LayoutRefPtr MainInternalWindowLayout = FlowLayout::create();

        InternalWindowRefPtr MainInternalWindow = InternalWindow::create();
        //MainInternalWindow->pushToChildren(TextAreaScrollPanel);
        MainInternalWindow->pushToChildren(theTextEditor);
        MainInternalWindow->pushToChildren(ButtonPanel);
        MainInternalWindow->setLayout(MainInternalWindowLayout);
        MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
        MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
        MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.95f,0.95f));
        //MainInternalWindow->setDrawTitlebar(true);
        //MainInternalWindow->setResizable(true);

        // Create the Drawing Surface
        UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
        TutorialDrawingSurface->setGraphics(TutorialGraphics);
        TutorialDrawingSurface->setEventProducer(TutorialWindow);
    	
	    TutorialDrawingSurface->openWindow(MainInternalWindow);

        // Create the UI Foreground Object
        UIForegroundRefPtr TutorialUIForeground = UIForeground::create();

        TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);


        sceneManager.setRoot(scene);

        // Add the UI Foreground Object to the Scene
        ViewportRefPtr TutorialViewport = sceneManager.getWindow()->getPort(0);
        TutorialViewport->addForeground(TutorialUIForeground);
    		

        // Show the whole Scene
        sceneManager.showAll();

    	
        //Open Window
        Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.95f);
        Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
        TutorialWindow->openWindow(WinPos,
                                   WinSize,
                                   "06Editor");
        TutorialWindow->connectKeyTyped(boost::bind(keyTyped, _1, theTextEditor.get()));

        commitChanges();

        //Enter main Loop
        TutorialWindow->mainLoop();
    }

    osgExit();

    return 0;
}
コード例 #9
0
int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc,argv);

    // Set up Window
    TutorialWindow = createNativeWindow();
    TutorialWindow->initWindow();

    TutorialWindow->setDisplayCallback(display);
    TutorialWindow->setReshapeCallback(reshape);

    /******************************************************

             Add MouseListeners and WindowListeners
             to the WindowEvent.

    ******************************************************/

    TutorialMouseListener TheTutorialMouseListener;
    TutorialMouseListener1 BasicListener;
    TutorialMouseMotionListener TheTutorialMouseMotionListener;
    TutorialWindow->addMouseListener(&TheTutorialMouseListener);
    TutorialWindow->addMouseMotionListener(&TheTutorialMouseMotionListener);
    TutorialKeyListener TheKeyListener;
    TutorialWindow->addKeyListener(&TheKeyListener);

    // Make Torus Node (creates Torus in background of scene)
    NodeRefPtr TorusGeometryNode = makeTorus(90, 270, 16, 16);

    // Make Main Scene Node and add the Torus
    NodeRefPtr scene = OSG::Node::create();
    scene->setCore(OSG::Group::create());
    scene->addChild(TorusGeometryNode);

    // Create the Graphics
    GraphicsRefPtr TutorialGraphics = OSG::Graphics2D::create();

    // Initialize the LookAndFeelManager to enable default settings
    LookAndFeelManager::the()->getLookAndFeel()->init();


    LoadButton = Button::create();

    LoadButton->setMinSize(Vec2f(50, 25));
    LoadButton->setMaxSize(Vec2f(200, 100));
    LoadButton->setPreferredSize(Vec2f(100, 50));
    LoadButton->setToolTipText("Click to open a file browser window");
    LoadButton->setText("Load File");

    LoadButton->addActionListener(&BasicListener);

    SaveButton = Button::create();

    SaveButton->setMinSize(Vec2f(50, 25));
    SaveButton->setMaxSize(Vec2f(200, 100));
    SaveButton->setPreferredSize(Vec2f(100, 50));
    SaveButton->setToolTipText("Click to save the currently opened file");
    SaveButton->setText("Save File");

    SaveButton->addActionListener(&BasicListener);

    theTextEditor = TextEditor::create();
    theTextEditor->setPreferredSize(Vec2f(600,400));

    /*

    UIFontRefPtr _Font = UIFont::create();
    _Font->setFamily("SANS");
    _Font->setGap(3);
    _Font->setGlyphPixelSize(46);
    _Font->setSize(15);
    _Font->setTextureWidth(0);
    _Font->setStyle(TextFace::STYLE_PLAIN);

    ExampleTextDomArea->setPreferredSize(Vec2f(600, 400));
    ExampleTextDomArea->setWrapStyleWord(false);
    ExampleTextDomArea->setMinSize(Vec2f(600,400));
    ExampleTextDomArea->setFont(_Font);

    ExampleAdvancedTextDomArea = OSG::AdvancedTextDomArea::create();
    ExampleAdvancedTextDomArea->setPreferredSize(Vec2f(600,400));
    ExampleAdvancedTextDomArea->setMinSize(Vec2f(600,400));
    ExampleAdvancedTextDomArea->setGutterVisible(true);
    ExampleAdvancedTextDomArea->pushToChildren(ExampleTextDomArea);
    ExampleAdvancedTextDomArea->setLayout(LayoutRefPtr(OSG::FlowLayout::create()));
    ExampleAdvancedTextDomArea->setPreferredSize(Vec2f(600,400));
    ExampleAdvancedTextDomArea->setMinSize(Vec2f(600,400));

    ScrollPanelRefPtr TextAreaScrollPanel = ScrollPanel::create();
    TextAreaScrollPanel->setPreferredSize(Vec2f(600,400));
    TextAreaScrollPanel->setMinSize(Vec2f(600,400));
    TextAreaScrollPanel->setViewComponent(ExampleAdvancedTextDomArea);

    */

    ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
    MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));

    LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();

    InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
    MainInternalWindow->pushToChildren(theTextEditor);
    MainInternalWindow->pushToChildren(LoadButton);
    MainInternalWindow->pushToChildren(SaveButton);
    MainInternalWindow->setLayout(MainInternalWindowLayout);
    MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
    MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
    MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.85f,0.85f));
    MainInternalWindow->setDrawTitlebar(true);
    MainInternalWindow->setResizable(false);


    /******************************************************

             The Drawing Surface is created the
             same as with previous Tutorials
             (however the MainInternalWindow is created
             in a function below).

    ******************************************************/

    UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
    TutorialDrawingSurface->setGraphics(TutorialGraphics);
    TutorialDrawingSurface->setEventProducer(TutorialWindow);

    TutorialDrawingSurface->openWindow(MainInternalWindow);

    /******************************************************

            Create the 3D UIRectangle.  This allows
            the DrawingSurface to be rotated relative
            to the screen, allowing a 3D aspect to
            the DrawingSurface.  The Surface
            can still be interacted with, so Buttons,
            Menus, etc. all will still function
            normally.

            -setPoint(Pnt3f): Determine the location
                of the UIRectangle in 3D space.  Keep
                in mind that (0,0,0) is located
                directly in the center of the sceen.
                (For our purposes it is the center
                of the tori.) The point is located
                on the lower left corner of the
                rectangle.
            -setWidth(float): Determine the Width
                of the UIRectangle.  This may
                physically appear different depending
                on where the UIRectangle is placed
                as above (due to it being located
                further away, etc).
            -setHeight(float): Determine the Height
                of the UIRectangle.  This may
                physically appear different depending
                on where the UIRectangle is placed
                as above (due to it being located
                further away, etc).
            -setDrawingSurface(DrawingSurface):
                Determine what DrawingSurface is
                drawn on the UIRectangle.  This
                will typically be the main
                DrawingSurface, however, multiple
                DrawingSurfaces can be used with
                multiple UIRectangles.


    ******************************************************/

    //Make A 3D Rectangle to draw the UI on
    UIRectangleRefPtr ExampleUIRectangle = UIRectangle::create();
    ExampleUIRectangle->setPoint(Pnt3f(-400,-400,200));
    ExampleUIRectangle->setWidth(800.0);
    ExampleUIRectangle->setHeight(800.0);
    ExampleUIRectangle->setDrawingSurface(TutorialDrawingSurface);

    /******************************************************

            Because the previous Tutorials used a
            Viewport to view the scene, which is
            no longer being used, the UIRectangle
            must be added to the scene for it to
            be displayed (identical to how the
            Torus is added).

            First, create a Node, and set its
            core to be the UIRectangle.  Then,
            add that to the scene Node which
            is created above.  This scene is
            then set as the Root for the view.
            It is possible to change this Root
            to be just the UIRectangle (as
            commented out below).

    ******************************************************/
    NodeRefPtr ExampleUIRectangleNode = OSG::Node::create();
    ExampleUIRectangleNode->setCore(ExampleUIRectangle);

    // Add the UIRectangle as a child to the scene
    scene->addChild(ExampleUIRectangleNode);

    // Create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;

    // Tell the Manager what to manage
    mgr->setWindow(TutorialWindow);
    mgr->setRoot(scene);
    //mgr->setRoot(ExampleUIRectangleNode);

    // Show the whole Scene
    mgr->showAll();


    //Open Window
    Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
    Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
    TutorialWindow->openWindow(WinPos,
                               WinSize,
                               "3DNotepad!!");

    //Enter main Loop
    TutorialWindow->mainLoop();

    osgExit();

    return 0;
}