• R/O
  • HTTP
  • SSH
  • HTTPS

Molby: コミット

Molecular Modeling Software


コミットメタ情報

リビジョンa0980d39eb025a61bc942f42d5f8afe5a58511b6 (tree)
日時2022-09-19 00:32:41
作者Toshi Nagata <alchemist.2005@nift...>
コミッターToshi Nagata

ログメッセージ

The scroll position of the atom list is always reset after any change. Fixed.

変更サマリ

差分

--- a/MolLib/MainView.c
+++ b/MolLib/MainView.c
@@ -223,6 +223,9 @@ MainView_refreshCachedInfo(MainView *mview)
223223 for (i = 0; i < mol->natoms; i++) {
224224 mview->visibleFlags[i] &= ~2;
225225 }
226+
227+ /* Store the tableIndex value */
228+ mview->cachedTableIndex = mview->tableIndex;
226229 }
227230
228231 #pragma mark ====== 2D/3D transform operations ======
@@ -324,7 +327,7 @@ MainView_convertObjectPositionToScreenPosition(MainView *mview, const double *ob
324327 if (glGetError() == GL_NO_ERROR) {
325328 screenPos[0] = objX / scale;
326329 screenPos[1] = objY / scale;
327- screenPos[2] = objZ / scale;
330+ screenPos[2] = objZ;
328331 /* fprintf(stderr, "object(%.3f,%.3f,%.3f) screen(%.3f,%.3f,%.3f)\n", objectPos[0], objectPos[1], objectPos[2], screenPos[0], screenPos[1], screenPos[2]); */
329332 return 1;
330333 } else return 0;
--- a/MolLib/MainView.h
+++ b/MolLib/MainView.h
@@ -189,7 +189,8 @@ typedef struct MainView {
189189 /* Caches for the table view; recalculated in MainView_refreshCachedInfo */
190190 struct IntGroup *tableCache; /* Indices of atoms etc. that are shown in the table */
191191 struct IntGroup *tableSelection; /* Selected rows in the table */
192-
192+ int cachedTableIndex; /* The value of tableIndex at the last call to MainView_refreshCachedInfo */
193+
193194 /* Print support */
194195 Byte isPrinting;
195196
--- a/wxSources/MoleculeView.cpp
+++ b/wxSources/MoleculeView.cpp
@@ -236,10 +236,10 @@ MoleculeView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
236236 { // "Rotate bond" button and mySlider
237237 #include "../bitmaps/rotate_bond.xpm"
238238 wxBitmap bmp1(rotate_bond_xpm);
239- wxBitmapButton *button1 = new wxBitmapButton(panel1, -1, bmp1, wxDefaultPosition, wxSize(21, 21), wxTOGGLEBUTTON_STYLE);
239+ wxBitmapButton *button1 = new wxBitmapButton(panel1, -1, bmp1, wxDefaultPosition, FromFrameDIP(frame, wxSize(21, 21)), wxTOGGLEBUTTON_STYLE);
240240 sizer31->Add(button1, 0, 0, 0);
241241 button1->Disable();
242- MySlider *slider1 = new MySlider(panel1, myID_RotateBondSlider, wxVERTICAL, wxDefaultPosition, wxSize(21, 21));
242+ MySlider *slider1 = new MySlider(panel1, myID_RotateBondSlider, wxVERTICAL, wxDefaultPosition, FromFrameDIP(frame, wxSize(21, 21)));
243243 sizer31->Add(slider1, 1, wxEXPAND);
244244 }
245245 sizer3->Add(sizer31, 0, wxALL | wxEXPAND, 0);
@@ -376,7 +376,7 @@ MoleculeView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
376376 wxGetApp().Connect(MyDocumentEvent_scriptMenuModified, MyDocumentEvent, wxCommandEventHandler(MoleculeView::OnScriptMenuModified), NULL, this);
377377
378378 // Intercept the double-click handler of MyListCtrl
379- listctrl->Connect(wxEVT_LEFT_DCLICK, wxMouseEventHandler(MoleculeView::OnLeftDClickInListCtrl), NULL, this);
379+ listctrl->GetScrolledWindow()->Bind(wxEVT_LEFT_DCLICK, &MoleculeView::OnLeftDClickInListCtrl, this);
380380
381381 // Set data source for the list control
382382 listctrl->SetDataSource(this);
@@ -562,13 +562,13 @@ MoleculeView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint))
562562 bool
563563 MoleculeView::OnClose(bool deleteWindow)
564564 {
565-#if !defined(__WXMAC__)
565+//#if !defined(__WXMAC__) && !defined(__WXOSX__)
566566 // On wxOSX, this causes invocation of MyDocument::Close() twice, which
567567 // apprently is not very good. However, on wxMSW this is not the case.
568568 // So we need to keep this code for wxMSW but not for wxOSX.
569569 if (!GetDocument()->Close())
570570 return false;
571-#endif
571+//#endif
572572
573573 // Dispose relationship between this and Molecule (MainView)
574574 MainView_setViewObject(mview, NULL);
@@ -609,6 +609,7 @@ MoleculeView::Activate(bool activate)
609609 sActiveViews.Insert(this, 0);
610610 }
611611 wxView::Activate(activate);
612+ frame->Refresh();
612613 }
613614
614615 wxPrintout *
@@ -792,12 +793,46 @@ MoleculeView::OnStopProgressPressed(wxCommandEvent& event)
792793 void
793794 MoleculeView::OnDocumentModified(wxCommandEvent& event)
794795 {
796+ int xpos, ypos, rowindex, newypos;
795797 if (!mview->freezeScreen) {
796798 if (canvas)
797799 canvas->Refresh();
798800 UpdateFrameControls();
799801 MoleculeLock(mview->mol);
802+
803+ // Get the current row/column value; if the table index is the same, keep the
804+ // displayed position as close as possible
805+ listctrl->GetScrollPosition(&xpos, &ypos);
806+ if (mview->cachedTableIndex != mview->tableIndex) {
807+ xpos = ypos = 0; /* Different table is shown; should reset the view */
808+ } else {
809+ if (mview->tableIndex >= kMainViewAtomTableIndex && mview->tableIndex <= kMainViewImproperTableIndex) {
810+ // Atom, Bond, Angle, Dihedral, Improper; use the cache
811+ int count = IntGroupGetCount(mview->tableCache);
812+ if (ypos < count)
813+ rowindex = IntGroupGetNthPoint(mview->tableCache, ypos);
814+ else if (count > 0)
815+ rowindex = IntGroupGetNthPoint(mview->tableCache, count - 1);
816+ else rowindex = 0;
817+ } else rowindex = ypos;
818+ }
800819 MainView_refreshTable(mview);
820+ if (mview->tableIndex >= kMainViewAtomTableIndex && mview->tableIndex <= kMainViewImproperTableIndex) {
821+ int ic, is, ie, i;
822+ ic = IntGroupGetIntervalCount(mview->tableCache);
823+ newypos = 0;
824+ for (i = 0; i < ic; i++) {
825+ is = IntGroupGetStartPoint(mview->tableCache, i);
826+ ie = IntGroupGetEndPoint(mview->tableCache, i);
827+ if (rowindex < ie) {
828+ if (rowindex >= is)
829+ newypos += (rowindex - is);
830+ break;
831+ }
832+ newypos += ie - is;
833+ }
834+ } else newypos = rowindex;
835+ listctrl->SetScrollPosition(xpos, newypos);
801836 MoleculeUnlock(mview->mol);
802837 }
803838
旧リポジトリブラウザで表示