本文整理汇总了C++中ViewportRefPtr::addForeground方法的典型用法代码示例。如果您正苦于以下问题:C++ ViewportRefPtr::addForeground方法的具体用法?C++ ViewportRefPtr::addForeground怎么用?C++ ViewportRefPtr::addForeground使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ViewportRefPtr
的用法示例。
在下文中一共展示了ViewportRefPtr::addForeground方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makeDocForeground
SimpleScreenDoc::SimpleScreenDoc(SimpleSceneManager* SceneManager,
WindowEventProducer* MainWindow)
{
_DocForeground = makeDocForeground();
_DocForeground->setBgColor(Color4f(0.0f,0.0f,0.0f,0.8f));
_DocForeground->setBorderColor(Color4f(1.0f,1.0f,1.0f,1.0f));
_DocForeground->setTextMargin(Vec2f(5.0f,5.0f));
_DocForeground->setHorizontalAlign(SimpleTextForeground::Left);
_DocForeground->setVerticalAlign(SimpleTextForeground::Top);
_DocForeground->setActive(false);
_DocShowForeground = makeDocShowForeground();
ViewportRefPtr TutorialViewport = SceneManager->getWindow()->getPort(0);
TutorialViewport->addForeground(_DocForeground);
TutorialViewport->addForeground(_DocShowForeground);
MainWindow->connectKeyTyped(boost::bind(&SimpleScreenDoc::keyTyped,
this,
_1));
//Color Keyframe Sequence
KeyframeColorSequenceRecPtr ColorKeyframes = KeyframeColorSequenceColor4f::create();
ColorKeyframes->addKeyframe(Color4f(1.0f,1.0f,1.0f,1.0f),0.0f);
ColorKeyframes->addKeyframe(Color4f(1.0f,1.0f,1.0f,1.0f),5.0f);
ColorKeyframes->addKeyframe(Color4f(1.0f,1.0f,1.0f,0.0f),7.0f);
//Animator
KeyframeAnimatorRecPtr TheAnimator = KeyframeAnimator::create();
TheAnimator->setKeyframeSequence(ColorKeyframes);
//Animation
_ShowDocFadeOutAnimation = FieldAnimation::create();
_ShowDocFadeOutAnimation->setAnimator(TheAnimator);
_ShowDocFadeOutAnimation->setInterpolationType(Animator::LINEAR_INTERPOLATION);
_ShowDocFadeOutAnimation->setCycling(1);
_ShowDocFadeOutAnimation->setAnimatedField(_DocShowForeground,
SimpleTextForeground::ColorFieldId);
_ShowDocFadeOutAnimation->attachUpdateProducer(MainWindow);
_ShowDocFadeOutAnimation->start();
}
示例2: 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);
}
示例3: main
//.........这里部分代码省略.........
// creating a submenu. Note this does not
// involve begin/endEditCPs to do
ExampleSubMenu->addItem(SubMenuItem1);
ExampleSubMenu->addItem(SubMenuItem2);
ExampleSubMenu->addItem(SubMenuItem3);
/******************************************************
Create the PopupMenu itself.
Items are added in the order in which
they will be displayed (top to bottom)
via addItem(ItemToBeAdded)
The PopupMenu is attached to a
Button below using
setPopupMenu(PopupMenuName).
Note: PopupMenus can be added to any
Component.
******************************************************/
PopupMenuRefPtr ExamplePopupMenu = PopupMenu::create();
ExamplePopupMenu->addItem(MenuItem1);
ExamplePopupMenu->addItem(MenuItem2);
ExamplePopupMenu->addItem(MenuItem3);
ExamplePopupMenu->addSeparator();
ExamplePopupMenu->addItem(ExampleSubMenu);
ExamplePopupMenu->addItem(MenuItem4);
// Create a Button and Font
UIFontRefPtr PopupMenuButtonFont = OSG::UIFont::create();
PopupMenuButtonFont->setSize(16);
ButtonRefPtr PopupMenuButton = OSG::Button::create();
PopupMenuButton->setText("RightClickMe!");
// Add the PopupMenu to PopupMenuButton so that when right clicked,
// the PopupMenu will appear
PopupMenuButton->setPopupMenu(ExamplePopupMenu);
PopupMenuButton->setPreferredSize(Vec2f(200,100));
PopupMenuButton->setFont(PopupMenuButtonFont);
// 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));
LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(PopupMenuButton);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,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);
// 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,
"01RubberBandCamera");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例4: main
//.........这里部分代码省略.........
distorted. For Layouts which will often
be dynamically changed, FlowLayout is not
the best choice.
-setHorizontalGap(int): Determine the Horizontal
gap in pixels between Components in
FlowLayout.
-setVerticalGap(int): Determine the Vertical
gap in pixels between Components in
FlowLayout.
-setOrientation(ENUM): Determine whether the
Layout is arranged Vertically or
Horizontally. Takes HORIZONTAL_ORIENTATION
or VERTICAL_ORIENTATION arguments.
-setMajorAxisAlignment(ENUM): Determines
the alignment of the entire Layout
within its ComponentContainer. See below.
-setMinorAxistAlignment(ENUM): Determines
the alignment of Components within
the Layout. See below.
Both of the last two functions take the
following arguments: AXIS_MAX_ALIGNMENT,
AXIS_CENTER_ALIGNMENT, and AXIS_MIN_ALIGNMENT.
MAX puts it to the bottom/right, CENTER
centers it, and MIN puts it to the
top/left (for Vertical/Horizontal as
set above, respectively).
******************************************************/
FlowLayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
MainInternalWindowLayout->setHorizontalGap(3.0f);
MainInternalWindowLayout->setVerticalGap(3.0f);
MainInternalWindowLayout->setOrientation(FlowLayout::VERTICAL_ORIENTATION);
MainInternalWindowLayout->setMajorAxisAlignment(0.5f);
MainInternalWindowLayout->setMinorAxisAlignment(1.0f);
// 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(ExampleButton1);
MainInternalWindow->pushToChildren(ExampleButton2);
MainInternalWindow->pushToChildren(ExampleButton3);
MainInternalWindow->pushToChildren(ExampleButton4);
MainInternalWindow->pushToChildren(ExampleButton5);
MainInternalWindow->pushToChildren(ExampleButton6);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
// Add a 10 pixel "padding" inside the MainFrame
MainInternalWindow->setAllInsets(10);
//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);
// 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,
"05FlowLayout");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例5: main
//.........这里部分代码省略.........
used within TextArea
-setSelectionStart(StartCharacterNumber):
Determine the character which the
selection will initially start after.
-setSelectionEnd(EndCharacterNumber):
Determine the character which the
selection will end before.
-setCaretPosition(Location): Determine the
location of the Caret within the TextArea.
Note: this does not do too much
currently because the only way
to cause the TextArea to gain focus is
to click within it, causing the
Caret to move.
******************************************************/
// Create a TextArea component
TextAreaRefPtr ExampleTextArea = OSG::TextArea::create();
ExampleTextArea->setPreferredSize(Vec2f(300, 200));
ExampleTextArea->setMinSize(Vec2f(300, 200));
ExampleTextArea->setTextColor(Color4f(0.0, 0.0, 0.0, 1.0));
ExampleTextArea->setSelectionBoxColor(Color4f(0.0, 0.0, 1.0, 1.0));
ExampleTextArea->setSelectionTextColor(Color4f(1.0, 1.0, 1.0, 1.0));
// Determine the font and initial text
ExampleTextArea->setText("What");
ExampleTextArea->setFont(ExampleFont);
// This will select the "a" from above
ExampleTextArea->setSelectionStart(2);
ExampleTextArea->setSelectionEnd(3);
ExampleTextArea->setCaretPosition(2);
//ExampleTextArea->setLineWrap(false);
// Create a ScrollPanel
ScrollPanelRefPtr TextAreaScrollPanel = ScrollPanel::create();
TextAreaScrollPanel->setPreferredSize(Vec2f(200,200));
TextAreaScrollPanel->setHorizontalResizePolicy(ScrollPanel::RESIZE_TO_VIEW);
// Add the TextArea to the ScrollPanel so it is displayed
TextAreaScrollPanel->setViewComponent(ExampleTextArea);
// 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));
LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(TextAreaScrollPanel);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,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);
// 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,
"22TextArea");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例6: 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;
}
示例7: main
//.........这里部分代码省略.........
ExampleButton->setTextColor(Color4f(1.0, 0.0, 0.0, 1.0));
ExampleButton->setRolloverTextColor(Color4f(1.0, 0.0, 1.0, 1.0));
ExampleButton->setActiveTextColor(Color4f(1.0, 0.0, 0.0, 1.0));
ExampleButton->setAlignment(Vec2f(1.0,0.0));
/******************************************************
Create a ToggleButton and determine its
characteristics. ToggleButton inherits
off of Button, so all characteristsics
used above can be used with ToggleButtons
as well.
The only difference is that when pressed,
ToggleButton remains pressed until pressed
again.
-setSelected(bool): Determine whether the
ToggleButton is Selected (true) or
deselected (false).
******************************************************/
ToggleButtonRefPtr ExampleToggleButton = OSG::ToggleButton::create();
ExampleToggleButton->setSelected(false);
ExampleToggleButton->setText("ToggleMe");
ExampleToggleButton->setToolTipText("Toggle Button ToolTip");
// Create Background to be used with the MainInternalWindow
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
// Create The Internal Window
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
// Assign the Button to the MainInternalWindow so it will be displayed
// when the view is rendered.
MainInternalWindow->pushToChildren(ExampleButton);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setPosition(Pnt2f(50,50));
MainInternalWindow->setPreferredSize(Vec2f(300,300));
MainInternalWindow->setTitle(std::string("Internal Window 1"));
// Create The Internal Window
InternalWindowRefPtr MainInternalWindow2 = OSG::InternalWindow::create();
LayoutRefPtr MainInternalWindowLayout2 = OSG::FlowLayout::create();
// Assign the Button to the MainInternalWindow so it will be displayed
// when the view is rendered.
MainInternalWindow2->pushToChildren(ExampleToggleButton);
MainInternalWindow2->setLayout(MainInternalWindowLayout2);
MainInternalWindow2->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow2->setPosition(Pnt2f(150,150));
MainInternalWindow2->setPreferredSize(Vec2f(300,300));
MainInternalWindow2->setTitle(std::string("Internal Window 2"));
MainInternalWindow2->setIconable(false);
MainInternalWindow2->setAllwaysOnTop(true);
// Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow2);
// 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);
// 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,
"37InternalWindow");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例8: main
//.........这里部分代码省略.........
// Create an Action and assign it to ExampleButton
// This Class is defined above, and will cause the output
// window to display "Button 1 Action" when pressed
ExampleButton->connectActionPerformed(boost::bind(actionPerformed, _1));
/******************************************************
Create a ToggleButton and determine its
characteristics. ToggleButton inherits
off of Button, so all characteristsics
used above can be used with ToggleButtons
as well.
The only difference is that when pressed,
ToggleButton remains pressed until pressed
again.
-setSelected(bool): Determine whether the
ToggleButton is Selected (true) or
deselected (false).
******************************************************/
ToggleButtonRefPtr ExampleToggleButton = OSG::ToggleButton::create();
ExampleToggleButton->setSelected(false);
ExampleToggleButton->setText("ToggleMe");
ExampleToggleButton->setToolTipText("Toggle Button ToolTip");
//Button with Image
ButtonRefPtr ExampleDrawObjectButton = OSG::Button::create();
ExampleDrawObjectButton->setDrawObjectToTextAlignment(Button::ALIGN_DRAW_OBJECT_RIGHT_OF_TEXT);
ExampleDrawObjectButton->setText("Icon");
ExampleDrawObjectButton->setImage(std::string("./Data/Icon.png"));
ExampleDrawObjectButton->setActiveImage(std::string("./Data/Icon.png"));
ExampleDrawObjectButton->setFocusedImage(std::string("./Data/Icon.png"));
ExampleDrawObjectButton->setRolloverImage(std::string("./Data/Icon.png"));
ExampleDrawObjectButton->setDisabledImage(std::string("./Data/Icon.png"));
// 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(ExampleButton);
MainInternalWindow->pushToChildren(ExampleToggleButton);
MainInternalWindow->pushToChildren(ExampleDrawObjectButton);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,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);
sceneManager.setRoot(scene);
// Add the UI Foreground Object to the Scene
ViewportRefPtr TutorialViewport = sceneManager.getWindow()->getPort(0);
TutorialViewport->addForeground(TutorialUIForeground);
//Create the Documentation Foreground and add it to the viewport
SimpleScreenDoc TheSimpleScreenDoc(&sceneManager, TutorialWindow);
// Show the whole Scene
sceneManager.showAll();
//Attach key controls
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"01Button");
commitChanges();
//Enter main Loop
TutorialWindow->mainLoop();
}
osgExit();
return 0;
}
示例9: main
//.........这里部分代码省略.........
ExampleButton2->setText("Previous Card");
ExampleButton2->setConstraints(ExampleButton2Constraints);
// Add ActionListener
BackCardActionListener TheBackCardActionListener;
ExampleButton2->addActionListener( &TheBackCardActionListener);
ExampleButton3->setText("This");
ExampleButton4->setText("is");
ExampleButton5->setText("Card");
ExampleButton6->setText("Layout");
ExampleButton7->setText("First Card");
ExampleButton7->setConstraints(ExampleButton7Constraints);
// Add ActionListener
FirstCardActionListener TheFirstCardActionListener;
ExampleButton7->addActionListener( &TheFirstCardActionListener);
ExampleButton8->setText("Last Card");
ExampleButton8->setConstraints(ExampleButton8Constraints);
// Add ActionListener
LastCardActionListener TheLastCardActionListener;
ExampleButton8->addActionListener( &TheLastCardActionListener);
ExampleCardPanel->setLayout(ExampleCardLayout);
ExampleCardPanel->pushToChildren(ExampleButton3);
ExampleCardPanel->pushToChildren(ExampleButton4);
ExampleCardPanel->pushToChildren(ExampleButton5);
ExampleCardPanel->pushToChildren(ExampleButton6);
ExampleCardPanel->setConstraints(ExampleCardPanelConstraints);
// 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(ExampleButton1);
MainInternalWindow->pushToChildren(ExampleButton2);
MainInternalWindow->pushToChildren(ExampleButton7);
MainInternalWindow->pushToChildren(ExampleButton8);
MainInternalWindow->pushToChildren(ExampleCardPanel);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,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);
// 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,
"11CardLayout");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例10: main
//.........这里部分代码省略.........
LookAndFeelManager::the()->getLookAndFeel()->init();
/******************************************************
Create the DefaultMutableComboBoxModel and
add Elements to it (several Colors
in this case). These will be the data
values shown in the ComboBox.
******************************************************/
DefaultMutableComboBoxModelRefPtr ExampleComboBoxModel = DefaultMutableComboBoxModel::create();
ExampleComboBoxModel->addElement(boost::any(Color4f(1.0,0.0,0.0,1.0)));
ExampleComboBoxModel->addElement(boost::any(Color4f(0.0,1.0,0.0,1.0)));
ExampleComboBoxModel->addElement(boost::any(Color4f(0.0,0.0,1.0,1.0)));
ExampleComboBoxModel->addElement(boost::any(Color4f(0.0,0.0,0.0,1.0)));
ExampleComboBoxModel->addElement(boost::any(Color4f(1.0,1.0,1.0,1.0)));
ExampleComboBoxModel->addElement(boost::any(std::string("More Colors")));
/******************************************************
Create an editable ComboBox. A ComboBox
has a Model just like various other
Components.
******************************************************/
ColorChooserComboBoxComponentGeneratorRefPtr TheColorChooserComboBoxComponentGenerator = ColorChooserComboBoxComponentGenerator::create();
//Create the ComboBox
ComboBoxRefPtr ExampleComboBox = ComboBox::create();
// Set the Model created above to the ComboBox
ExampleComboBox->setModel(ExampleComboBoxModel);
ExampleComboBox->setCellGenerator(TheColorChooserComboBoxComponentGenerator);
ExampleComboBox->setEditable(false);
// Determine where the ComboBox starts
ExampleComboBox->setSelectedIndex(0);
// 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));
LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(ExampleComboBox);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
//Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(graphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr foreground = OSG::UIForeground::create();
foreground->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 viewport = mgr->getWindow()->getPort(0);
viewport->addForeground(foreground);
// 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,
"33_2_ColorComboBox");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例11: main
//.........这里部分代码省略.........
of pixels between each row.
******************************************************/
GridLayoutRefPtr MainInternalWindowLayout = OSG::GridLayout::create();
MainInternalWindowLayout->setRows(3);
MainInternalWindowLayout->setColumns(2);
MainInternalWindowLayout->setHorizontalGap(4);
MainInternalWindowLayout->setVerticalGap(4);
/******************************************************
Create and edit some Button Components.
Note that as with BoxLayout, Components
are resized to fit their respective
grid boxes. Unless a MaxSize is set,
this will be the case. This will
override even PreferredSizes (see
ExampleButton3).
******************************************************/
ButtonRefPtr ExampleButton1 = OSG::Button::create();
ButtonRefPtr ExampleButton2 = OSG::Button::create();
ButtonRefPtr ExampleButton3 = OSG::Button::create();
ButtonRefPtr ExampleButton4 = OSG::Button::create();
ButtonRefPtr ExampleButton5 = OSG::Button::create();
ButtonRefPtr ExampleButton6 = OSG::Button::create();
ExampleButton1->setPreferredSize(Vec2f(50,50));
ExampleButton1->setMaxSize(Vec2f(50,50)); //if MaxSize is commented out, this button then will revert to being the same size as the others in the grid.
ExampleButton2->setPreferredSize(Vec2f(200,100)); //<----
// |
ExampleButton3->setPreferredSize(Vec2f(50,100)); //Notice that even though these two differ in size they appear the same on the grid
// 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(ExampleButton1);
MainInternalWindow->pushToChildren(ExampleButton2);
MainInternalWindow->pushToChildren(ExampleButton3);
MainInternalWindow->pushToChildren(ExampleButton4);
MainInternalWindow->pushToChildren(ExampleButton5);
MainInternalWindow->pushToChildren(ExampleButton6);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,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);
// 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,
"07GridLayout");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例12: main
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
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();
/******************************************************
Create and edit a CheckboxButton.
Note: the only function call shown
specific to CheckboxButton is setSelected.
In DefaultLookAndFeel, the options
for changing the style of the CheckBox
are shown. CheckboxButton also
inherits off Button so all features
of Button may be used.
-setSelected(bool): Determines if the
CheckboxButton is checked(true) or
not checked(false).
******************************************************/
CheckboxButtonRefPtr ExampleCheckboxButton = OSG::CheckboxButton::create();
ExampleCheckboxButton->setMinSize(Vec2f(50, 25));
ExampleCheckboxButton->setMaxSize(Vec2f(300, 100));
ExampleCheckboxButton->setPreferredSize(Vec2f(200, 50));
ExampleCheckboxButton->setEnabled(true);
ExampleCheckboxButton->setText("Checkbox Button");
ExampleCheckboxButton->setAlignment(Vec2f(0.5,0.5));
ExampleCheckboxButton->setSelected(true);
// 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));
LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(ExampleCheckboxButton);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,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);
// Show the whole Scene
mgr->showAll();
//.........这里部分代码省略.........
示例13: main
//.........这里部分代码省略.........
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;
}
示例14: main
//.........这里部分代码省略.........
******************************************************/
//Create the ComboBox
ComboBoxRefPtr ExampleComboBox = ComboBox::create();
// Set the Model created above to the ComboBox
ExampleComboBox->setModel(ExampleComboBoxModel);
// Determine where the ComboBox starts
ExampleComboBox->setSelectedIndex(0);
/******************************************************
Create a non-editable ComboBox.
-setEditable(bool): Determine whether
the user can type in the ComboBox
or if it is uneditable. In this
case, it is set to false.
When creating a non-editable ComboBox,
a Renderer must also be assigned. For
editable ComboBoxes, the ComboBox
automatically shows its text due to the
nature of the ComboBox. However, when
uneditable, this aspect of the ComboBox
is disabled, and so to display the
selection, a renderer must be created and
assigned to the ComboBox.
Note: as with Sliders and ScrollBars,
having the same Model assigned causes
the ComboBoxes to be tied together.
******************************************************/
// Create another ComboBox
ComboBoxRefPtr ExampleUneditableComboBox = ComboBox::create();
// Set it to be uneditable
ExampleUneditableComboBox->setEditable(false);
ExampleUneditableComboBox->setModel(ExampleComboBoxModel);
// 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));
LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(ExampleComboBox);
MainInternalWindow->pushToChildren(ExampleUneditableComboBox);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
//Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(graphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr foreground = OSG::UIForeground::create();
foreground->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 viewport = mgr->getWindow()->getPort(0);
viewport->addForeground(foreground);
// 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,
"33ComboBox");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例15: main
//.........这里部分代码省略.........
ExamplePanel1->setPreferredSize(Vec2f(400, 400));
ExamplePanel1->pushToChildren(ExampleButton2);
ExamplePanel1->pushToChildren(ExamplePanel3);
ExamplePanel1->pushToChildren(ExamplePanel4);
ExamplePanel1->setLayout(ExamplePanel1Layout);
ExamplePanel1->setBackgrounds(ExamplePanelBackground);
ExamplePanel1->setBorders(ExamplePanelBorder);
ExamplePanel2->setPreferredSize(Vec2f(400, 400));
ExamplePanel2->pushToChildren(ExampleButton3);
ExamplePanel2->pushToChildren(ExamplePanel5);
ExamplePanel2->pushToChildren(ExamplePanel6);
ExamplePanel2->setLayout(ExamplePanel2Layout);
ExamplePanel2->setBackgrounds(ExamplePanelBackground);
ExamplePanel2->setBorders(ExamplePanelBorder);
ExamplePanel3->pushToChildren(ExampleButton4);
ExamplePanel3->pushToChildren(ExampleButton5);
ExamplePanel3->setLayout(ExamplePanel3Layout);
ExamplePanel3->setPreferredSize(Vec2f(125, 130));
ExamplePanel3->setBackgrounds(ExampleSmallPanelBackground);
ExamplePanel4->pushToChildren(ExampleButton6);
ExamplePanel4->pushToChildren(ExampleButton7);
ExamplePanel4->setLayout(ExamplePanel4Layout);
ExamplePanel4->setPreferredSize(Vec2f(125, 130));
ExamplePanel4->setBackgrounds(ExampleSmallPanelBackground);
ExamplePanel5->pushToChildren(ExampleButton8);
ExamplePanel5->pushToChildren(ExampleButton9);
ExamplePanel5->setLayout(ExamplePanel5Layout);
ExamplePanel5->setPreferredSize(Vec2f(125, 130));
ExamplePanel5->setBackgrounds(ExampleSmallPanelBackground);
ExamplePanel6->pushToChildren(ExampleButton10);
ExamplePanel6->pushToChildren(ExampleButton11);
ExamplePanel6->setLayout(ExamplePanel6Layout);
ExamplePanel6->setPreferredSize(Vec2f(125, 130));
ExamplePanel6->setBackgrounds(ExampleSmallPanelBackground);
// 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->setBorder(ExamplePanelBorder);
MainInternalWindow->pushToChildren(ExampleLabel1);
MainInternalWindow->pushToChildren(ExampleButton1);
MainInternalWindow->pushToChildren(ExamplePanel1);
MainInternalWindow->pushToChildren(ExamplePanel2);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.8f,0.8f));
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);
// 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,
"12ComplexLayout");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}