Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 34 additions & 20 deletions include/viz/FixedPixelText.H
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#ifndef FIXEDPIXELTEXT_H
#define FIXEDPIXELTEXT_H

#include <cstddef>
#include <GL/gl.h>

// Draw a bitmap string with a fixed screen-space advance between glyphs.
// Drawing glyphs under a window-coordinate projection prevents camera zoom
// from changing the raster advance used by glBitmap.
inline void drawFixedPixelBitmapText(GLuint fontOffset, const char *text,
GLdouble glyphAdvance)
// Draw the fixed 9x15 font with screen-space pixels. Drawing each set bit
// as geometry avoids OpenGL's glBitmap path, which can allocate temporary
// textures in software renderers while drawing display lists.
inline void drawFixedPixelText(const GLubyte *const *glyphs,
const char *text,
GLdouble glyphAdvance)
{
if (!text || !*text)
if (!glyphs || !text || !*text)
return;

GLboolean valid = GL_FALSE;
Expand All @@ -27,9 +29,6 @@ inline void drawFixedPixelBitmapText(GLuint fontOffset, const char *text,

GLint matrixMode;
glGetIntegerv(GL_MATRIX_MODE, &matrixMode);
glPushAttrib(GL_PIXEL_MODE_BIT);
glPixelZoom(1.0f, 1.0f);

glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
Expand All @@ -41,23 +40,38 @@ inline void drawFixedPixelBitmapText(GLuint fontOffset, const char *text,
glLoadIdentity();

const GLdouble windowZ = 1.0 - 2.0 * raster[2];
for (const unsigned char *character =
reinterpret_cast<const unsigned char *>(text);
*character != '\0'; ++character) {
const GLdouble windowX = raster[0] + glyphAdvance *
(character - reinterpret_cast<const unsigned char *>(text));
glRasterPos3d(windowX, raster[1], windowZ);
glGetBooleanv(GL_CURRENT_RASTER_POSITION_VALID, &valid);
if (!valid)
break;
glCallList(fontOffset + *character);
glBegin(GL_QUADS);
for (std::size_t index = 0; text[index] != '\0'; ++index) {
const unsigned char code = static_cast<unsigned char>(text[index]);
const GLubyte *glyph = glyphs[code];
if (!glyph) continue;

// The first byte is the glyph width; the bitmap is stored as two
// most-significant-bit-first bytes for each of its 16 rows. The
// visible font is 9x15, as in the former glBitmap display lists.
const GLubyte *bitmap = glyph + 1;
const GLdouble originX = raster[0] + glyphAdvance * index;
for (int row = 0; row < 15; ++row) {
const unsigned int bits =
(static_cast<unsigned int>(bitmap[row * 2]) << 8) |
static_cast<unsigned int>(bitmap[row * 2 + 1]);
for (int column = 0; column < 9; ++column) {
if ((bits & (0x8000u >> column)) == 0) continue;
const GLdouble x = originX + column;
const GLdouble y = raster[1] + row;
glVertex3d(x, y, windowZ);
glVertex3d(x + 1, y, windowZ);
glVertex3d(x + 1, y + 1, windowZ);
glVertex3d(x, y + 1, windowZ);
}
}
}
glEnd();

glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(matrixMode);
glPopAttrib();
}

#endif
4 changes: 2 additions & 2 deletions src/apps/basistool/WxBasisToolApp.C
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "dsm/ResourceDescriptor.H"

#include "wxgui/WxFeedback.H"
#include "wxgui/ewxWindowUtils.H"

#include "WxBasisToolApp.H"
#include "WxBasisTool.H"
Expand Down Expand Up @@ -191,9 +192,8 @@ void WxBasisToolApp::invokeMCB(JMSMessage& msg)
this->setPollContext(urlstr);

p_basisToolFrame->Iconize(false);
p_basisToolFrame->Raise();
p_basisToolFrame->Show(true);
p_basisToolFrame->SetFocus();
ewxRaiseWindow(p_basisToolFrame);
p_basisToolFrame->RequestUserAttention();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/apps/builder/Builder.C
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,7 @@ void Builder::setContext(const string& url, const bool& force)
bool newContext = false;

// Make sure it is raised/uniconified for popup dialogs
Raise();
ewxRaiseWindow(this);

if (p_calculation) {
if (p_calculation->getURL()==url && !force) {
Expand Down
6 changes: 4 additions & 2 deletions src/apps/builder/BuilderApp.C
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ void BuilderApp::invokeMCB(JMSMessage& msg)
if (action == "" && urlstr.empty()) {

// "New Structure": no calculation, keep the default context
p_builder->Raise();

} else if (action == "") {

Expand Down Expand Up @@ -552,7 +551,10 @@ void BuilderApp::invokeMCB(JMSMessage& msg)

registerTopShell(p_builder);
p_builder->Iconize(false);
#ifdef __WXMSW__
#ifdef __WXGTK__
p_builder->Show(true);
ewxRaiseWindow(p_builder);
#elif defined(__WXMSW__)
p_builder->Show(true);
ewxRaiseWindow(p_builder);
#else
Expand Down
4 changes: 2 additions & 2 deletions src/apps/calced/CalcEdApp.C
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "dsm/EDSIServerCentral.H"
#include "dsm/ResourceDescriptor.H"

#include "wxgui/ewxWindowUtils.H"
#include "CalcEdApp.H"
#include "CalcEd.H"

Expand Down Expand Up @@ -148,8 +149,7 @@ void CalcEdApp::invokeMCB(JMSMessage& msg)

p_calced->Iconize(false);
showEditor();
p_calced->Raise();
p_calced->SetFocus();
ewxRaiseWindow(p_calced);
p_calced->RequestUserAttention();
} else {
showEditor();
Expand Down
6 changes: 0 additions & 6 deletions src/apps/launcher/WxLauncherApp.C
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,9 @@ void WxLauncherApp::invokeMCB(JMSMessage& msg)
this->setPollContext(url);

p_launchFrame->Iconize(false);
#ifdef __WXMSW__
p_launchFrame->Show(true);
ewxRaiseWindow(p_launchFrame);
#else
p_launchFrame->Raise();
p_launchFrame->Show(true);
p_launchFrame->SetFocus();
p_launchFrame->RequestUserAttention();
#endif
}
}

Expand Down
25 changes: 25 additions & 0 deletions src/apps/organizer/CalcMgr.C
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ bool CalcMgr::Create( wxWindow* parent, wxWindowID id, const wxString& caption,
* collapse events during it, then the tree
* size <w> <h> resize the Organizer window
* firstvisible the label of the tree's top visible row (its scroll)
* scrollsummary scroll the calculation summary to its bottom and back
* showbox scroll the summary panel so that the Progress box is at
* its top
* progressbox the shown summary's Progress box: shown or not, its
Expand Down Expand Up @@ -1064,6 +1065,30 @@ void CalcMgr::runTestCommand(const string& line)
for (int i = 0; i < 5; i++) wxYield();
}
outcome = box ? "scrolled" : "no box";
} else if (command == "scrollsummary") {
CalculationContextPanel *panel =
dynamic_cast<CalculationContextPanel*>(p_contextPanel);
for (int i = 0; i < 5; i++) wxYield();
if (panel) {
const wxSize virtualSize = panel->GetVirtualSize();
const wxSize clientSize = panel->GetClientSize();
int unitY = 1;
panel->GetScrollPixelsPerUnit(0, &unitY);
const int maxY = std::max(0, (virtualSize.y - clientSize.y +
std::max(1, unitY) - 1) /
std::max(1, unitY));
if (maxY > 0) {
panel->Scroll(-1, maxY);
for (int i = 0; i < 5; i++) wxYield();
panel->Scroll(-1, 0);
for (int i = 0; i < 5; i++) wxYield();
outcome = "scrolled to " + std::to_string(maxY) + " and back";
} else {
outcome = "no scroll range";
}
} else {
outcome = "no calculation panel";
}
} else if (command == "progressbox") {
CalculationContextPanel *panel =
dynamic_cast<CalculationContextPanel*>(p_contextPanel);
Expand Down
4 changes: 2 additions & 2 deletions src/apps/organizer/CalcMgrApp.C
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "dsm/EDSIFactory.H"

#include "wxgui/ewxSplash.H"
#include "wxgui/ewxWindowUtils.H"
#include "wxgui/WxJMSMessageDispatch.H"
#include "wxgui/WxJMSSubscriber.H"
#include "wxgui/WxState.H"
Expand Down Expand Up @@ -286,9 +287,8 @@ void CalcMgrApp::invokeMCB(JMSMessage& msg)
const string app = msg.getProperty("appname");
if (!app.empty() && app != "Organizer") return;
p_calcMgr->Iconize(false);
p_calcMgr->Raise();
p_calcMgr->Show(true);
p_calcMgr->SetFocus();
ewxRaiseWindow(p_calcMgr);
p_calcMgr->RequestUserAttention();
}

Expand Down
37 changes: 25 additions & 12 deletions src/apps/organizer/CalculationContextPanel.C
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,22 @@ static bool basisToolOff(Resource *res, ResourceTool *tool)
return code && code->getBasisSetToolHidden();
}

// wxGTK's fixed-position child container may still allocate widgets hidden
// through a sizer. Collapse inactive controls in the sizer while keeping the
// native child GTK-visible at zero size.
static void setSizerChildVisible(wxWindow *window, bool visible)
{
wxSizer *sizer = window->GetContainingSizer();
if (visible) {
if (sizer) sizer->Show(window, true);
window->Show(true);
} else {
if (sizer) sizer->Show(window, false);
window->Show(true);
window->SetSize(0, 0, 0, 0);
}
}



/**
Expand Down Expand Up @@ -290,6 +306,8 @@ void CalculationContextPanel::updateProgress()
const bool show = p_progressBox->wanted();
if (show != GetSizer()->IsShown(p_progressSizer)) {
GetSizer()->Show(p_progressSizer, show);
p_progressBox->Show(true);
if (!show) p_progressBox->SetSize(0, 0, 0, 0);
Layout();
FitInside();
} else if (show && resized) {
Expand Down Expand Up @@ -438,6 +456,8 @@ void CalculationContextPanel::createControls()
p_progressSizer->Add(p_progressBox, wxSizerFlags(1).Expand().Border());
GetSizer()->Add(p_progressSizer, wxSizerFlags().Expand().Border());
GetSizer()->Hide(p_progressSizer);
p_progressBox->Show(true);
p_progressBox->SetSize(0, 0, 0, 0);
}
} // end of ToolPropertyView for loop

Expand Down Expand Up @@ -668,18 +688,11 @@ void CalculationContextPanel::setPropValue(ResourceProperty* resProp)
p_inpProvProps->findValue(resProp->getQName(), valuestr);
}

// some properties will have no value, but we want them to be displayed on the
// panel anyway, so show the user a place-holder
if (valuestr == "") {
if (! resProp->getDisplay()) // do we force the label/prop's display?
{
label->Hide();
prop->Hide();
}
} else {
label->Show();
prop->Show();
}
// Empty metadata fields take no sizer space, while their GTK widgets remain
// visible at zero size so scrolling cannot allocate a hidden child.
const bool show = !valuestr.empty() || resProp->getDisplay();
setSizerChildVisible(label, show);
setSizerChildVisible(prop, show);

// the property might need special formatting or other considerations based
// on its type
Expand Down
16 changes: 12 additions & 4 deletions src/apps/organizer/ProgressBox.C
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ ProgressBox::ProgressBox(wxWindow *parent)
ewxConfig::getConfig(INIFILE)->Read(FOLDKEY, &p_collapsed);
p_energyLabel = new wxStaticText(this, wxID_ANY, "");
ewxMakeSelectable(p_energyLabel);
p_energyLabel->Hide();
p_energyLabel->SetSize(0, 0, 0, 0);
p_energyLabel->Show(true);
p_energyLabel->Bind(wxEVT_CONTEXT_MENU, &ProgressBox::OnContextMenu, this);
for (int i = 0; i < 3; i++) {
p_buttons[i] = new wxButton(this, wxID_ANY, ACTIONS[i]);
p_buttons[i]->Hide();
p_buttons[i]->SetSize(0, 0, 0, 0);
p_buttons[i]->Show(true);
p_buttons[i]->Bind(wxEVT_BUTTON, [this, i](wxCommandEvent&) {
if (p_action) p_action(i);
});
Expand Down Expand Up @@ -683,8 +685,14 @@ wxSize ProgressBox::layout(wxDC *dc)
}
}
if (!dc && !buttonsShown)
for (int i = 0; i < 3; i++) p_buttons[i]->Hide();
if (!dc && !energyShown) p_energyLabel->Hide();
for (int i = 0; i < 3; i++) {
p_buttons[i]->SetSize(0, 0, 0, 0);
p_buttons[i]->Show(true);
}
if (!dc && !energyShown) {
p_energyLabel->SetSize(0, 0, 0, 0);
p_energyLabel->Show(true);
}
return size;
}

Expand Down
2 changes: 1 addition & 1 deletion src/viz/propsgcommands/IsoSurfaceCmd.C
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ bool IsoSurfaceCmd::execute()
}
lattice->coord.setValues(0, resX+resY+resZ, coords);

delete coords;
delete[] coords;
}


Expand Down
16 changes: 3 additions & 13 deletions src/wxgui/jms/WxJMSMessageDispatch.C
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "dsm/ResourceDescriptor.H"
#include "dsm/ResourceTool.H"

#include "wxgui/ewxWindowUtils.H"
#include "wxgui/WxJMSMessageDispatch.H"

// KLS 9/6/06
Expand Down Expand Up @@ -329,19 +330,8 @@ void WxJMSMessageDispatch::notifyReady()
void WxJMSMessageDispatch::raiseAllWindows()
{
for (int win=p_topShells.size()-1; win>=0; win--) {
// wxTopLevelWindow * topLevelWin =
// dynamic_cast<wxTopLevelWindow *>(p_topShells[win]);
// if (topLevelWin) {
// topLevelWin->Iconize(false);
// topLevelWin->Raise();
// topLevelWin->Show(true);
// topLevelWin->SetFocus();
// topLevelWin->RequestUserAttention();
// }
// else {
(p_topShells[win])->Raise();
(p_topShells[win])->Show(true);
// }
p_topShells[win]->Show(true);
ewxRaiseWindow(p_topShells[win]);
}
}

Expand Down
Loading
Loading