[Gcblue-commits] gcb_wx/src/graphics tc3DViewer.cpp,1.7,1.8 tc3DWindow.cpp,1.12,1.13 tcButton.cpp,1.
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2004-12-21 02:26:30
|
Update of /cvsroot/gcblue/gcb_wx/src/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31924/src/graphics Modified Files: tc3DViewer.cpp tc3DWindow.cpp tcButton.cpp tcLauncherPopup.cpp tcParticleEffect.cpp Log Message: Changes for OSG 0.9.8 Index: tcButton.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcButton.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** tcButton.cpp 11 Dec 2004 01:09:06 -0000 1.15 --- tcButton.cpp 21 Dec 2004 02:26:17 -0000 1.16 *************** *** 81,95 **** if (isButtonOn) { ! backgroundColor.set(0.392f, 1.0f, 0.392f, backgroundAlpha); textColor.set(0, 0, 0, backgroundAlpha); } else if (isMouseOver) { ! backgroundColor.set(1, 1, 1, backgroundAlpha); textColor.set(0, 0, 0, backgroundAlpha); } else { ! backgroundColor.set(0, 0, 0, backgroundAlpha); textColor.set(1, 1, 1, backgroundAlpha); } --- 81,98 ---- if (isButtonOn) { ! backgroundColor = onColor; ! backgroundColor._v[3] = backgroundAlpha; textColor.set(0, 0, 0, backgroundAlpha); } else if (isMouseOver) { ! backgroundColor = overColor; ! backgroundColor._v[3] = backgroundAlpha; textColor.set(0, 0, 0, backgroundAlpha); } else { ! backgroundColor = offColor; ! backgroundColor._v[3] = backgroundAlpha; textColor.set(1, 1, 1, backgroundAlpha); } *************** *** 174,181 **** /** * version to initialize from XML file */ tcButton::tcButton(tc3DWindow *parent, TiXmlNode *config) ! : tc3DWindow(parent, wxPoint(0,0), wxSize(10,10), "XMLButton", parent) { caption = "NULL"; --- 177,215 ---- /** + * + */ + void tcButton::SetBackgroundAlpha(float val) + { + backgroundAlpha = val; + } + + /** + * + */ + void tcButton::SetFillColors(const osg::Vec4& off_color, const osg::Vec4& over_color, + const osg::Vec4& on_color) + { + offColor = off_color; + overColor = over_color; + onColor = on_color; + } + + /** + * + */ + void tcButton::SetFontSize(float val) + { + fontSize = val; + } + + + /** * version to initialize from XML file */ tcButton::tcButton(tc3DWindow *parent, TiXmlNode *config) ! : tc3DWindow(parent, wxPoint(0,0), wxSize(10,10), "XMLButton", parent), ! offColor(0, 0, 0, 1), ! overColor(0.4, 1, 0.4, 1), ! onColor(1, 1, 1, 1) { caption = "NULL"; *************** *** 255,259 **** tcButton::tcButton(tc3DWindow *parent, const wxPoint& pos, const wxSize& size, const wxString& name) ! : tc3DWindow(parent, pos, size, name, parent) { --- 289,296 ---- tcButton::tcButton(tc3DWindow *parent, const wxPoint& pos, const wxSize& size, const wxString& name) ! : tc3DWindow(parent, pos, size, name, parent), ! offColor(0, 0, 0, 1), ! overColor(0.4, 1, 0.4, 1), ! onColor(1, 1, 1, 1) { Index: tcParticleEffect.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcParticleEffect.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tcParticleEffect.cpp 23 Nov 2004 23:30:57 -0000 1.6 --- tcParticleEffect.cpp 21 Dec 2004 02:26:17 -0000 1.7 *************** *** 87,91 **** // or it's absolute; in the first case, we must transform the vectors // from local to world space. ! if (prg->getReferenceFrame() == osgParticle::Program::RELATIVE_TO_PARENTS) { // transform the center point (full transformation) xf_center_ = prg->transformLocalToWorld(center_); --- 87,91 ---- // or it's absolute; in the first case, we must transform the vectors // from local to world space. ! if (prg->getReferenceFrame() == osgParticle::Program::RELATIVE_RF) { // transform the center point (full transformation) xf_center_ = prg->transformLocalToWorld(center_); *************** *** 335,339 **** modularEmitter->setPlacer(particlePlacer); ! modularEmitter->setReferenceFrame(osgParticle::Emitter::RELATIVE_TO_ABSOLUTE); shooter = new osgParticle::RadialShooter; --- 335,339 ---- modularEmitter->setPlacer(particlePlacer); ! modularEmitter->setReferenceFrame(osgParticle::Emitter::ABSOLUTE_RF); shooter = new osgParticle::RadialShooter; *************** *** 364,368 **** particlePlacer->setCenter(0, 0, 0); smokeTrailEmitter->setPlacer(particlePlacer); ! smokeTrailEmitter->setReferenceFrame(osgParticle::Emitter::RELATIVE_TO_ABSOLUTE); program = new osgParticle::ModularProgram; --- 364,368 ---- particlePlacer->setCenter(0, 0, 0); smokeTrailEmitter->setPlacer(particlePlacer); ! smokeTrailEmitter->setReferenceFrame(osgParticle::Emitter::ABSOLUTE_RF); program = new osgParticle::ModularProgram; *************** *** 391,395 **** modularEmitter->setPlacer(particlePlacer); ! modularEmitter->setReferenceFrame(osgParticle::Emitter::RELATIVE_TO_ABSOLUTE); shooter = new osgParticle::RadialShooter; --- 391,395 ---- modularEmitter->setPlacer(particlePlacer); ! modularEmitter->setReferenceFrame(osgParticle::Emitter::ABSOLUTE_RF); shooter = new osgParticle::RadialShooter; Index: tc3DViewer.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tc3DViewer.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** tc3DViewer.cpp 11 Dec 2004 01:09:06 -0000 1.7 --- tc3DViewer.cpp 21 Dec 2004 02:26:17 -0000 1.8 *************** *** 1206,1210 **** osg::Light* light = new osg::Light; lightsource->setLight(light); ! lightsource->setReferenceFrame(osg::LightSource::RELATIVE_TO_ABSOLUTE); // headlight. lightsource->setLocalStateSetModes(osg::StateAttribute::ON); light->setPosition(osg::Vec4(0,0,1,1)); --- 1206,1210 ---- osg::Light* light = new osg::Light; lightsource->setLight(light); ! lightsource->setReferenceFrame(osg::LightSource::ABSOLUTE_RF); // headlight. lightsource->setLocalStateSetModes(osg::StateAttribute::ON); light->setPosition(osg::Vec4(0,0,1,1)); *************** *** 1265,1269 **** guiObjects = new osg::MatrixTransform; guiObjects->setMatrix(osg::Matrix::identity()); ! guiObjects->setReferenceFrame(osg::MatrixTransform::RELATIVE_TO_ABSOLUTE); guiView->setSceneData(guiObjects.get()); --- 1265,1269 ---- guiObjects = new osg::MatrixTransform; guiObjects->setMatrix(osg::Matrix::identity()); ! guiObjects->setReferenceFrame(osg::MatrixTransform::ABSOLUTE_RF); guiView->setSceneData(guiObjects.get()); *************** *** 1858,1862 **** hudObjects = new osg::MatrixTransform; hudObjects->setMatrix(osg::Matrix::identity()); ! hudObjects->setReferenceFrame(osg::MatrixTransform::RELATIVE_TO_ABSOLUTE); orthoProjection = new osg::Projection(); --- 1858,1862 ---- hudObjects = new osg::MatrixTransform; hudObjects->setMatrix(osg::Matrix::identity()); ! hudObjects->setReferenceFrame(osg::MatrixTransform::ABSOLUTE_RF); orthoProjection = new osg::Projection(); Index: tcLauncherPopup.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcLauncherPopup.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tcLauncherPopup.cpp 11 Dec 2004 01:09:06 -0000 1.2 --- tcLauncherPopup.cpp 21 Dec 2004 02:26:17 -0000 1.3 *************** *** 22,27 **** --- 22,30 ---- #include "stdwx.h" + #include "wxcommands.h" + #include "tcButton.h" #include "tcLauncherPopup.h" #include "tcLauncher.h" + #include "tcNumberWidget.h" #include "tcPlatformObject.h" #include "tcSimState.h" *************** *** 36,39 **** --- 39,50 ---- #endif + + BEGIN_EVENT_TABLE(tcLauncherPopup, tc3DWindow) + EVT_COMMAND(LP_CLOSE, wxEVT_COMMAND_BUTTON_CLICKED, tcLauncherPopup::OnCloseCommand) + EVT_COMMAND(LP_LAUNCH, wxEVT_COMMAND_BUTTON_CLICKED, tcLauncherPopup::OnLaunchCommand) + EVT_COMMAND(LP_SETDATUM, wxEVT_COMMAND_BUTTON_CLICKED, tcLauncherPopup::OnDatumCommand) + EVT_COMMAND(ID_BUTTONREDRAW, wxEVT_COMMAND_BUTTON_CLICKED , tcLauncherPopup::OnChildRedraw) + END_EVENT_TABLE() + tc3DWindow* tcLauncherPopup::parent = 0; *************** *** 53,63 **** void tcLauncherPopup::Draw() { ! unsigned currentCount = tcTime::Get()->Get30HzCount(); unsigned age = currentCount - birthCount; ! if (age % 10 == 0) redraw = true; if (!redraw) return; redraw = false; --- 64,83 ---- void tcLauncherPopup::Draw() { ! if (destroy) ! { ! ClearDrawObjects(); ! this->Destroy(); ! return; ! } + unsigned currentCount = tcTime::Get()->Get30HzCount(); unsigned age = currentCount - birthCount; ! if (age % 1 == 0) redraw = true; if (!redraw) return; + + UpdateTorpedoLauncher(); + redraw = false; *************** *** 72,76 **** DrawRectangleR(0, 0, float(mnWidth), float(mnHeight), ! osg::Vec4(0, 0, 0, 0.5f), FILL_ON); DrawBorder(); --- 92,96 ---- DrawRectangleR(0, 0, float(mnWidth), float(mnHeight), ! osg::Vec4(0, 0, 0, 0.6f), FILL_ON); DrawBorder(); *************** *** 103,128 **** color, fontSize, LEFT_CENTER); - MeasureText(defaultFont.get(), fontSize, s.c_str(), textSize); - x += float(textSize.GetWidth()) + 5.0f; - - datumButton.Set(x, x + 10.0f, - y - 0.5f * float(textSize.GetHeight()), y + 0.5 * float(textSize.GetHeight())); - DrawRectangleR(datumButton, osg::Vec4(1, 1, 1, 1), FILL_OFF); - - - x += 15.0f; - - launchButton.Set(x, x + 10.0f, - y - 0.5f * float(textSize.GetHeight()), y + 0.5 * float(textSize.GetHeight())); if (launcher->GetLauncherStatus() == tcLauncher::LAUNCHER_READY) { ! color.set(0.4f, 1.0f, 0.4f, 1.0f); } else { ! color.set(1.0f, 0.4f, 0.4f, 1.0f); } ! DrawRectangleR(launchButton, color, FILL_ON); HideUnusedObjects(); --- 123,140 ---- color, fontSize, LEFT_CENTER); if (launcher->GetLauncherStatus() == tcLauncher::LAUNCHER_READY) { ! launchButton->SetFillColors(osg::Vec4(0.2, 0.5, 0.2, 1.0), osg::Vec4(0.4, 1.0, 0.4, 1.0), ! osg::Vec4(0.4, 1.0, 0.4, 1.0)); } else { ! launchButton->SetFillColors(osg::Vec4(0.5, 0.2, 0.2, 1.0), osg::Vec4(0.5, 0.2, 0.2, 1.0), ! osg::Vec4(0.5, 0.2, 0.2, 1.0)); } ! ! ! DrawChildren(); HideUnusedObjects(); *************** *** 148,188 **** /** ! * A hack job for now :) */ ! void tcLauncherPopup::OnLButtonDown(wxMouseEvent& event) { ! wxPoint pos = event.GetPosition(); ! if (launchButton.ContainsPoint(pos.x, pos.y)) { ! if (tcLauncher* launcher = GetLauncher()) ! { ! if (launcher->GetLauncherStatus() == tcLauncher::LAUNCHER_READY) ! { ! launcher->mnUncommitted -= 1; ! if (launcher->mnUncommitted < 0) ! { ! launcher->mnUncommitted = 0; // don't set new cmd here since this is an error case ! std::cerr << "Error - tcLauncherState::SetLaunch - negative uncommitted\n"; ! } ! //else ! //{ ! // commandObj.SetNewCommand(GetLauncherFlag(nLauncher)); ! //} ! } ! } } ! else if (datumButton.ContainsPoint(pos.x, pos.y)) { ! if (tcLauncher* launcher = GetLauncher()) { ! tcCommandQueue::Get()->GetUserInputForID("SetDatum", "Datum", platformId, launcherIdx); } } ! else { ! ClearDrawObjects(); ! this->Destroy(); } } --- 160,333 ---- /** ! * Create and initialize GUI objects for torpedo control */ ! void tcLauncherPopup::InitTorpedoControls() { ! const int widgetWidth = 40; ! const int widgetHeight = 12; ! const float widgetFontSize = 12.0; ! const float widgetAlpha = 0.9f; ! int x = 80; ! int y = 20; ! tcLauncher* launcher = GetLauncher(); ! wxASSERT(launcher); ! if (!launcher) return; ! ! launchButton = new tcButton(this, wxPoint(mnWidth - 40, 5), ! wxSize(widgetHeight, widgetHeight)); ! launchButton->SetActive(true); ! launchButton->SetBackgroundAlpha(widgetAlpha); ! launchButton->SetCaption("L"); ! launchButton->SetCommand(LP_LAUNCH); ! launchButton->SetFontSize(11.0); ! launchButton->SetSendRedraw(true); ! ! selectDatumButton = new tcButton(this, wxPoint(mnWidth - 55, 5), ! wxSize(widgetHeight, widgetHeight)); ! selectDatumButton->SetActive(true); ! selectDatumButton->SetBackgroundAlpha(widgetAlpha); ! selectDatumButton->SetCaption("D"); ! selectDatumButton->SetCommand(LP_SETDATUM); ! selectDatumButton->SetFontSize(11.0); ! selectDatumButton->SetSendRedraw(true); ! ! runToEnableAdjust = new tcNumberWidget(runToEnable, this, wxPoint(x, y), ! wxSize(widgetWidth, widgetHeight)); ! runToEnableAdjust->SetBackgroundAlpha(widgetAlpha); ! runToEnableAdjust->SetCaption("Run to enable"); ! runToEnableAdjust->SetFontSize(widgetFontSize); ! runToEnableAdjust->SetActive(true); ! runToEnableAdjust->SetSendRedraw(true); ! runToEnable = launcher->runToEnable_m; ! y += widgetHeight + 5; ! ! depthAdjust = new tcNumberWidget(depth, this, wxPoint(x, y), ! wxSize(widgetWidth, widgetHeight)); ! depthAdjust->SetBackgroundAlpha(widgetAlpha); ! depthAdjust->SetCaption("Depth"); ! depthAdjust->SetFontSize(widgetFontSize); ! depthAdjust->SetActive(true); ! depthAdjust->SetSendRedraw(true); ! depth = launcher->runDepth_m; ! y += widgetHeight + 5; ! ! speedAdjust = new tcNumberWidget(speed, this, wxPoint(x, y), ! wxSize(widgetWidth, widgetHeight)); ! speedAdjust->SetBackgroundAlpha(widgetAlpha); ! speedAdjust->SetCaption("Speed"); ! speedAdjust->SetFontSize(widgetFontSize); ! speedAdjust->SetActive(true); ! speedAdjust->SetSendRedraw(true); ! speed = launcher->preEnableSpeed_kts; ! y += widgetHeight + 5; ! ! ceilingAdjust = new tcNumberWidget(ceiling, this, wxPoint(x, y), ! wxSize(widgetWidth, widgetHeight)); ! ceilingAdjust->SetBackgroundAlpha(widgetAlpha); ! ceilingAdjust->SetCaption("Ceiling"); ! ceilingAdjust->SetFontSize(widgetFontSize); ! ceilingAdjust->SetActive(true); ! ceilingAdjust->SetSendRedraw(true); ! ceiling = launcher->ceiling_m; ! y += widgetHeight + 5; ! ! floorAdjust = new tcNumberWidget(floor, this, wxPoint(x, y), ! wxSize(widgetWidth, widgetHeight)); ! floorAdjust->SetBackgroundAlpha(widgetAlpha); ! floorAdjust->SetCaption("Floor"); ! floorAdjust->SetFontSize(widgetFontSize); ! floorAdjust->SetActive(true); ! floorAdjust->SetSendRedraw(true); ! floor = launcher->floor_m; ! y += widgetHeight + 5; ! ! //tcButton* activePassiveButton; ! } ! ! /** ! * Update torpedo launcher with GUI params ! */ ! void tcLauncherPopup::UpdateTorpedoLauncher() ! { ! tcLauncher* launcher = GetLauncher(); ! wxASSERT(launcher); ! ! launcher->runToEnable_m = runToEnable; ! ! launcher->runDepth_m = depth; ! launcher->preEnableSpeed_kts = speed; ! launcher->ceiling_m = ceiling; ! launcher->floor_m = floor; ! launcher->usePassive = isPassive; ! } ! ! /** ! * Intended to be overrided to intercept command events from GUI ! * objects within the window. ! * This routine intercepts the ID_BUTTONREDRAW event. ! */ ! void tcLauncherPopup::OnChildRedraw(wxCommandEvent& event) ! { ! redraw = true; ! } ! ! /** ! * Close and destroy popup ! */ ! void tcLauncherPopup::OnCloseCommand(wxCommandEvent& event) ! { ! destroy = true; ! } ! ! ! void tcLauncherPopup::OnDatumCommand(wxCommandEvent& event) ! { ! redraw = true; ! ! if (tcLauncher* launcher = GetLauncher()) { ! tcCommandQueue::Get()->GetUserInputForID("SetDatum", "Datum", platformId, launcherIdx); } ! } ! ! void tcLauncherPopup::OnLaunchCommand(wxCommandEvent& event) ! { ! redraw = true; ! ! if (tcLauncher* launcher = GetLauncher()) { ! if (launcher->GetLauncherStatus() == tcLauncher::LAUNCHER_READY) { ! launcher->mnUncommitted -= 1; ! if (launcher->mnUncommitted < 0) ! { ! launcher->mnUncommitted = 0; // don't set new cmd here since this is an error case ! std::cerr << "Error - tcLauncherState::SetLaunch - negative uncommitted\n"; ! } ! //else ! //{ ! // commandObj.SetNewCommand(GetLauncherFlag(nLauncher)); ! //} } } ! } ! ! /** ! * A hack job for now :) ! */ ! void tcLauncherPopup::OnLButtonDown(wxMouseEvent& event) ! { ! wxPoint pos = event.GetPosition(); ! ! isLButtonDown = true; ! if ((pos.y <= 10) || (pos.y >= mnHeight)) { ! dragOn = true; ! // position in parent's frame of mouse pointer ! dragPoint = wxPoint(mrectWindow.GetLeft() + pos.x, mrectWindow.GetBottom() + pos.y); ! return; } + } *************** *** 190,195 **** * */ ! void tcLauncherPopup::OnMouseOver(wxMouseEvent& event) { } --- 335,362 ---- * */ ! void tcLauncherPopup::OnLButtonUp(wxMouseEvent& event) { + isLButtonDown = false; + dragOn = false; + } + + /** + * + */ + void tcLauncherPopup::OnMouseMove(wxMouseEvent& event) + { + if (!dragOn) return; + + wxPoint pos = event.GetPosition(); + + // position in parent's frame of mouse pointer + wxPoint current = wxPoint(mrectWindow.GetLeft() + pos.x, mrectWindow.GetBottom() + pos.y); + if (current != dragPoint) + { + wxPoint delta = current - dragPoint; + tc3DWindow::MoveWindow(mrectWindow.GetLeft() + delta.x, + mrectWindow.GetTop() + delta.y); + dragPoint = current; + } } *************** *** 200,207 **** */ tcLauncherPopup::tcLauncherPopup(long id, unsigned idx, const wxPoint& pos) ! : tc3DWindow(parent, pos, wxSize(150, 50), "LauncherPopupControl", parent), platformId(id), launcherIdx(idx), ! redraw(true) { SetBaseRenderBin(parent->GetBaseRenderBin() + 10); --- 367,376 ---- */ tcLauncherPopup::tcLauncherPopup(long id, unsigned idx, const wxPoint& pos) ! : tc3DWindow(parent, pos, wxSize(200, 150), "LauncherPopupControl", parent), platformId(id), launcherIdx(idx), ! redraw(true), ! dragOn(false), ! destroy(false) { SetBaseRenderBin(parent->GetBaseRenderBin() + 10); *************** *** 211,214 **** --- 380,396 ---- wxASSERT(simState); + const int closeButtonSize = 12; + closeButton = new tcButton(this, wxPoint(mnWidth - closeButtonSize, 0), + wxSize(closeButtonSize, closeButtonSize)); + closeButton->SetActive(true); + closeButton->SetBackgroundAlpha(1.0); + closeButton->SetCaption(""); + closeButton->SetCommand(LP_CLOSE); + closeButton->LoadImages("close.png", "close.png", "close.png", "close.png"); + closeButton->SetSendRedraw(true); + + + InitTorpedoControls(); + SetActive(true); } Index: tc3DWindow.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tc3DWindow.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** tc3DWindow.cpp 7 Dec 2004 04:00:28 -0000 1.12 --- tc3DWindow.cpp 21 Dec 2004 02:26:17 -0000 1.13 *************** *** 1538,1542 **** osg::ref_ptr<osg::MatrixTransform> transform = new osg::MatrixTransform; ! transform->setReferenceFrame(osg::MatrixTransform::RELATIVE_TO_PARENTS); transform->setDataVariance(osg::Object::DYNAMIC); --- 1538,1542 ---- osg::ref_ptr<osg::MatrixTransform> transform = new osg::MatrixTransform; ! transform->setReferenceFrame(osg::MatrixTransform::RELATIVE_RF); transform->setDataVariance(osg::Object::DYNAMIC); *************** *** 1568,1571 **** --- 1568,1576 ---- HideUnusedObjects(); + + for (size_t n=0; n<children.size(); n++) + { + children[n]->ClearDrawObjects(); + } } *************** *** 1862,1866 **** transform->setDataVariance(osg::Object::DYNAMIC); transform->setMatrix(osg::Matrix::translate(pos.x, pos.y + yOffset, 0)); ! transform->setReferenceFrame(osg::MatrixTransform::RELATIVE_TO_PARENTS); } else --- 1867,1871 ---- transform->setDataVariance(osg::Object::DYNAMIC); transform->setMatrix(osg::Matrix::translate(pos.x, pos.y + yOffset, 0)); ! transform->setReferenceFrame(osg::MatrixTransform::RELATIVE_RF); } else *************** *** 1869,1873 **** transform->setDataVariance(osg::Object::DYNAMIC); transform->setMatrix(osg::Matrix::translate(pos.x, pos.y + yOffset, 0)); ! transform->setReferenceFrame(osg::MatrixTransform::RELATIVE_TO_ABSOLUTE); } --- 1874,1878 ---- transform->setDataVariance(osg::Object::DYNAMIC); transform->setMatrix(osg::Matrix::translate(pos.x, pos.y + yOffset, 0)); ! transform->setReferenceFrame(osg::MatrixTransform::ABSOLUTE_RF); } |