glViewport(0, 0, width, height);
/* Clear the buffer */
- glClearColor(mview->background_color[0], mview->background_color[1], mview->background_color[2], 0);
+ glClearColor(mview->background_color[0], mview->background_color[1], mview->background_color[2], mview->background_color[3]);
glClear(GL_COLOR_BUFFER_BIT |
GL_DEPTH_BUFFER_BIT);
show
}
end
+
+ def ask_graphic_export_scale
+ scale = get_global_settings("global.export_graphic_scale")
+ scale = (scale ? scale.to_i - 1 : 3)
+ bg_color = get_global_settings("global.export_background_color")
+ bg_color = (bg_color ? bg_color.to_i + 1 : 0)
+ hash = Dialog.run("Set Export Properties") {
+ layout(2,
+ item(:text, :title=>"Resolution:"),
+ item(:popup, :subitems=>["Screen", "Screenx2", "Screenx3", "Screenx4", "Screenx5"], :tag=>"resolution", :value=>scale),
+ item(:text, :title=>"Background color:"),
+ item(:popup, :subitems=>["Same as Screen", "Transparent", "Black", "White"], :tag=>"bg_color", :value=>bg_color))
+ }
+ if hash[:status] == 0
+ set_global_settings("global.export_graphic_scale", (hash["resolution"] + 1).to_s)
+ set_global_settings("global.export_background_color", (hash["bg_color"] - 1).to_s)
+ return 0
+ else
+ return -1
+ end
+ end
# DEBUG
def cmd_test
}
wxImage *
-MoleculeView::CaptureGLCanvas(float scale)
+MoleculeView::CaptureGLCanvas(float scale, int bg_color)
{
if (canvas && mview->mol != NULL) {
int x, y, width, height;
-
+ float bgcol[4];
+
canvas->SetCurrent();
canvas->GetClientSize(&width, &height);
width *= scale;
MainView_initializeOpenGL();
mview->offline_scale = scale;
+ for (x = 0; x < 4; x++) {
+ bgcol[x] = mview->background_color[x];
+ }
+ if (bg_color == 0) {
+ mview->background_color[0] = 0;
+ mview->background_color[1] = 0;
+ mview->background_color[2] = 0;
+ mview->background_color[3] = 0;
+ } else if (bg_color == 1) {
+ mview->background_color[0] = 0;
+ mview->background_color[1] = 0;
+ mview->background_color[2] = 0;
+ mview->background_color[3] = 1;
+ } else if (bg_color == 2) {
+ mview->background_color[0] = 1;
+ mview->background_color[1] = 1;
+ mview->background_color[2] = 1;
+ mview->background_color[3] = 1;
+ }
MoleculeLock(mview->mol);
MainView_drawModel(mview);
MoleculeUnlock(mview->mol);
+ for (x = 0; x < 4; x++) {
+ mview->background_color[x] = bgcol[x];
+ }
mview->offline_scale = 0.0;
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
void OnDraw(wxDC *dc);
void OnUpdate(wxView *sender, wxObject *hint = (wxObject *) NULL);
bool OnClose(bool deleteWindow = true);
- wxImage *CaptureGLCanvas(float scale = 1.0);
+ wxImage *CaptureGLCanvas(float scale = 1.0, int bg_color = -1);
virtual void Activate (bool activate);
virtual wxPrintout *OnCreatePrintout();
wxString wildcard = _T("PNG File (*.png)|*.png|TIFF File (*.tif)|*.tif|All Files (*.*)|*.*");
wxFileName fname(GetFilename());
wxString fnstr;
- int i;
+ Int scale, bg_color, n, i;
+ char *p;
+ i = MolActionCreateAndPerform(mol, SCRIPT_ACTION(";i"), "ask_graphic_export_scale", &n);
+ if (i != 0 || n < 0)
+ return;
+ i = MyAppCallback_getGlobalSettingsWithType("global.export_graphic_scale", 'i', &scale);
+ if (i != 0)
+ scale = 4;
+ i = MyAppCallback_getGlobalSettingsWithType("global.export_background_color", 'i', &bg_color);
+ if (i != 0)
+ bg_color = 0;
GetPrintableName(fnstr);
if ((i = fnstr.Find('.', true)) != wxNOT_FOUND) {
fnstr = fnstr.Mid(0, i);
if (dialog->ShowModal() == wxID_OK) {
wxString fnpath = dialog->GetPath();
MoleculeView *myview = (MoleculeView *)GetFirstView();
- float scale = 4.0;
- wxImage *img = myview->CaptureGLCanvas(scale);
+ wxImage *img = myview->CaptureGLCanvas(scale, bg_color);
wxString ext = fnpath.AfterLast('.');
wxBitmapType type = wxBITMAP_TYPE_PNG;
if (ext.CmpNoCase(_T("tif")) == 0)