mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-06-17 22:03:37 -06:00
SurfaceCtrl_Demo: Update of the layout
git-svn-id: svn://ultimatepp.org/upp/trunk@14925 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
4b42211f54
commit
01f39a8e97
4 changed files with 103 additions and 16 deletions
|
|
@ -9,10 +9,16 @@ namespace Upp{
|
|||
#include <CtrlCore/lay.h>
|
||||
|
||||
class SurfaceCtrl_Demo : public WithSurfaceCtrl_DemoLayout<TopWindow> {
|
||||
private:
|
||||
|
||||
void RetrieveCameraInformation();
|
||||
void UpdatePosition();
|
||||
void UpdateRotation();
|
||||
|
||||
public:
|
||||
typedef SurfaceCtrl_Demo CLASSNAME;
|
||||
SurfaceCtrl_Demo();
|
||||
virtual void Layout();
|
||||
|
||||
virtual bool Key(dword key, int count);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,31 @@
|
|||
LAYOUT(SurfaceCtrl_DemoLayout, 564, 372)
|
||||
ITEM(SurfaceCtrl, canvas, SetFrame(ThinInsetFrame()).HSizePosZ(0, 0).VSizePosZ(28, 0))
|
||||
ITEM(Label, dv___1, SetLabel(t_("File :")).LeftPosZ(8, 28).TopPosZ(4, 19))
|
||||
ITEM(EditString, filename, HSizePosZ(36, 204).TopPosZ(4, 19))
|
||||
ITEM(Button, butOpen, SetLabel(t_("Open")).RightPosZ(156, 44).TopPosZ(4, 20))
|
||||
ITEM(Button, Ultimate, SetLabel(t_("Ultimate++ !")).RightPosZ(4, 68).TopPosZ(4, 20))
|
||||
ITEM(Button, OpenEarth, SetLabel(t_("Open Earth")).RightPosZ(88, 64).TopPosZ(4, 20))
|
||||
LAYOUT(SurfaceCtrl_DemoLayout, 872, 475)
|
||||
ITEM(SurfaceCtrl, canvas, SetFrame(ThinInsetFrame()).HSizePosZ(2, 2).VSizePosZ(56, 1))
|
||||
ITEM(Label, dv___1, SetLabel(t_("File :")).LeftPosZ(7, 28).TopPosZ(7, 18))
|
||||
ITEM(EditString, filename, LeftPosZ(33, 220).TopPosZ(7, 19))
|
||||
ITEM(Button, butOpen, SetLabel(t_("Open")).LeftPosZ(255, 44).TopPosZ(7, 19))
|
||||
ITEM(Button, Ultimate, SetLabel(t_("Ultimate++ !")).LeftPosZ(369, 68).TopPosZ(7, 19))
|
||||
ITEM(Button, OpenEarth, SetLabel(t_("Open Earth")).LeftPosZ(301, 64).TopPosZ(7, 19))
|
||||
ITEM(Switch, cameraView, SetLabel(t_("Perspective view\nParallel view")).LeftPosZ(54, 184).TopPosZ(35, 16))
|
||||
ITEM(Option, axis, SetLabel(t_("Show axis")).LeftPosZ(364, 68).TopPosZ(35, 16))
|
||||
ITEM(Label, fov, SetLabel(t_("FOV:")).SetFont(StdFontZ(11)).LeftPosZ(246, 27).TopPosZ(33, 19))
|
||||
ITEM(EditIntSpin, fovSelector, LeftPosZ(274, 74).TopPosZ(33, 19))
|
||||
ITEM(Label, camera, SetLabel(t_("Camera:")).SetFont(StdFontZ(11)).LeftPosZ(7, 44).TopPosZ(33, 19))
|
||||
ITEM(LabelBox, dv___11, SetLabel(t_("Camera values")).SetFont(StdFont().Bold()).LeftPosZ(444, 423).TopPosZ(0, 55))
|
||||
ITEM(Label, frontvec, SetLabel(t_("(x=12, y=439, z=10)")).LeftPosZ(765, 101).TopPosZ(38, 13))
|
||||
ITEM(Label, dv___13, SetLabel(t_("Angle (quaternion):")).LeftPosZ(450, 97).TopPosZ(35, 13))
|
||||
ITEM(EditInt64, quatZ, LeftPosZ(658, 34).TopPosZ(32, 19))
|
||||
ITEM(EditInt64, camPosZ, LeftPosZ(652, 40).TopPosZ(11, 19))
|
||||
ITEM(EditInt64, quatX, LeftPosZ(586, 34).TopPosZ(32, 19))
|
||||
ITEM(EditInt64, quatY, LeftPosZ(622, 34).TopPosZ(32, 19))
|
||||
ITEM(EditInt64, camPosY, LeftPosZ(610, 40).TopPosZ(11, 19))
|
||||
ITEM(EditInt64, camPosX, LeftPosZ(568, 40).TopPosZ(11, 19))
|
||||
ITEM(Label, dv___20, SetLabel(t_("Front vector :")).SetFont(StdFontZ(10)).LeftPosZ(697, 67).TopPosZ(38, 13))
|
||||
ITEM(Label, dv___21, SetLabel(t_("Up vector :")).SetFont(StdFontZ(10)).LeftPosZ(699, 58).TopPosZ(8, 13))
|
||||
ITEM(Label, dv___22, SetLabel(t_("Right vector :")).SetFont(StdFontZ(10)).LeftPosZ(698, 64).TopPosZ(23, 13))
|
||||
ITEM(Label, dv___23, SetLabel(t_("Position (xyz):")).LeftPosZ(495, 71).TopPosZ(15, 13))
|
||||
ITEM(Label, rightvec, SetLabel(t_("(x=12, y=439, z=10)")).LeftPosZ(765, 101).TopPosZ(23, 13))
|
||||
ITEM(Label, upvec, SetLabel(t_("(x=12, y=439, z=10)")).LeftPosZ(765, 101).TopPosZ(8, 13))
|
||||
ITEM(Button, resetPos, SetLabel(t_("Reset")).LeftPosZ(447, 45).TopPosZ(14, 15))
|
||||
ITEM(EditInt64, quatW, LeftPosZ(550, 34).TopPosZ(32, 19))
|
||||
END_LAYOUT
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
uses
|
||||
CtrlLib,
|
||||
SurfaceCtrl;
|
||||
SurfaceCtrl,
|
||||
Functions4U;
|
||||
|
||||
file
|
||||
SurfaceCtrl_Demo.h,
|
||||
|
|
|
|||
|
|
@ -1,12 +1,36 @@
|
|||
#include "SurfaceCtrl_Demo.h"
|
||||
|
||||
#include <Functions4U/Functions4U_Gui.h>
|
||||
|
||||
namespace Upp{
|
||||
SurfaceCtrl_Demo::SurfaceCtrl_Demo()
|
||||
{
|
||||
CtrlLayout(*this, "SurfaceCtrl demo. STL viewer");
|
||||
filename.SetText( GetFileDirectory(__FILE__) + "Stanford_Bunny_sample.stl" );
|
||||
|
||||
|
||||
cameraView <<= 0;
|
||||
cameraView.WhenAction = [&]{
|
||||
if(cameraView == 0){
|
||||
canvas.GetCamera().SetCameraType(CT_PERSPECTIVE);
|
||||
}else if(cameraView == 1){
|
||||
canvas.GetCamera().SetCameraType(CT_ORTHOGRAPHIC);
|
||||
}else{
|
||||
canvas.GetCamera().SetCameraType(CT_PERSPECTIVE);
|
||||
}
|
||||
canvas.Refresh();
|
||||
};
|
||||
axis = canvas.IsAxisEnable();
|
||||
axis.WhenAction = [&]{
|
||||
canvas.ShowAxis(axis.Get());
|
||||
canvas.Refresh();
|
||||
};
|
||||
|
||||
fovSelector <<= canvas.GetCamera().GetFOV();
|
||||
fovSelector.MinMax(0,160);
|
||||
fovSelector.WhenAction =[&]{
|
||||
canvas.GetCamera().SetFOV(fovSelector);
|
||||
canvas.Refresh();
|
||||
};
|
||||
|
||||
butOpen.WhenAction = [&] {
|
||||
try {
|
||||
|
||||
|
|
@ -46,24 +70,58 @@ namespace Upp{
|
|||
}
|
||||
};
|
||||
|
||||
camPosX <<= THISBACK(UpdatePosition);
|
||||
camPosY <<= THISBACK(UpdatePosition);
|
||||
camPosZ <<= THISBACK(UpdatePosition);
|
||||
|
||||
quatW <<= THISBACK(UpdateRotation);
|
||||
quatX <<= THISBACK(UpdateRotation);
|
||||
quatY <<= THISBACK(UpdateRotation);
|
||||
quatZ <<= THISBACK(UpdateRotation);
|
||||
|
||||
resetPos.WhenAction = [&]{
|
||||
canvas.GetCamera().GetTransform().SetPosition(0,0,20);
|
||||
canvas.GetCamera().GetTransform().SetRotation(0,glm::vec3(0,0,0));
|
||||
canvas.Refresh();
|
||||
};
|
||||
|
||||
canvas.WhenPaint = [&] {
|
||||
canvas.DrawAllObjects();
|
||||
RetrieveCameraInformation();
|
||||
};
|
||||
Sizeable().Zoomable();
|
||||
}
|
||||
|
||||
void SurfaceCtrl_Demo::Layout(){
|
||||
canvas.GLResize(GetSize().cx,GetSize().cy);
|
||||
}
|
||||
|
||||
|
||||
bool SurfaceCtrl_Demo::Key(dword key, int count){
|
||||
return canvas.Key(key,count);
|
||||
}
|
||||
|
||||
void SurfaceCtrl_Demo::RetrieveCameraInformation(){
|
||||
Transform& t = canvas.GetCamera().GetTransform();
|
||||
camPosX = t.GetPosition().x;
|
||||
camPosY = t.GetPosition().y;
|
||||
camPosZ = t.GetPosition().z;
|
||||
glm::quat q = t.GetRotation();
|
||||
quatW = q.w;
|
||||
quatX = q.x;
|
||||
quatY = q.y;
|
||||
quatZ = q.z;
|
||||
frontvec.SetLabel("("+ AsString( t.GetFront().x,2) +", " + AsString(t.GetFront().y,2) +", " + AsString(t.GetFront().z,2) + ")");
|
||||
upvec.SetLabel("("+ AsString(t.GetUp().x,2) +", " + AsString(t.GetUp().y,2) +", " + AsString(t.GetUp().z,2) + ")");
|
||||
rightvec.SetLabel("("+ AsString(t.GetRight().x,2) +", " + AsString(t.GetRight().y,2) +", " + AsString(t.GetRight().z,2) + ")");
|
||||
|
||||
}
|
||||
void SurfaceCtrl_Demo::UpdatePosition(){
|
||||
canvas.GetCamera().GetTransform().SetPosition(camPosX,camPosY,camPosZ);
|
||||
}
|
||||
void SurfaceCtrl_Demo::UpdateRotation(){
|
||||
canvas.GetCamera().GetTransform().SetRotation(glm::quat(quatW,quatX,quatY,quatZ));
|
||||
}
|
||||
}
|
||||
|
||||
GUI_APP_MAIN
|
||||
{
|
||||
Upp::ConsoleOutput con(true);
|
||||
Upp::StdLogSetup( Upp::LOG_COUT | Upp::LOG_FILE);
|
||||
Upp::SurfaceCtrl_Demo().Run();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue