• R/O
  • HTTP
  • SSH
  • HTTPS

Molby: コミット

Molecular Modeling Software


コミットメタ情報

リビジョン4e23791d0294093d2f09141ed29a50a6f72042c3 (tree)
日時2022-09-13 21:59:18
作者Toshi Nagata <alchemist.2005@nift...>
コミッターToshi Nagata

ログメッセージ

OpenGL canvas is updated for supporting high-res display

変更サマリ

差分

--- a/MolLib/MainView.c
+++ b/MolLib/MainView.c
@@ -283,18 +283,19 @@ MainView_convertScreenPositionToObjectPosition(MainView *mview, const GLfloat *s
283283 GLint viewport[4], n;
284284 GLfloat winZ;
285285 GLdouble posX, posY, posZ;
286+ float scale = mview->view_scale;
286287 if (mview == NULL)
287288 return 0;
288289 MainViewCallback_frame(mview, rect);
289290 viewport[0] = viewport[1] = 0;
290- viewport[2] = (GLint)(rect[2] - rect[0]);
291- viewport[3] = (GLint)(rect[3] - rect[1]);
291+ viewport[2] = (GLint)(rect[2] - rect[0]) * scale;
292+ viewport[3] = (GLint)(rect[3] - rect[1]) * scale;
292293 MainViewCallback_lockFocus(mview);
293294 if (screenPos[2] >= 0.0)
294295 winZ = screenPos[2];
295296 else
296- glReadPixels(screenPos[0], screenPos[1], 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ);
297- gluUnProject(screenPos[0], screenPos[1], winZ, mview->modelview_matrix, mview->projection_matrix, viewport, &posX, &posY, &posZ);
297+ glReadPixels(screenPos[0] * scale, screenPos[1] * scale, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ);
298+ gluUnProject(screenPos[0] * scale, screenPos[1] * scale, winZ, mview->modelview_matrix, mview->projection_matrix, viewport, &posX, &posY, &posZ);
298299 n = glGetError();
299300 MainViewCallback_unlockFocus(mview);
300301 objectPos[0] = posX;
@@ -312,17 +313,18 @@ MainView_convertObjectPositionToScreenPosition(MainView *mview, const double *ob
312313 float rect[4];
313314 GLint viewport[4];
314315 GLdouble objX, objY, objZ;
316+ float scale = mview->view_scale;
315317 if (mview == NULL)
316318 return 0;
317319 MainViewCallback_frame(mview, rect);
318320 viewport[0] = viewport[1] = 0;
319- viewport[2] = (GLint)(rect[2] - rect[0]);
320- viewport[3] = (GLint)(rect[3] - rect[1]);
321+ viewport[2] = (GLint)(rect[2] - rect[0]) * scale;
322+ viewport[3] = (GLint)(rect[3] - rect[1]) * scale;
321323 gluProject(objectPos[0], objectPos[1], objectPos[2], mview->modelview_matrix, mview->projection_matrix, viewport, &objX, &objY, &objZ);
322324 if (glGetError() == GL_NO_ERROR) {
323- screenPos[0] = objX;
324- screenPos[1] = objY;
325- screenPos[2] = objZ;
325+ screenPos[0] = objX / scale;
326+ screenPos[1] = objY / scale;
327+ screenPos[2] = objZ / scale;
326328 /* fprintf(stderr, "object(%.3f,%.3f,%.3f) screen(%.3f,%.3f,%.3f)\n", objectPos[0], objectPos[1], objectPos[2], screenPos[0], screenPos[1], screenPos[2]); */
327329 return 1;
328330 } else return 0;
@@ -1730,13 +1732,14 @@ MainView_drawModel(MainView *mview)
17301732
17311733 if (!mview->isInitialized) {
17321734 MainView_initializeOpenGL();
1735+ mview->view_scale = MainViewCallback_getContentScaleFactor(mview);
17331736 mview->isInitialized = 1;
17341737 }
17351738
17361739 dimension = mview->dimension;
17371740
17381741 if (mview->offline_scale == 0.0)
1739- scale = 1.0;
1742+ scale = mview->view_scale;
17401743 else
17411744 scale = mview->offline_scale;
17421745
@@ -1840,11 +1843,11 @@ MainView_drawModel(MainView *mview)
18401843 glOrtho(0, width, 0, height, -1.0, 1.0);
18411844 glColor3f(1.0, 1.0, 0.0);
18421845 glBegin(GL_LINE_STRIP);
1843- glVertex2f(mview->dragStartPos[0], mview->dragStartPos[1]);
1844- glVertex2f(mview->dragStartPos[0], mview->dragEndPos[1]);
1845- glVertex2f(mview->dragEndPos[0], mview->dragEndPos[1]);
1846- glVertex2f(mview->dragEndPos[0], mview->dragStartPos[1]);
1847- glVertex2f(mview->dragStartPos[0], mview->dragStartPos[1]);
1846+ glVertex2f(mview->dragStartPos[0] * scale, mview->dragStartPos[1] * scale);
1847+ glVertex2f(mview->dragStartPos[0] * scale, mview->dragEndPos[1] * scale);
1848+ glVertex2f(mview->dragEndPos[0] * scale, mview->dragEndPos[1] * scale);
1849+ glVertex2f(mview->dragEndPos[0] * scale, mview->dragStartPos[1] * scale);
1850+ glVertex2f(mview->dragStartPos[0] * scale, mview->dragStartPos[1] * scale);
18481851 glEnd();
18491852 glEnable(GL_DEPTH_TEST);
18501853 enableLighting();
--- a/MolLib/MainView.h
+++ b/MolLib/MainView.h
@@ -133,6 +133,7 @@ typedef struct MainView {
133133 Byte freezeScreen;
134134 float dimension;
135135
136+ float view_scale; /* scale factor for display (for high resolution screens) */
136137 float offline_scale; /* If non-zero, this is the expansion factor for offline-rendering */
137138 int offline_width, offline_height; /* If non-zero, then these are size for offline-rendering */
138139
@@ -262,6 +263,7 @@ STUB int MainViewCallback_clickCount(void *eventRef);
262263 STUB void MainViewCallback_lockFocus(MainView *mview);
263264 STUB void MainViewCallback_unlockFocus(MainView *mview);
264265 STUB void MainViewCallback_frame(MainView *mview, float *rect);
266+STUB float MainViewCallback_getContentScaleFactor(MainView *mview);
265267 STUB void MainViewCallback_display(MainView *mview);
266268 STUB void MainViewCallback_makeFront(MainView *mview);
267269 STUB void MainViewCallback_setNeedsDisplay(MainView *mview, int flag);
--- a/build-xcode/Molby.xcodeproj/project.pbxproj
+++ b/build-xcode/Molby.xcodeproj/project.pbxproj
@@ -25,6 +25,7 @@
2525
2626 /* Begin PBXBuildFile section */
2727 E403568428CF6A3D008E2C46 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E403568328CF6A3D008E2C46 /* QuartzCore.framework */; };
28+ E403568528D0AD7E008E2C46 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4FC7845183E51180064FB2E /* Carbon.framework */; };
2829 E4059F9B28C46A6E0052B36B /* molby_icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = E4FC77D4183E4FF20064FB2E /* molby_icon.icns */; };
2930 E4059F9C28C46A6E0052B36B /* Scripts in Resources */ = {isa = PBXBuildFile; fileRef = E4FC77D6183E4FFE0064FB2E /* Scripts */; };
3031 E4059F9D28C46A6E0052B36B /* amber11 in Resources */ = {isa = PBXBuildFile; fileRef = E4FC77D8183E503E0064FB2E /* amber11 */; };
@@ -144,12 +145,10 @@
144145 E4FC7802183E503E0064FB2E /* amber11 in Resources */ = {isa = PBXBuildFile; fileRef = E4FC77D8183E503E0064FB2E /* amber11 */; };
145146 E4FC7811183E50DC0064FB2E /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4FC7810183E50DC0064FB2E /* Accelerate.framework */; };
146147 E4FC7838183E50F00064FB2E /* AGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4FC7837183E50F00064FB2E /* AGL.framework */; };
147- E4FC784C183E51180064FB2E /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4FC7845183E51180064FB2E /* Carbon.framework */; };
148148 E4FC784D183E51180064FB2E /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4FC7846183E51180064FB2E /* Cocoa.framework */; };
149149 E4FC784E183E51180064FB2E /* GLUT.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4FC7847183E51180064FB2E /* GLUT.framework */; };
150150 E4FC784F183E51180064FB2E /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4FC7848183E51180064FB2E /* IOKit.framework */; };
151151 E4FC7850183E51180064FB2E /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4FC7849183E51180064FB2E /* OpenGL.framework */; };
152- E4FC7851183E51180064FB2E /* QuickTime.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4FC784A183E51180064FB2E /* QuickTime.framework */; };
153152 E4FC7852183E51180064FB2E /* System.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4FC784B183E51180064FB2E /* System.framework */; };
154153 E4FC7A17183E51570064FB2E /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4FC7A15183E51570064FB2E /* AppKit.framework */; };
155154 E4FC7A18183E51570064FB2E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4FC7A16183E51570064FB2E /* Foundation.framework */; };
@@ -316,12 +315,11 @@
316315 E4FC7811183E50DC0064FB2E /* Accelerate.framework in Frameworks */,
317316 E4FC7838183E50F00064FB2E /* AGL.framework in Frameworks */,
318317 E403568428CF6A3D008E2C46 /* QuartzCore.framework in Frameworks */,
319- E4FC784C183E51180064FB2E /* Carbon.framework in Frameworks */,
320318 E4FC784D183E51180064FB2E /* Cocoa.framework in Frameworks */,
321319 E4FC784E183E51180064FB2E /* GLUT.framework in Frameworks */,
322320 E4FC784F183E51180064FB2E /* IOKit.framework in Frameworks */,
321+ E403568528D0AD7E008E2C46 /* Carbon.framework in Frameworks */,
323322 E4FC7850183E51180064FB2E /* OpenGL.framework in Frameworks */,
324- E4FC7851183E51180064FB2E /* QuickTime.framework in Frameworks */,
325323 E4FC7852183E51180064FB2E /* System.framework in Frameworks */,
326324 E4FC7A17183E51570064FB2E /* AppKit.framework in Frameworks */,
327325 E4FC7A18183E51570064FB2E /* Foundation.framework in Frameworks */,
--- a/wxSources/MoleculeView.cpp
+++ b/wxSources/MoleculeView.cpp
@@ -252,7 +252,7 @@ MoleculeView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
252252
253253 // Let the MyGLCanvas pass the keyboard event to this
254254 canvas->Connect(-1, wxEVT_CHAR, wxKeyEventHandler(MoleculeView::OnChar), NULL, this);
255- }
255+ }
256256 {
257257 wxBoxSizer *sizer321 = new wxBoxSizer(wxHORIZONTAL);
258258 {
@@ -1094,6 +1094,15 @@ MainViewCallback_frame(MainView *mview, float *rect)
10941094 }
10951095 }
10961096
1097+float
1098+MainViewCallback_getContentScaleFactor(MainView *mview)
1099+{
1100+ if (gUseGUI && mview != NULL && mview->ref != NULL) {
1101+ return ((MoleculeView *)(mview->ref))->canvas->GetContentScaleFactor();
1102+ } else return 1.0;
1103+}
1104+
1105+
10971106 void
10981107 MainViewCallback_display(MainView *mview)
10991108 {
--- a/wxSources/MyGLCanvas.cpp
+++ b/wxSources/MyGLCanvas.cpp
@@ -168,13 +168,14 @@ MyGLCanvas::OnSize(wxSizeEvent &event)
168168
169169 // set GL viewport (not called by wxGLCanvas::OnSize on all platforms...)
170170 int w, h;
171+ double scale = GetContentScaleFactor();
171172 GetClientSize(&w, &h);
172173 #ifndef __WXMOTIF__
173174 // if (GetContext())
174175 #endif
175176 {
176177 context->SetCurrent(*this);
177- glViewport(0, 0, (GLint) w, (GLint) h);
178+ glViewport(0, 0, (GLint) (w * scale), (GLint) (h * scale));
178179 }
179180 #if defined(__WXMSW__)
180181 // On MSW, the window is not repainted upon resize event
--- a/wxSources/MyListCtrl.cpp
+++ b/wxSources/MyListCtrl.cpp
@@ -74,7 +74,7 @@ MyListCtrl::Create(wxWindow* parent, wxWindowID wid, const wxPoint& pos, const w
7474 this->wxWindow::Create(parent, wid, pos, size);
7575
7676 header = new wxWindow(this, 1001, wxPoint(0, 0), wxSize(size.x, 12));
77- scroll = new wxScrolledWindow(this, 1002, wxPoint(0, 12), wxSize(size.x, (size.y <= 12 ? 100 : size.y) - 12));
77+ scroll = new wxScrolledWindow(this, 1002, wxPoint(0, 12), wxSize(size.x, (size.y <= 12 ? -1 : size.y - 12)));
7878
7979 // Set sizer
8080 wxBoxSizer *vsizer = new wxBoxSizer(wxVERTICAL);
@@ -173,7 +173,6 @@ MyListCtrl::RefreshTable(bool refreshWindow)
173173 header->SetMinSize(sz);
174174 scroll->SetScrollbars(rowHeight, rowHeight, floor((pageWidth + rowHeight - 1) / rowHeight), nrows);
175175 scroll->SetVirtualSize(pageWidth, pageHeight);
176- Fit();
177176 Layout();
178177 }
179178 needsReload = false;
旧リポジトリブラウザで表示