[GME-commit] GMESRC/GME/Gme GMEApp.cpp,1.134,1.135 GMEApp.h,1.29,1.30 GMEView.cpp,1.173,1.174 GMEView.h,1.70,1.71

gme-commit at list.isis.vanderbilt.edu gme-commit at list.isis.vanderbilt.edu
Tue Nov 15 20:06:56 CST 2005


Update of /project/gme-repository/GMESRC/GME/Gme
In directory escher:/tmp/cvs-serv22731

Modified Files:
	GMEApp.cpp GMEApp.h GMEView.cpp GMEView.h 
Log Message:
Notification send upon
MOUSEOVER
SELECTED
UNSELECTED

Double attribute format can be specified in Settings dialog.


CVS User: Zoltan Molnar, ISIS (zolmol)

Index: GMEApp.h
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/Gme/GMEApp.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** GMEApp.h	11 Jul 2005 17:42:19 -0000	1.29
--- GMEApp.h	15 Nov 2005 20:06:54 -0000	1.30
***************
*** 77,80 ****
--- 77,82 ----
  	int  autosaveFreq;
  	CString defZoomLev;
+ 	bool mouseOverNotify;
+ 	CString realFmtStr;
  
  public:
***************
*** 94,97 ****
--- 96,101 ----
  	void Autosave();
  	CString getDefZoomLev() { return defZoomLev; }
+ 	inline bool isMouseOverNotifyEnabled() { return mouseOverNotify; }
+ 	inline CString getRealFmtStr() { return realFmtStr; }
  
  	// Both empty: reset on close, only one empty: no change to that name.

Index: GMEView.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/Gme/GMEView.cpp,v
retrieving revision 1.173
retrieving revision 1.174
diff -C2 -d -r1.173 -r1.174
*** GMEView.cpp	31 Aug 2005 19:38:41 -0000	1.173
--- GMEView.cpp	15 Nov 2005 20:06:54 -0000	1.174
***************
*** 1308,1311 ****
--- 1308,1447 ----
  }
  
+ bool CGMEView::SendMouseOver4Object( CGuiObject * pObject)
+ {
+ 	bool ok = true;
+ 	try {
+ 		BeginTransaction();
+ 
+ 		if( pObject && pObject->mgaFco)
+ 		{
+ 			long oStatus;
+ 			COMTHROW(pObject->mgaFco->get_Status(&oStatus));
+ 			if(oStatus == OBJECT_EXISTS) // make sure it has not been deleted since then
+ 				COMTHROW( pObject->mgaFco->SendEvent(OBJEVENT_MOUSEOVER));
+ 		}
+ 
+ 		CommitTransaction();
+ 	}
+ 	catch(hresult_exception &e) {
+ 		AbortTransaction(e.hr);
+ 		ok = false;
+ 	}
+ 	return ok;
+ }
+ 
+ bool CGMEView::SendSelecEvent4Object( CGuiObject* pSelection)
+ {
+ 	bool ok = true;
+ 
+ 	std::list<CGuiObject*>::iterator found = std::find( m_lstUnselect.begin(), m_lstUnselect.end(), pSelection);
+ 	if( found != m_lstUnselect.end()) // it can't be unsel and sel at the same time
+ 	{
+ 		m_lstUnselect.erase( found);
+ 	}
+ 
+ 	found = std::find( m_lstSelect.begin(), m_lstSelect.end(), pSelection);
+ 	if( found != m_lstSelect.end()) // it should not be twice in sel
+ 	{
+ 		m_lstSelect.erase( found);
+ 	}
+ 
+ 	m_lstSelect.push_back( pSelection);
+ 	return ok;
+ }
+ 
+ bool CGMEView::SendUnselEvent4Object( CGuiObject* pUnselection)
+ {
+ 	bool ok = true;
+ 
+ 	std::list<CGuiObject*>::iterator found = std::find( m_lstSelect.begin(), m_lstSelect.end(), pUnselection);
+ 	if( found != m_lstSelect.end()) // it can't be unsel and sel at the same time
+ 	{
+ 		m_lstSelect.erase( found);
+ 	}
+ 
+ 	found = std::find( m_lstUnselect.begin(), m_lstUnselect.end(), pUnselection);
+ 	if( found != m_lstUnselect.end()) // it should not be twice in unsel
+ 	{
+ 		m_lstUnselect.erase( found);
+ 	}
+ 
+ 	m_lstUnselect.push_back( pUnselection);
+ 	return ok;
+ }
+ 
+ bool CGMEView::SendSelecEvent4List( CGuiObjectList* pSelection)
+ {
+ 	bool ok = true;
+ 	// send select event for each object in list
+ 	POSITION pos = pSelection->GetHeadPosition();
+ 	CGuiObject *obj;
+ 	while(pos) {
+ 		obj = pSelection->GetNext(pos);
+ 		bool ok2 = SendSelecEvent4Object( obj);
+ 		ok = ok && ok2;
+ 	}
+ 	return ok;
+ }
+ 
+ 
+ bool CGMEView::SendUnselEvent4List( CGuiObjectList* pUnselection)
+ {
+ 	bool ok = true;
+ 	// send deselect event for each object in list
+ 	POSITION pos = pUnselection->GetHeadPosition();
+ 	CGuiObject *obj;
+ 	while(pos) {
+ 		obj = pUnselection->GetNext(pos);
+ 		bool ok2 = SendUnselEvent4Object( obj);
+ 		ok = ok && ok2;
+ 	}
+ 	return ok;
+ }
+ 
+ void CGMEView::SendNow()
+ {
+ 	if( m_lstSelect.empty() && m_lstUnselect.empty())
+ 		return;
+ 
+ 	bool ok = true;
+ 	try {
+ 		BeginTransaction();
+ 
+ 		std::list<CGuiObject*>::iterator it;
+ 		for( it = m_lstUnselect.begin(); it != m_lstUnselect.end(); ++it)
+ 		{
+ 			CGuiObject * pUnselection = *it;
+ 			if( pUnselection && pUnselection->mgaFco)
+ 			{
+ 				long oStatus;
+ 				COMTHROW(pUnselection->mgaFco->get_Status(&oStatus));
+ 				if(oStatus == OBJECT_EXISTS) // make sure it has not been deleted since then
+ 					COMTHROW( pUnselection->mgaFco->SendEvent(OBJEVENT_DESELECT));
+ 			}
+ 		}
+ 
+ 		for( it = m_lstSelect.begin(); it != m_lstSelect.end(); ++it)
+ 		{
+ 			CGuiObject * pSelection = *it;
+ 			if( pSelection && pSelection->mgaFco)
+ 			{
+ 				long oStatus;
+ 				COMTHROW(pSelection->mgaFco->get_Status(&oStatus));
+ 				if(oStatus == OBJECT_EXISTS)
+ 					COMTHROW( pSelection->mgaFco->SendEvent(OBJEVENT_SELECT));
+ 			}
+ 		}
+ 
+ 		m_lstSelect.clear();
+ 		m_lstUnselect.clear();
+ 
+ 		CommitTransaction();
+ 	}
+ 	catch(hresult_exception &e) {
+ 		AbortTransaction(e.hr);
+ 		ok = false;
+ 	}
+ }
  void CGMEView::ResetParent()
  {
***************
*** 1504,1508 ****
  	}
  	try {
! 		BeginTransaction(TRANSACTION_READ_ONLY);
  		validGuiObjects = false;
  
--- 1640,1644 ----
  	}
  	try {
! 	BeginTransaction(TRANSACTION_READ_ONLY);
  		validGuiObjects = false;
  
***************
*** 1564,1568 ****
  		annotators.RemoveAll();
  		connections.RemoveAll();
! 		selected.RemoveAll();
  		selectedAnnotations.RemoveAll();
  
--- 1700,1704 ----
  		annotators.RemoveAll();
  		connections.RemoveAll();
! 		selected.RemoveAll(); // we don't call here the this->SendUnselEvent4List( &selected); because it might contain freshly deleted objects, which can't be notified
  		selectedAnnotations.RemoveAll();
  
***************
*** 1604,1608 ****
  				if(obj) {
  					if(id == obj->id)
! 						selected.AddTail(obj);
  				}
  			}
--- 1740,1744 ----
  				if(obj) {
  					if(id == obj->id)
! 						selected.AddTail(obj); // this->SendSelecEvent4Object( obj); omitted because of a READONLY transaction
  				}
  			}
***************
*** 1963,1966 ****
--- 2099,2103 ----
  {
  	CGMEEventLogger::LogGMEEvent("CGMEView::ModeChange in "+path+name+"\r\n");
+ 	this->SendUnselEvent4List( &selected);
  	selected.RemoveAll();
  	selectedAnnotations.RemoveAll();
***************
*** 2118,2127 ****
--- 2255,2267 ----
  				spos.y = min(spos.y, totalSize.cy);
  
+ 				this->SendUnselEvent4List( &selected);
  				selected.RemoveAll();
  				selectedAnnotations.RemoveAll();
+ 				this->SendSelecEvent4Object( guiObj);
  				selected.AddTail(guiObj);
  				ScrollToPosition(spos);
  				ChangeAttrPrefFco(guiObj);
  				Invalidate();
+ 				this->SendNow();
  			}
  		}
***************
*** 3320,3323 ****
--- 3460,3464 ----
  			FillModelGrid();
  			AutoRoute(); // HACK we may have size change here, reroute the whole thing for now
+ 			this->SendUnselEvent4List( &selected);
  			selected.RemoveAll();
  			selectedAnnotations.RemoveAll();
***************
*** 3470,3473 ****
--- 3611,3615 ----
  		FillModelGrid();
  		AutoRoute(); // HACK we may have size change here, reroute the whole thing for now
+ 		this->SendUnselEvent4List( &selected);
  		selected.RemoveAll();
  		selectedAnnotations.RemoveAll();
***************
*** 3496,3499 ****
--- 3638,3642 ----
  	FillModelGrid();
  	AutoRoute(); // HACK we may have size change here, reroute the whole thing for now
+ 	this->SendUnselEvent4List( &selected);
  	selected.RemoveAll();
  	selectedAnnotations.RemoveAll();
***************
*** 3538,3546 ****
--- 3681,3695 ----
  						alreadySelected = selected.Find(selection);
  						if(alreadySelected)
+ 						{
+ 							this->SendUnselEvent4Object( selected.GetAt( alreadySelected));
  							selected.RemoveAt(alreadySelected);
+ 						}
  						else if(!(nFlags & MK_CONTROL)) {
  							selectedAnnotations.RemoveAll();
+ 							this->SendUnselEvent4List( &selected);
  							selected.RemoveAll();
  						}
+ 
+ 						this->SendSelecEvent4Object( selection);
  						selected.AddHead(selection);
  					}
***************
*** 3551,3554 ****
--- 3700,3704 ----
  							selectedAnnotations.RemoveAt(alreadySelected);
  						else if(!(nFlags & MK_CONTROL)) {
+ 							this->SendUnselEvent4List( &selected);
  							selected.RemoveAll();
  							selectedAnnotations.RemoveAll();
***************
*** 3586,3589 ****
--- 3736,3740 ----
  							if (selection) {
  								if(alreadySelected) {
+ 									this->SendUnselEvent4Object( selected.GetHead());
  									selected.RemoveHead();
  									selection = selected.GetCount() ? selected.GetHead() : 0;
***************
*** 3607,3614 ****
--- 3758,3767 ----
  						}
  						else {
+ 							this->SendUnselEvent4List( &selected);
  							selected.RemoveAll();
  							selectedAnnotations.RemoveAll();
  							if (selection) {
  								if(!alreadySelected) {
+ 									this->SendSelecEvent4Object( selection);
  									selected.AddHead(selection);
  									ChangeAttrPrefObjs(selected);
***************
*** 3653,3656 ****
--- 3806,3810 ----
  				}
  				else {
+ 					this->SendUnselEvent4List( &selected);
  					selected.RemoveAll();
  					selectedAnnotations.RemoveAll();
***************
*** 3669,3672 ****
--- 3823,3827 ----
  							dc.DPtoLP(tracker.m_rect);
  							FindObjects(tracker.m_rect,selected);
+ 							this->SendSelecEvent4List( &selected);
  							FindAnnotations(tracker.m_rect,selectedAnnotations);
  							if(selected.GetCount() > 0) {
***************
*** 3842,3845 ****
--- 3997,4001 ----
  	dragSource = 0;
  	CScrollZoomView::OnLButtonDown(nFlags, point);
+ 	this->SendNow();
  }
  
***************
*** 4043,4052 ****
--- 4199,4211 ----
  					alreadySelected = selected.Find(selection);
  					if(!(nFlags & MK_CONTROL)) {
+ 						this->SendUnselEvent4List( &selected);
  						selected.RemoveAll();
  						selectedAnnotations.RemoveAll();
  					}
  					else if(alreadySelected) {
+ 						this->SendUnselEvent4Object( selected.GetAt( alreadySelected));
  						selected.RemoveAt(alreadySelected);
  					}
+ 					this->SendSelecEvent4Object( selection);
  					selected.AddHead(selection);
  					ChangeAttrPrefObjs(selected);
***************
*** 4056,4059 ****
--- 4215,4219 ----
  						alreadySelected = selectedAnnotations.Find(annotation);
  						if(!(nFlags & MK_CONTROL)) {
+ 							this->SendUnselEvent4List( &selected);
  							selected.RemoveAll();
  							selectedAnnotations.RemoveAll();
***************
*** 4126,4129 ****
--- 4286,4290 ----
  	}
  	CScrollZoomView::OnRButtonDown(nFlags, point);
+ 	this->SendNow();
  }
  
***************
*** 4475,4479 ****
  
  	GMEEVENTLOG_GUIOBJS(selected);
! 	DeleteObjects(selected);
  	selected.RemoveAll();
  }
--- 4636,4641 ----
  
  	GMEEVENTLOG_GUIOBJS(selected);
! 	this->SendUnselEvent4List( &selected);
! 	DeleteObjects( selected);
  	selected.RemoveAll();
  }
***************
*** 5794,5797 ****
--- 5956,5960 ----
  {
  	CGMEEventLogger::LogGMEEvent("CGMEView::OnEditSelectall in "+path+name+"\r\n");
+ 	this->SendUnselEvent4List( &selected);
  	selected.RemoveAll();
  	selectedAnnotations.RemoveAll();
***************
*** 5800,5803 ****
--- 5963,5967 ----
  		CGuiObject *obj = dynamic_cast<CGuiObject *>(children.GetNext(pos));
  		if(obj && obj->IsVisible())
+ 			this->SendSelecEvent4Object( obj);
  			selected.AddTail(obj);
  	}
***************
*** 5815,5818 ****
--- 5979,5983 ----
  	GMEEVENTLOG_GUIANNOTATORS(selectedAnnotations);
  	Invalidate();
+ 	this->SendNow();
  }
  
***************
*** 6112,6115 ****
--- 6277,6295 ----
  void CGMEView::OnMouseMove(UINT nFlags, CPoint screenpoint)
  {
+ 	// send notification if requested by the user // introd by ZolMol on 2005/11
+ 	if( theApp.isMouseOverNotifyEnabled()/* && GetDocument()->GetEditMode() == GME_EDIT_MODE*/) {
+ 		CGMEView *self = const_cast<CGMEView *>(this);
+ 		CPoint point(screenpoint);
+ 		CoordinateTransfer(point);
+ 
+ 		static CGuiObject *lastObject = 0;
+ 		CGuiObject *object = self->FindObject(point);
+ 		if(object) {
+ 			if( object != lastObject)
+ 				this->SendMouseOver4Object( object);
+ 		}
+ 		lastObject = object;
+ 	}
+ 
  	if ((GetDocument()->GetEditMode() == GME_AUTOCONNECT_MODE) || (tmpConnectMode)) {
  		CGMEView *self = const_cast<CGMEView *>(this);

Index: GMEView.h
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/Gme/GMEView.h,v
retrieving revision 1.70
retrieving revision 1.71
diff -C2 -d -r1.70 -r1.71
*** GMEView.h	31 Aug 2005 19:38:41 -0000	1.70
--- GMEView.h	15 Nov 2005 20:06:54 -0000	1.71
***************
*** 16,19 ****
--- 16,20 ----
  #include "AspectSyncDlg.h"
  #include "ScrollZoomView.h"
+ #include <list>
  
  class CViewDriver;
***************
*** 154,157 ****
--- 155,166 ----
  	void CreateAnnotators();
  	bool SendCloseModelEvent();
+ 	bool SendSelecEvent4Object( CGuiObject* selection);
+ 	bool SendUnselEvent4Object( CGuiObject* selection);
+ 	bool SendSelecEvent4List( CGuiObjectList* pSelectedList);
+ 	bool SendUnselEvent4List( CGuiObjectList* pSelectedList);
+ 	bool SendMouseOver4Object( CGuiObject * object);
+ 	void SendNow();
+ 	std::list<CGuiObject*> m_lstSelect;
+ 	std::list<CGuiObject*> m_lstUnselect;
  	void Reset(bool doInvalidate = false);
  	void ResetPartBrowser();

Index: GMEApp.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/Gme/GMEApp.cpp,v
retrieving revision 1.134
retrieving revision 1.135
diff -C2 -d -r1.134 -r1.135
*** GMEApp.cpp	31 Aug 2005 19:38:41 -0000	1.134
--- GMEApp.cpp	15 Nov 2005 20:06:54 -0000	1.135
***************
*** 116,119 ****
--- 116,121 ----
  	labelAvoidance = false;
  	defZoomLev = "100";
+ 	mouseOverNotify = false;
+ 	realFmtStr = "%.12g";
  	// TODO: add construction code here,
  	set_terminate(EmergencyTerminate);
***************
*** 1254,1257 ****
--- 1256,1270 ----
  		if( bstr_zl)
  			CopyTo( bstr_zl, defZoomLev);
+ 
+ 		// SendMouseOver notification
+ 		VARIANT_BOOL send_mouse_over;
+ 		COMTHROW( registrar->GetMouseOverNotify(REGACCESS_USER, &send_mouse_over));
+ 		mouseOverNotify = ( send_mouse_over != VARIANT_FALSE);
+ 
+ 		// Real number format string
+ 		CComBSTR bstr_fmt;
+ 		COMTHROW( registrar->GetRealNmbFmtStr( REGACCESS_USER, &bstr_fmt));
+ 		if( bstr_fmt)
+ 			CopyTo( bstr_fmt, realFmtStr);
  	}
  	MSGCATCH("Error while trying to get program settings",;);



More information about the GME-commit mailing list