当前位置: 首页>>代码示例>>C++>>正文


C++ ViewportRefPtr::setBackground方法代码示例

本文整理汇总了C++中ViewportRefPtr::setBackground方法的典型用法代码示例。如果您正苦于以下问题:C++ ViewportRefPtr::setBackground方法的具体用法?C++ ViewportRefPtr::setBackground怎么用?C++ ViewportRefPtr::setBackground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ViewportRefPtr的用法示例。


在下文中一共展示了ViewportRefPtr::setBackground方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: doMain

//
// setup scene
//
static int doMain(int argc, char *argv[])
{
    preloadSharedObject("OSGFileIO");
    preloadSharedObject("OSGImageFileIO");

    osgInit(argc,argv);

    int winid = setupGLUT(&argc, argv);

    win = GLUTWindow::create();
    win->setGlutId(winid);
    win->init();

    if(argc < 2)
    {
        FWARNING(("No file given!\n"));
        FWARNING(("Supported file formats:\n"));

        std::list<const char*> suffixes;
        SceneFileHandler::the()->getSuffixList(suffixes);

        for(std::list<const char*>::iterator it  = suffixes.begin();
                                            it != suffixes.end();
                                        ++it)
        {
            FWARNING(("%s\n", *it));
        }

        staticScene = createStaticScene();
    }
    else
    {
        staticScene = SceneFileHandler::the()->read(argv[1]);
    }

    dynamicScene = createDynamicScene();

    commitChanges();

    mgr = SimpleSceneManager::create();

    NodeUnrecPtr root = makeCoredNode<Group>();
    root->addChild(staticScene);

    mgr->setWindow(win);
    mgr->setRoot  (root);

    GradientBackgroundUnrecPtr background = GradientBackground::create();
    background->addLine(Color3f(0,0,0), 0);
    background->addLine(Color3f(1,1,1), 1);

    staticVp = win->getPort(0);
    staticVp->setBackground(background);

    camera = staticVp->getCamera();

    mgr->showAll();

    return 0;
}
开发者ID:jondo2010,项目名称:OpenSG,代码行数:63,代码来源:dyndrawing1.cpp

示例2: createDynamicViewport

static void createDynamicViewport()
{
    win->subPortByObj(staticVp);

    FBOBackgroundUnrecPtr fboBckgnd = FBOBackground::create();
    fboBckgnd->setFrameBufferObject(spSimpleFBO->fbo());

    NodeUnrecPtr root = makeCoredNode<Group>();
    root->addChild(dynamicScene);

    mgr->setRoot(root);

    dynamicVp = Viewport::create();
    dynamicVp->setRoot      (rootNode(root));
    dynamicVp->setBackground(fboBckgnd);
    dynamicVp->setCamera    (camera);
    dynamicVp->setSize      (0,0, 1,1);

    mgr->getNavigator()->setViewport(dynamicVp);
    
    win->addPort(dynamicVp);

    mgr->update();
}
开发者ID:jondo2010,项目名称:OpenSG,代码行数:24,代码来源:dyndrawing1.cpp

示例3: main


//.........这里部分代码省略.........
		ExampleList->setModel(ExampleListModel);

    ExampleList->setSelectionModel(ExampleListSelectionModel);


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

            Determine the SelectionModel
            -SINGLE_SELECTION lets you select ONE item
                via a single mouse click
            -SINGLE_INTERVAL_SELECTION lets you select
                one interval via mouse and SHIFT key
            -MULTIPLE_INTERVAL_SELECTION lets you select
                via mouse, and SHIFT and CONTRL keys

            Note: this tutorial is currently set up
            to allow for this to be changed via 
			TogggleButtons with ActionListeners attached 
            to them so this code is commented out.

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

    //SelectionModel.setMode(DefaultListSelectionModel::SINGLE_SELECTION);
    //SelectionModel.setMode(DefaultListSelectionModel::SINGLE_INTERVAL_SELECTION);
    //SelectionModel.setMode(DefaultListSelectionModel::MULTIPLE_INTERVAL_SELECTION);

    // Create a ScrollPanel for easier viewing of the List (see 27ScrollPanel)
    ScrollPanelRefPtr ExampleScrollPanel = ScrollPanel::create();
        ExampleScrollPanel->setPreferredSize(Vec2f(200,300));
        ExampleScrollPanel->setHorizontalResizePolicy(ScrollPanel::RESIZE_TO_VIEW);
        //ExampleScrollPanel->setVerticalResizePolicy(ScrollPanel::RESIZE_TO_VIEW);
    ExampleScrollPanel->setViewComponent(ExampleList);

    // Create MainFramelayout
    FlowLayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
    MainInternalWindowLayout->setOrientation(FlowLayout::VERTICAL_ORIENTATION);
    MainInternalWindowLayout->setMajorAxisAlignment(0.5f);
    MainInternalWindowLayout->setMinorAxisAlignment(0.5f);

    LabelRefPtr ListLabel = Label::create();
    ListLabel->setText("Background Colors List");
    ListLabel->setPreferredSize(Vec2f(200.0f, ListLabel->getPreferredSize().y()));

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

    InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
    MainInternalWindow->pushToChildren(ListLabel);
    MainInternalWindow->pushToChildren(ExampleScrollPanel);
    MainInternalWindow->setLayout(MainInternalWindowLayout);
    MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
    MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
    MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.7f,0.5f));
    MainInternalWindow->setDrawTitlebar(false);
    MainInternalWindow->setResizable(false);

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

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

        TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);

    // Create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;

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

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

    // 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,
            "44MFieldList");

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

    osgExit();

    return 0;
}
开发者ID:danguilliams,项目名称:OpenSGToolbox,代码行数:101,代码来源:44MFieldList.cpp

示例4: main


//.........这里部分代码省略.........

        NodeRefPtr RootNode = Node::create();
        RootNode->setCore(Group::create());
        RootNode->addChild(TheLightNode);
        RootNode->addChild(TheLightBeaconNode);
        setName(RootNode,"Root Node");

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

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

        //Create the Main interface
        LuaDebuggerInterface TheLuaDebuggerInterface;

        // 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));

        BorderLayoutRefPtr MainInternalWindowLayout = BorderLayout::create();

        //Split Panel
        BorderLayoutConstraintsRefPtr SplitPanelConstraints = BorderLayoutConstraints::create();
        SplitPanelConstraints->setRegion(BorderLayoutConstraints::BORDER_CENTER);
        TheLuaDebuggerInterface.getMainSplitPanel()->setConstraints(SplitPanelConstraints);

        BorderLayoutConstraintsRefPtr ButtonPanelConstraints = BorderLayoutConstraints::create();
        ButtonPanelConstraints->setRegion(BorderLayoutConstraints::BORDER_NORTH);
        TheLuaDebuggerInterface.getButtonPanel()->setConstraints(ButtonPanelConstraints);

        BorderLayoutConstraintsRefPtr CodeAreaInfoPanelConstraints = BorderLayoutConstraints::create();
        CodeAreaInfoPanelConstraints->setRegion(BorderLayoutConstraints::BORDER_SOUTH);
        TheLuaDebuggerInterface.getCodeAreaInfoPanel()->setConstraints(CodeAreaInfoPanelConstraints);

        InternalWindowRefPtr MainInternalWindow = InternalWindow::create();
        MainInternalWindow->pushToChildren(TheLuaDebuggerInterface.getButtonPanel());
        MainInternalWindow->pushToChildren(TheLuaDebuggerInterface.getMainSplitPanel());
        MainInternalWindow->pushToChildren(TheLuaDebuggerInterface.getCodeAreaInfoPanel());
        MainInternalWindow->setLayout(MainInternalWindowLayout);
        MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
        MainInternalWindow->setTitle("Lua Debugger");
        setName(MainInternalWindow,"Internal Window");

        // 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);

        //Scene Background
        GradientBackgroundRefPtr SceneBackground = GradientBackground::create();
        SceneBackground->addLine(Color3f(0.0,0.0,0.0),0.0);
        setName(SceneBackground,"Scene Background");

        // Tell the Manager what to manage
        sceneManager.setWindow(TutorialWindow);
        sceneManager.setRoot(RootNode);
        //sceneManager.setHeadlight(false);

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

        TutorialWindow->connectKeyTyped(boost::bind(keyTyped,
                                                    _1,
                                                    &TheLuaDebuggerInterface));

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


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

        MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
        MainInternalWindow->setPreferredSize(WinSize * 0.85);

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

        TheLuaManager->uninit();
    }

    osgExit();

    return 0;
}
开发者ID:achvas88,项目名称:OpenSGToolbox,代码行数:101,代码来源:03LuaDebugger.cpp

示例5: main

int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc,argv);

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

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

    TutorialKeyListener TheKeyListener;
    TutorialWindow->addKeyListener(&TheKeyListener);

    // 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 = 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();

    //Background
    TutorialBackground = GradientBackground::create();
    TutorialBackground->addLine(Color3f(1.0,0.0,0.0), 0.0);
    TutorialBackground->addLine(Color3f(0.0,1.0,0.0), 0.2);
    TutorialBackground->addLine(Color3f(0.0,0.0,1.0), 0.4);
    TutorialBackground->addLine(Color3f(0.0,1.0,1.0), 0.6);
    TutorialBackground->addLine(Color3f(1.0,1.0,0.0), 0.8);
    TutorialBackground->addLine(Color3f(1.0,1.0,1.0), 1.0);

	TheUndoManager = UndoManager::create();
	UndoManagerChangeListener TheUndoManagerChangeListener;
	TheUndoManager->addChangeListener(&TheUndoManagerChangeListener);
    
    LabelRefPtr SingleFieldLabel = OSG::Label::create();
    SingleFieldLabel->setText("Single Field");
    SingleFieldLabel->setBorders(NULL);
    SingleFieldLabel->setBackgrounds(NULL);

    LabelRefPtr MultiFieldLabel = OSG::Label::create();
    MultiFieldLabel->setText("Multi Field");
    MultiFieldLabel->setBorders(NULL);
    MultiFieldLabel->setBackgrounds(NULL);

    LabelRefPtr SinglePtrFieldLabel = OSG::Label::create();
    SinglePtrFieldLabel->setText("Single Ptr Field");
    SinglePtrFieldLabel->setBorders(NULL);
    SinglePtrFieldLabel->setBackgrounds(NULL);

    LabelRefPtr MultiPtrFieldLabel = OSG::Label::create();
    MultiPtrFieldLabel->setText("Multi Ptr Field");
    MultiPtrFieldLabel->setBorders(NULL);
    MultiPtrFieldLabel->setBackgrounds(NULL);

    TabPanelRefPtr ExampleTabPanel = OSG::TabPanel::create();
    ExampleTabPanel->setPreferredSize(Vec2f(600,600));
    ExampleTabPanel->addTab(SingleFieldLabel, createSingleFieldPanel());
    ExampleTabPanel->addTab(MultiFieldLabel, createMultiFieldPanel());
    ExampleTabPanel->addTab(SinglePtrFieldLabel, createSinglePtrFieldPanel());
    ExampleTabPanel->addTab(MultiPtrFieldLabel, createMultiPtrFieldPanel());
    ExampleTabPanel->setTabAlignment(0.5f);
    ExampleTabPanel->setTabPlacement(TabPanel::PLACEMENT_NORTH);
    ExampleTabPanel->setSelectedIndex(0);

	//UndoList
	UndoRedoListModel = DefaultListModel::create();
    UndoRedoListModel->pushBack(boost::any(std::string("Top")));
	ListSelectionModelPtr UndoRedoListSelectionModel(new DefaultListSelectionModel());

	UndoRedoList = List::create();
        UndoRedoList->setPreferredSize(Vec2f(200, 300));
        UndoRedoList->setOrientation(List::VERTICAL_ORIENTATION);
		UndoRedoList->setModel(UndoRedoListModel);

    UndoRedoList->setSelectionModel(UndoRedoListSelectionModel);

    UndoRedoListListener TheUndoRedoListListener;
    UndoRedoList->getSelectionModel()->addListSelectionListener(&TheUndoRedoListListener);

    UndoButton = OSG::Button::create();
            UndoButton->setText("Undo");
			UndoButton->setEnabled(TheUndoManager->numberOfUndos() != 0);
    UndoButtonActionListener TheUndoButtonActionListener;
    UndoButton->addActionListener(&TheUndoButtonActionListener);
	

    RedoButton = OSG::Button::create();
            RedoButton->setText("Redo");
			RedoButton->setEnabled(TheUndoManager->numberOfRedos() != 0);
    RedoButtonActionListener TheRedoButtonActionListener;
    RedoButton->addActionListener(&TheRedoButtonActionListener);

//.........这里部分代码省略.........
开发者ID:msteners,项目名称:OpenSGToolbox,代码行数:101,代码来源:01ChangeFieldCommands.cpp

示例6: main

// Initialize GLUT & OpenSG and set up the scene
int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc,argv);

    // GLUT init
    int winid = setupGLUT(&argc, argv);

    if(argc >= 2)
        scene = SceneFileHandler::the()->read(argv[1]);
    else
        scene = SceneFileHandler::the()->read("Data/tie.wrl");
    
    if(scene == NULL)
        scene = makeTorus(0.3, 4, 16, 64);

    // init material
    phong_chunk = createPhongShaderMaterial();
    
    // get all the Materials of the current scene
    getAllMaterials(scene, materials);

    // add the phong material chunk to every found material
    for(int i = 0; i < materials.size(); ++i)
    {
        (materials[i])->addChunk(phong_chunk);
    }
    phong_active = true;

    // open a new scope, because the pointers below should go out of scope
    // before entering glutMainLoop.
    // Otherwise OpenSG will complain about objects being alive after shutdown.
    {
        // the connection between GLUT and OpenSG
        GLUTWindowRefPtr gwin = GLUTWindow::create();
        gwin->setGlutId(winid);
        gwin->init     (     );
        
        // create the SimpleSceneManager helper
        _mgr = new SimpleSceneManager;
        
        // tell the manager what to manage
        _mgr->setWindow      (gwin );
        _mgr->setRoot        (scene);
        _mgr->turnHeadlightOn(     );
        
        commitChanges();
        
        // show the whole scene
        _mgr->showAll();
        
        // create a gradient background.
        GradientBackgroundRefPtr gbg = GradientBackground::create();
        gbg->clearLines();
        gbg->addLine(Color3f(0.7, 0.7, 0.8), 0);
        gbg->addLine(Color3f(0.0, 0.1, 0.3), 1);
        
        //set gradient background
        ViewportRefPtr vp = gwin->getPort(0);
        vp->setBackground(gbg);
        
        commitChanges();
    }

    // GLUT main loop
    glutMainLoop();

    return 0;
}
开发者ID:DaveHarrison,项目名称:OpenSGDevMaster,代码行数:70,代码来源:phongshaderwithglmaterials.cpp

示例7: attachApplication


//.........这里部分代码省略.........
    //{
        //SWARNING << "Could not load Torus Knot from: "
                 //<< TorusKnotFile.string() << " because this file doesn't exist."  << std::endl;
        TorusGeometryNode = makeTorus(.5, 2, 64, 64);
    //}

    //Scene Transformation
    TransformRefPtr SceneTransformCore = Transform::create();

    NodeRefPtr SceneTransformNode = Node::create();
    SceneTransformNode->setCore(SceneTransformCore);
    SceneTransformNode->addChild(TorusGeometryNode);

    //Light
    NodeRefPtr LightBeaconNode = Node::create();
    LightBeaconNode->setCore(Transform::create());

    DirectionalLightRefPtr SceneLightCore = DirectionalLight::create();
    SceneLightCore->setDirection(1.0,0.0,0.0);
    SceneLightCore->setBeacon(LightBeaconNode);

    NodeRefPtr SceneLightNode = Node::create();
    SceneLightNode->setCore(SceneLightCore);
    SceneLightNode->addChild(SceneTransformNode);


    // Make Main Scene Node and add the Torus
    NodeRefPtr DefaultRootNode = OSG::Node::create();
    DefaultRootNode->setCore(OSG::Group::create());
    DefaultRootNode->addChild(CameraBeaconNode);
    DefaultRootNode->addChild(SceneLightNode);
    DefaultRootNode->addChild(LightBeaconNode);

    //Camera
    PerspectiveCameraRefPtr DefaultCamera = PerspectiveCamera::create();
    DefaultCamera->setBeacon(CameraBeaconNode);
    DefaultCamera->setFov   (osgDegree2Rad(60.f));
    DefaultCamera->setNear  (0.1f);
    DefaultCamera->setFar   (10000.f);

    //Background
    GradientBackgroundRefPtr DefaultBackground = GradientBackground::create();
    DefaultBackground->addLine(Color3f(0.0f,0.0f,0.0f), 0.0f);
    DefaultBackground->addLine(Color3f(0.0f,0.0f,0.5f), 1.0f);

    //Animation
    //KeyFrames
    KeyframeTransformationSequenceRefPtr TransformationKeyframes = KeyframeTransformationSequenceMatrix4f::create();
    OSG::Matrix TempMat;

    TransformationKeyframes->addKeyframe(TempMat,0.0f);
    TempMat.setRotate(Quaternion(Vec3f(0.0f,1.0f,0.0f), 3.14159f*0.5));
    TransformationKeyframes->addKeyframe(TempMat,4.0f);
    TempMat.setRotate(Quaternion(Vec3f(0.0f,1.0f,0.0f), 3.14159f*1.0));
    TransformationKeyframes->addKeyframe(TempMat,8.0f);
    TempMat.setRotate(Quaternion(Vec3f(0.0f,1.0f,0.0f), 3.14159f*1.5));
    TransformationKeyframes->addKeyframe(TempMat,12.0f);
    TempMat.setRotate(Quaternion(Vec3f(0.0f,1.0f,0.0f), 0.0f));
    TransformationKeyframes->addKeyframe(TempMat,16.0f);

    //Animator
    KeyframeAnimatorRefPtr TorusAnimator = OSG::KeyframeAnimator::create();
    TorusAnimator->setKeyframeSequence(TransformationKeyframes);

    //Animation
    _TorusAnimation = FieldAnimation::create();
    _TorusAnimation->setAnimator(TorusAnimator);
    _TorusAnimation->setInterpolationType(Animator::LINEAR_INTERPOLATION);
    _TorusAnimation->setCycling(-1);
    _TorusAnimation->setAnimatedField(SceneTransformCore, std::string("matrix"));
    _TorusAnimation->attachUpdateProducer(MainApplication::the()->getMainWindow()->editEventProducer());
    _TorusAnimation->start();

    //Foreground
    //ImageForegroundRefPtr LogoForeground = ImageForeground::create();
    //BoostPath LogoPath(MainApplication::the()->getSettings()->getDataDirectory() / "Images/Logo.png");
    //ImageRefPtr LoadedImage = ImageFileHandler::the().read(LogoPath.string().c_str());

    //	LogoForeground->addImage( LoadedImage, Pnt2f( 0,0 ) );

    ForegroundRefPtr UserInterfaceForeground = createInterface();
    _TheUIDrawingSurface->setEventProducer(MainApplication::the()->getMainWindow());

    if(MainApplication::the()->getMainWindow() != NULL &&
       MainApplication::the()->getMainWindow()->getMFPort()->size() == 0)
    {
        ViewportRefPtr DefaultViewport = Viewport::create();
        DefaultViewport->setCamera                  (DefaultCamera);
        DefaultViewport->setRoot                    (DefaultRootNode);
        DefaultViewport->setSize                    (0.0f,0.0f, 1.0f,1.0f);
        DefaultViewport->setBackground              (DefaultBackground);
        DefaultViewport->addForeground              (UserInterfaceForeground);

        MainApplication::the()->getMainWindow()->addPort(DefaultViewport);
    }

    MainApplication::the()->getMainWindow()->addKeyListener(&_StartScreenKeyListener);
    MainApplication::the()->getMainWindow()->addUpdateListener(&_ScreenUpdateListener);

}
开发者ID:msteners,项目名称:KabalaEngine,代码行数:101,代码来源:KEApplicationStartScreen.cpp

示例8: main


//.........这里部分代码省略.........

        //Editor Field
        LabelRecPtr TheTextEditorLabel = Label::create();
        TheTextEditorLabel->setText("Text");
        TheTextEditorLabel->setPreferredSize(Vec2f(100.0f, 20.0f));

        FieldEditorComponentRefPtr TheTextEditor = FieldEditorFactory::the()->createDefaultEditor(EditedLabel,
                                                                                                  Label::TextFieldId,
                                                                                                  TheCommandManager);
        TheTextEditor->setPreferredSize(Vec2f(100.0f, 20.0f));

        LabelRecPtr ThePreferredSizeEditorLabel = Label::create();
        ThePreferredSizeEditorLabel->setText("PreferredSize");
        ThePreferredSizeEditorLabel->setPreferredSize(Vec2f(100.0f, 20.0f));

        FieldEditorComponentRefPtr ThePreferredSizeEditor =
            FieldEditorFactory::the()->createDefaultEditor(EditedLabel,
                                                           Label::PreferredSizeFieldId,
                                                           TheCommandManager);
        ThePreferredSizeEditor->setPreferredSize(Vec2f(150.0f, 20.0f));

        //Editing Panel
        LayoutRefPtr EditorPanelLayout = OSG::FlowLayout::create();
        PanelRecPtr EditorPanel = Panel::create();
        EditorPanel->setPreferredSize(Vec2f(200.0f,200.0f));
        EditorPanel->pushToChildren(TheTextEditorLabel);
        EditorPanel->pushToChildren(TheTextEditor);
        EditorPanel->pushToChildren(ThePreferredSizeEditorLabel);
        EditorPanel->pushToChildren(ThePreferredSizeEditor);
        EditorPanel->setLayout(EditorPanelLayout);

        //Undo Panel
        LabelRecPtr UndoPanelLabel = Label::create();
        UndoPanelLabel->setText("Undo Panel");
        UndoPanelLabel->setPreferredSize(Vec2f(100.0f, 20.0f));

        LayoutRefPtr UndoPanelLayout = OSG::FlowLayout::create();
        PanelRecPtr UndoPanel = Panel::create();
        UndoPanel->setPreferredSize(Vec2f(300.0f,300.0f));
        UndoPanel->pushToChildren(UndoPanelLabel);
        UndoPanel->pushToChildren(UndoRedoScrollPanel);
        UndoPanel->pushToChildren(UndoButton);
        UndoPanel->pushToChildren(RedoButton);
        UndoPanel->setLayout(UndoPanelLayout);

        // Create The Main InternalWindow
        // Create Background to be used with the Main InternalWindow
        ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
        MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
        InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
        LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
        MainInternalWindow->pushToChildren(EditedLabel);
        MainInternalWindow->pushToChildren(EditorPanel);
        MainInternalWindow->pushToChildren(UndoPanel);
        MainInternalWindow->setLayout(MainInternalWindowLayout);
        MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
        MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
        MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.95f,0.95f));
        MainInternalWindow->setDrawTitlebar(false);
        MainInternalWindow->setResizable(false);

        // Create the Drawing Surface
        UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
        TutorialDrawingSurface->setGraphics(TutorialGraphics);
        TutorialDrawingSurface->setEventProducer(TutorialWindow);
        
	    TutorialDrawingSurface->openWindow(MainInternalWindow);
    	
	    // Create the UI Foreground Object
        UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();

        TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);

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

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

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

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

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

    osgExit();

    return 0;
}
开发者ID:achvas88,项目名称:OpenSGToolbox,代码行数:101,代码来源:02GenericFieldEditor.cpp


注:本文中的ViewportRefPtr::setBackground方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。