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.
@@ -223,6 +223,9 @@ MainView_refreshCachedInfo(MainView *mview) | ||
223 | 223 | for (i = 0; i < mol->natoms; i++) { |
224 | 224 | mview->visibleFlags[i] &= ~2; |
225 | 225 | } |
226 | + | |
227 | + /* Store the tableIndex value */ | |
228 | + mview->cachedTableIndex = mview->tableIndex; | |
226 | 229 | } |
227 | 230 | |
228 | 231 | #pragma mark ====== 2D/3D transform operations ====== |
@@ -324,7 +327,7 @@ MainView_convertObjectPositionToScreenPosition(MainView *mview, const double *ob | ||
324 | 327 | if (glGetError() == GL_NO_ERROR) { |
325 | 328 | screenPos[0] = objX / scale; |
326 | 329 | screenPos[1] = objY / scale; |
327 | - screenPos[2] = objZ / scale; | |
330 | + screenPos[2] = objZ; | |
328 | 331 | /* fprintf(stderr, "object(%.3f,%.3f,%.3f) screen(%.3f,%.3f,%.3f)\n", objectPos[0], objectPos[1], objectPos[2], screenPos[0], screenPos[1], screenPos[2]); */ |
329 | 332 | return 1; |
330 | 333 | } else return 0; |
@@ -189,7 +189,8 @@ typedef struct MainView { | ||
189 | 189 | /* Caches for the table view; recalculated in MainView_refreshCachedInfo */ |
190 | 190 | struct IntGroup *tableCache; /* Indices of atoms etc. that are shown in the table */ |
191 | 191 | struct IntGroup *tableSelection; /* Selected rows in the table */ |
192 | - | |
192 | + int cachedTableIndex; /* The value of tableIndex at the last call to MainView_refreshCachedInfo */ | |
193 | + | |
193 | 194 | /* Print support */ |
194 | 195 | Byte isPrinting; |
195 | 196 |
@@ -236,10 +236,10 @@ MoleculeView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) | ||
236 | 236 | { // "Rotate bond" button and mySlider |
237 | 237 | #include "../bitmaps/rotate_bond.xpm" |
238 | 238 | 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); | |
240 | 240 | sizer31->Add(button1, 0, 0, 0); |
241 | 241 | 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))); | |
243 | 243 | sizer31->Add(slider1, 1, wxEXPAND); |
244 | 244 | } |
245 | 245 | sizer3->Add(sizer31, 0, wxALL | wxEXPAND, 0); |
@@ -376,7 +376,7 @@ MoleculeView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) | ||
376 | 376 | wxGetApp().Connect(MyDocumentEvent_scriptMenuModified, MyDocumentEvent, wxCommandEventHandler(MoleculeView::OnScriptMenuModified), NULL, this); |
377 | 377 | |
378 | 378 | // 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); | |
380 | 380 | |
381 | 381 | // Set data source for the list control |
382 | 382 | listctrl->SetDataSource(this); |
@@ -562,13 +562,13 @@ MoleculeView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint)) | ||
562 | 562 | bool |
563 | 563 | MoleculeView::OnClose(bool deleteWindow) |
564 | 564 | { |
565 | -#if !defined(__WXMAC__) | |
565 | +//#if !defined(__WXMAC__) && !defined(__WXOSX__) | |
566 | 566 | // On wxOSX, this causes invocation of MyDocument::Close() twice, which |
567 | 567 | // apprently is not very good. However, on wxMSW this is not the case. |
568 | 568 | // So we need to keep this code for wxMSW but not for wxOSX. |
569 | 569 | if (!GetDocument()->Close()) |
570 | 570 | return false; |
571 | -#endif | |
571 | +//#endif | |
572 | 572 | |
573 | 573 | // Dispose relationship between this and Molecule (MainView) |
574 | 574 | MainView_setViewObject(mview, NULL); |
@@ -609,6 +609,7 @@ MoleculeView::Activate(bool activate) | ||
609 | 609 | sActiveViews.Insert(this, 0); |
610 | 610 | } |
611 | 611 | wxView::Activate(activate); |
612 | + frame->Refresh(); | |
612 | 613 | } |
613 | 614 | |
614 | 615 | wxPrintout * |
@@ -792,12 +793,46 @@ MoleculeView::OnStopProgressPressed(wxCommandEvent& event) | ||
792 | 793 | void |
793 | 794 | MoleculeView::OnDocumentModified(wxCommandEvent& event) |
794 | 795 | { |
796 | + int xpos, ypos, rowindex, newypos; | |
795 | 797 | if (!mview->freezeScreen) { |
796 | 798 | if (canvas) |
797 | 799 | canvas->Refresh(); |
798 | 800 | UpdateFrameControls(); |
799 | 801 | 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 | + } | |
800 | 819 | 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); | |
801 | 836 | MoleculeUnlock(mview->mol); |
802 | 837 | } |
803 | 838 |