[GME-commit] GMESRC/GME/Gme GMEApp.cpp,1.133,1.134 GMEDoc.cpp,1.29,1.30 GMEDoc.h,1.12,1.13 GMEStd.h,1.24,1.25 GMEView.cpp,1.172,1.173 GMEView.h,1.69,1.70 GUIObject.cpp,1.52,1.53 GraphicsUtil.cpp,1.13,1.14 GraphicsUtil.h,1.6,1.7

gme-commit at list.isis.vanderbilt.edu gme-commit at list.isis.vanderbilt.edu
Wed Aug 31 20:38:43 CDT 2005


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

Modified Files:
	GMEApp.cpp GMEDoc.cpp GMEDoc.h GMEStd.h GMEView.cpp GMEView.h 
	GUIObject.cpp GraphicsUtil.cpp GraphicsUtil.h 
Log Message:
Modifications for smart copy (right click on connection is possible).

DetachFromArcheType choice when deleting archetypes.

New connection end style (GME_BOND_END) introduced.


CVS User: Zoltan Molnar, ISIS (zolmol)

Index: GraphicsUtil.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/Gme/GraphicsUtil.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** GraphicsUtil.cpp	11 May 2004 19:47:50 -0000	1.13
--- GraphicsUtil.cpp	31 Aug 2005 19:38:41 -0000	1.14
***************
*** 11,14 ****
--- 11,16 ----
  static int arrowXCoords[] = {-5, -7, -1, -7};
  static int arrowYCoords[] = {0, -3, 0, 3};
+ static int bondXCoords[] = {-1, -10};
+ static int bondYCoords[] = {0, -5};
  static int diamondXCoords[] = {-11, -6, -1, -6};
  static int diamondYCoords[] = {0, -3, 0, 3};
***************
*** 125,128 ****
--- 127,131 ----
  	for(int i = 0; i < GME_DIRECTION_NUM; i++) {
  		arrows[i] = new CArrowHead( i, arrowXCoords, arrowYCoords, 4 );
+ 		bonds[i] = new CArrowHead( i, bondXCoords, bondYCoords, 2 );
  		diamonds[i] = new CArrowHead( i, diamondXCoords, diamondYCoords, 4 );
  		apexes[i] = new CArrowHead( i, apexXCoords, apexYCoords, 3 );
***************
*** 145,148 ****
--- 148,152 ----
  	for(int i = 0; i < GME_DIRECTION_NUM; i++) {
  		delete arrows[i];
+ 		delete bonds[i];
  		delete diamonds[i];
  		delete apexes[i];
***************
*** 311,314 ****
--- 315,321 ----
  		case GME_ARROW_END :
  			arrows[ dir ]->Draw( pDC, last, false );
+ 			break;
+ 		case GME_BOND_END :
+ 			bonds[ dir ]->Draw( pDC, last, true );
  			break;
  		case GME_DIAMOND_END :

Index: GMEView.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/Gme/GMEView.cpp,v
retrieving revision 1.172
retrieving revision 1.173
diff -C2 -d -r1.172 -r1.173
*** GMEView.cpp	19 Jul 2005 17:47:01 -0000	1.172
--- GMEView.cpp	31 Aug 2005 19:38:41 -0000	1.173
***************
*** 2391,2394 ****
--- 2391,2395 ----
  void CGMEView::DeleteObjects(CGuiObjectList &objectList)
  {
+ 	bool brw_refresh_needed = false;
  	try {
  		CGMEEventLogger::LogGMEEvent("CGMEView::DeleteObjects in "+path+name+"\r\n");
***************
*** 2432,2435 ****
--- 2433,2438 ----
  			// making sure that the fco was not deleted previously in the loop due to a dependency 
  			if(oStatus == OBJECT_EXISTS) {
+ 				// throws E_MGA_MUST_ABORT if user selects CANCEL
+ 				brw_refresh_needed = askUserAndDetachIfNeeded( obj->mgaFco); // detach the dependents if needed
  				COMTHROW(obj->mgaFco->DestroyObject());
  				COMTHROW(obj->mgaFco->Close());
***************
*** 2440,2445 ****
  	catch(hresult_exception &e) {
  		AbortTransaction(e.hr);
! 		AfxMessageBox("Unable to delete models",MB_ICONSTOP | MB_OK);
! 		CGMEEventLogger::LogGMEEvent("    Unable to delete models.\r\n");
  		EndWaitCursor();
  		return;
--- 2443,2453 ----
  	catch(hresult_exception &e) {
  		AbortTransaction(e.hr);
! 		if( e.hr == E_MGA_MUST_ABORT)
! 			CGMEEventLogger::LogGMEEvent("    Archetype delete cancelled by user.\r\n");
! 		else
! 		{
! 			AfxMessageBox("Unable to delete models",MB_ICONSTOP | MB_OK);
! 			CGMEEventLogger::LogGMEEvent("    Unable to delete models.\r\n");
! 		}
  		EndWaitCursor();
  		return;
***************
*** 2447,2450 ****
--- 2455,2459 ----
  	EndWaitCursor();
  	ResetParent();
+ 	if( brw_refresh_needed) CGMEBrowser::theInstance->RefreshAll();
  }
  
***************
*** 2529,2532 ****
--- 2538,2568 ----
  }
  
+ void CGMEView::MakeSureGUIDIsUniqueForSmartCopy( CComPtr<IMgaFCO>& fco)
+ {
+ 	// this method prevents cloned objects having the same guid
+ 	// as their original ones
+ 	CComBSTR bstr;
+ 	COMTHROW( fco->get_RegistryValue( CComBSTR( "guid"), &bstr));
+ 	if( bstr == 0 || bstr == "") return; // no guid present, no need to replace it
+ 
+ 	GUID t_guid = GUID_NULL;
+ 	::CoCreateGuid(&t_guid);
+ 		
+ 	if (t_guid != GUID_NULL)
+ 	{
+ 		CString str_guid;
+ 		str_guid.Format("{%08lX-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X}",
+ 			t_guid.Data1, t_guid.Data2, t_guid.Data3,
+ 			t_guid.Data4[0], t_guid.Data4[1], t_guid.Data4[2], t_guid.Data4[3],
+ 			t_guid.Data4[4], t_guid.Data4[5], t_guid.Data4[6], t_guid.Data4[7]);
+ 		
+ 		// thus replace the old guid with a new one
+ 		COMTHROW( fco->put_RegistryValue( CComBSTR( "guid"), CComBSTR(str_guid)));
+ 	}
+ 
+ 	// store the previous guid in prev subnode
+ 	COMTHROW( fco->put_RegistryValue( CComBSTR( "guid/prev"), bstr));
+ }
+ 
  bool CGMEView::DoPasteNative(COleDataObject *pDataObject,bool drag,bool move,bool reference,bool derive,bool instance,CGuiObject *ref,CPoint point)
  {
***************
*** 2607,2610 ****
--- 2643,2655 ----
  						COMTHROW(currentModel->CopyFCOs(fcos,newRoles,&newFcos));
  					}
+ 
+ 					if(!reference && !derive) // smart copy subtask:
+ 					{
+ 						MGACOLL_ITERATE(IMgaFCO, newFcos) {
+ 							MakeSureGUIDIsUniqueForSmartCopy( CComPtr<IMgaFCO>(MGACOLL_ITER));
+ 						}
+ 						MGACOLL_ITERATE_END;
+ 					}
+ 
  					MGACOLL_ITERATE(IMgaFCO, newFcos) {
  						CComPtr<IMgaFCO> newFco;
***************
*** 4629,4633 ****
  		CGuiAnnotator::GetRectList(selectedAnnotations,annRects);
  		CGMEDataDescriptor desc(rects,annRects,pt,pt);
! 		GetDocument()->CopySmartToClipboard( &selected, &selectedAnnotations, &desc, this);
  	}
  }
--- 4674,4683 ----
  		CGuiAnnotator::GetRectList(selectedAnnotations,annRects);
  		CGMEDataDescriptor desc(rects,annRects,pt,pt);
! 
! 		CGuiFcoList fcoList;// copy selected->selectedFco
! 		POSITION pos = selected.GetHeadPosition();
! 		while( pos != NULL ) fcoList.AddTail( selected.GetNext( pos ));
! 
! 		GetDocument()->CopySmartToClipboard( &fcoList, &selectedAnnotations, &desc, this);
  	}
  }
***************
*** 4780,4784 ****
  			CRectList dummyAnnList;
  			CGMEDataDescriptor desc(rects,dummyAnnList,pt,pt);
! 			GetDocument()->CopySmartToClipboard( &list, &dummyList, &desc, this);
  		}
  		contextSelection = 0;
--- 4830,4855 ----
  			CRectList dummyAnnList;
  			CGMEDataDescriptor desc(rects,dummyAnnList,pt,pt);
! 
! 			CGuiFcoList fcoList;
! 			POSITION pos = list.GetHeadPosition();// copy list->fcoList
! 			while( pos != NULL ) fcoList.AddTail( list.GetNext( pos ));
! 
! 			GetDocument()->CopySmartToClipboard( &fcoList, &dummyList, &desc, this);
! 		}
! 		else 
! 		{
! 			CGuiConnection *guiConn = dynamic_cast<CGuiConnection *>(contextSelection);
! 			if( guiConn) // a valid connection
! 			{
! 				CGMEEventLogger::LogGMEEvent("    "+guiConn->GetName()+" "+guiConn->GetID()+"\r\n");
! 				CGuiFcoList list;
! 				CGuiAnnotatorList dummyList;
! 				list.AddTail(guiConn);
! 				CPoint pt = CPoint(0,0);
! 				CRectList dummyRects;
! 				CRectList dummyAnnList;
! 				CGMEDataDescriptor desc(dummyRects,dummyAnnList,pt,pt);
! 				GetDocument()->CopySmartToClipboard( &list, &dummyList, &desc, this);
! 			}
  		}
  		contextSelection = 0;
***************
*** 4786,4790 ****
  	else if (contextAnnotation) {
  		CGMEEventLogger::LogGMEEvent("    "+contextAnnotation->GetName()+"/r/n");
! 		CGuiObjectList dummyList;
  		CGuiAnnotatorList list;
  		list.AddTail(contextAnnotation);
--- 4857,4861 ----
  	else if (contextAnnotation) {
  		CGMEEventLogger::LogGMEEvent("    "+contextAnnotation->GetName()+"/r/n");
! 		CGuiFcoList dummyList;
  		CGuiAnnotatorList list;
  		list.AddTail(contextAnnotation);
***************
*** 6760,6762 ****
--- 6831,6879 ----
  	*p_valRet = val;
  	return true;
+ }
+ 
+ bool CGMEView::askUserAndDetachIfNeeded( CComPtr<IMgaFCO>& mgaFco)
+ {
+ 	// check whether dependends of mgaFco exist
+ 	CComPtr<IMgaFCOs> der_objs;
+ 	COMTHROW(mgaFco->get_DerivedObjects( &der_objs));
+ 	long cnt = 0;
+ 	if( der_objs) COMTHROW( der_objs->get_Count( &cnt));
+ 	if( cnt > 0) // if dependents exist should they be deleted?
+ 	{
+ 		bool question_asked = false;
+ 		bool detach_answered = false;
+ 		MGACOLL_ITERATE(IMgaFCO, der_objs) {
+ 			CComPtr<IMgaFCO> one_derived(MGACOLL_ITER);
+ 
+ 			VARIANT_BOOL prim_deriv;
+ 			COMTHROW( one_derived->get_IsPrimaryDerived( &prim_deriv));
+ 			if( prim_deriv == VARIANT_TRUE)
+ 			{
+ 				if( !question_asked) // pop up dialog only for the first time
+ 				{
+ 					CComBSTR nm;
+ 					COMTHROW( mgaFco->get_Name( &nm));
+ 					CString msg = "There are objects primary derived from: \"";
+ 					msg += nm;
+ 					msg += "\". Would you like to delete them as well?\n";
+ 					msg += "If you answer 'No' the derived objects will be detached, thus preserved.";
+ 
+ 					// this answer will be applied to all deriveds of this fco
+ 					int resp = AfxMessageBox( msg, MB_YESNOCANCEL);
+ 					if( resp == IDCANCEL) COMTHROW(E_MGA_MUST_ABORT);
+ 					else if( resp == IDNO) detach_answered = true;
+ 					
+ 					question_asked = true;
+ 				}
+ 
+ 				// if detach and preserve selected by the user:
+ 				if( detach_answered)
+ 					COMTHROW( one_derived->DetachFromArcheType());
+ 			}
+ 		}MGACOLL_ITERATE_END;
+ 
+ 		return detach_answered; // refresh needed for GMEActiveBrowser?
+ 	}
+ 	return false;
  }

Index: GMEView.h
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/Gme/GMEView.h,v
retrieving revision 1.69
retrieving revision 1.70
diff -C2 -d -r1.69 -r1.70
*** GMEView.h	19 Jul 2005 17:47:01 -0000	1.69
--- GMEView.h	31 Aug 2005 19:38:41 -0000	1.70
***************
*** 43,46 ****
--- 43,47 ----
  	void changeNamePosition( int w);
  	void updateNamePositionMenuItem( CCmdUI* pCmdUI, int this_val );
+ 	bool askUserAndDetachIfNeeded( CComPtr<IMgaFCO>& mgafco);
  
  public:
***************
*** 202,205 ****
--- 203,207 ----
  	bool DoPasteItem(COleDataObject* pDataObject,bool drag = false,bool move = false,bool reference = false,bool derive = false,bool instance = false,bool closure = false,bool merge = false,CGuiObject *ref = 0,CPoint pt = CPoint(0,0));
  	bool DoPasteNative(COleDataObject *pDataObject,bool drag,bool move,bool reference,bool derive,bool instance,CGuiObject *ref,CPoint pt);
+ 	void MakeSureGUIDIsUniqueForSmartCopy( CComPtr<IMgaFCO>& fco);
  	void ChangeAspect(CString aspName);
  	void ChangeAspect(int ind);

Index: GMEDoc.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/Gme/GMEDoc.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** GMEDoc.cpp	19 Jul 2005 17:47:01 -0000	1.29
--- GMEDoc.cpp	31 Aug 2005 19:38:41 -0000	1.30
***************
*** 107,111 ****
  }
  
! bool CGMEDoc::CreateFcoList2(CGuiObjectList* list,CComPtr<IMgaFCOs> &fcos,CGMEView *view, long* p_howmany, bool* array[8])
  {
  	bool all_containers = *array[ 0 ];
--- 107,111 ----
  }
  
! bool CGMEDoc::CreateFcoList2(CGuiFcoList* list,CComPtr<IMgaFCOs> &fcos,CGMEView *view, long* p_howmany, bool* array[8])
  {
  	bool all_containers = *array[ 0 ];
***************
*** 321,325 ****
  }
  
! void CGMEDoc::CopySmartToClipboard( CGuiObjectList* list, CGuiAnnotatorList *annList, CGMEDataDescriptor* desc, CGMEView *view)
  {
  	int k = 0;
--- 321,325 ----
  }
  
! void CGMEDoc::CopySmartToClipboard( CGuiFcoList* list, CGuiAnnotatorList *annList, CGMEDataDescriptor* desc, CGMEView *view)
  {
  	int k = 0;

Index: GMEDoc.h
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/Gme/GMEDoc.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** GMEDoc.h	12 Jan 2005 17:53:16 -0000	1.12
--- GMEDoc.h	31 Aug 2005 19:38:41 -0000	1.13
***************
*** 46,53 ****
  
  	static bool CreateFcoList(CGuiObjectList* list,CComPtr<IMgaFCOs> &fcos,CGMEView *view);
! 	static bool CreateFcoList2(CGuiObjectList* list,CComPtr<IMgaFCOs> &fcos,CGMEView *view, long *howmany, bool* array[8]);
  	static bool CreateAnnotationList(CGuiAnnotatorList* list,CComPtr<IMgaRegNodes> &anns,CGMEView *view);
  	static void CopyClosureToClipboard(CGuiObjectList* list,CGuiAnnotatorList *annList,CGMEDataDescriptor* desc,CGMEView *view);
! 	static void CopySmartToClipboard(CGuiObjectList* list,CGuiAnnotatorList *annList,CGMEDataDescriptor* desc,CGMEView *view);
  	static void CopyToClipboard(CGuiObjectList* list,CGuiAnnotatorList *annList,CGMEDataDescriptor* desc,CGMEView *view);
  	static DROPEFFECT DoDragDrop(CGuiObjectList* list, CGuiAnnotatorList *annList, CGMEDataDescriptor* desc,
--- 46,53 ----
  
  	static bool CreateFcoList(CGuiObjectList* list,CComPtr<IMgaFCOs> &fcos,CGMEView *view);
! 	static bool CreateFcoList2(CGuiFcoList* list,CComPtr<IMgaFCOs> &fcos,CGMEView *view, long *howmany, bool* array[8]);
  	static bool CreateAnnotationList(CGuiAnnotatorList* list,CComPtr<IMgaRegNodes> &anns,CGMEView *view);
  	static void CopyClosureToClipboard(CGuiObjectList* list,CGuiAnnotatorList *annList,CGMEDataDescriptor* desc,CGMEView *view);
! 	static void CopySmartToClipboard(CGuiFcoList* list,CGuiAnnotatorList *annList,CGMEDataDescriptor* desc,CGMEView *view);
  	static void CopyToClipboard(CGuiObjectList* list,CGuiAnnotatorList *annList,CGMEDataDescriptor* desc,CGMEView *view);
  	static DROPEFFECT DoDragDrop(CGuiObjectList* list, CGuiAnnotatorList *annList, CGMEDataDescriptor* desc,

Index: GraphicsUtil.h
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/Gme/GraphicsUtil.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** GraphicsUtil.h	11 May 2004 19:47:49 -0000	1.6
--- GraphicsUtil.h	31 Aug 2005 19:38:41 -0000	1.7
***************
*** 30,33 ****
--- 30,34 ----
  	CFontList allFonts;													// for destruction only
  	CArrowHead *arrows[GME_DIRECTION_NUM];
+ 	CArrowHead *bonds[GME_DIRECTION_NUM];
  	CArrowHead *diamonds[GME_DIRECTION_NUM];
  	CArrowHead *apexes[GME_DIRECTION_NUM];

Index: GUIObject.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/Gme/GUIObject.cpp,v
retrieving revision 1.52
retrieving revision 1.53
diff -C2 -d -r1.52 -r1.53
*** GUIObject.cpp	7 Jul 2005 15:45:42 -0000	1.52
--- GUIObject.cpp	31 Aug 2005 19:38:41 -0000	1.53
***************
*** 2043,2046 ****
--- 2043,2048 ----
  		if ( pref == "arrow" )
  			srcStyle = GME_ARROW_END;
+ 		else if ( pref == "bond" )
+ 			srcStyle = GME_BOND_END;
  		else if ( pref == "diamond" )
  			srcStyle = GME_DIAMOND_END;
***************
*** 2063,2066 ****
--- 2065,2070 ----
  		if ( pref == "arrow" )
  			dstStyle = GME_ARROW_END;
+ 		else if ( pref == "bond" )
+ 			dstStyle = GME_BOND_END;
  		else if ( pref == "diamond" )
  			dstStyle = GME_DIAMOND_END;

Index: GMEStd.h
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/Gme/GMEStd.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** GMEStd.h	25 Mar 2004 16:44:33 -0000	1.24
--- GMEStd.h	31 Aug 2005 19:38:41 -0000	1.25
***************
*** 63,66 ****
--- 63,67 ----
  #define GME_EMPTYAPEX_END			6
  #define GME_EMPTYBULLET_END			7
+ #define GME_BOND_END                8
  
  

Index: GMEApp.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/Gme/GMEApp.cpp,v
retrieving revision 1.133
retrieving revision 1.134
diff -C2 -d -r1.133 -r1.134
*** GMEApp.cpp	10 Aug 2005 16:13:28 -0000	1.133
--- GMEApp.cpp	31 Aug 2005 19:38:41 -0000	1.134
***************
*** 1108,1112 ****
  
  					// PETER: Create new MgaProject COM object (workaround MGA addon bug)
! 					COMTHROW(mgaProject.Release());
  					COMTHROW( mgaProject.CoCreateInstance(OLESTR("Mga.MgaProject")) );
  					#pragma warning(disable: 4310) // cast truncates constant value
--- 1108,1112 ----
  
  					// PETER: Create new MgaProject COM object (workaround MGA addon bug)
! 					mgaProject.Release();
  					COMTHROW( mgaProject.CoCreateInstance(OLESTR("Mga.MgaProject")) );
  					#pragma warning(disable: 4310) // cast truncates constant value



More information about the GME-commit mailing list