[GME-commit] GMESRC/GME/Gme GMEView.cpp,1.155,1.156 ModelGrid.cpp,1.5,1.6 ModelGrid.h,1.4,1.5

gme-commit at list.isis.vanderbilt.edu gme-commit at list.isis.vanderbilt.edu
Wed Oct 13 18:03:27 CDT 2004


Update of /var/lib/gme/GMESRC/GME/Gme
In directory braindrain:/tmp/cvs-serv22424

Modified Files:
	GMEView.cpp ModelGrid.cpp ModelGrid.h 
Log Message:
Asp synch bug corrected. 
It failed if the objects (whose position is to be synchronized) are not shown by all aspects of their parents.


CVS User: zolmol

Index: GMEView.cpp
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/Gme/GMEView.cpp,v
retrieving revision 1.155
retrieving revision 1.156
diff -C2 -d -r1.155 -r1.156
*** GMEView.cpp	27 Sep 2004 22:01:39 -0000	1.155
--- GMEView.cpp	13 Oct 2004 22:03:24 -0000	1.156
***************
*** 5556,5563 ****
  void CGMEView::SyncOnGrid(CGuiObject *obj, int aspectIndexFrom, int aspectIndexTo)
  {
! 	CPoint center = obj->GetLocation(aspectIndexFrom).CenterPoint();
  
! 	if (!modelGrid.IsAvailable(obj, aspectIndexFrom)) {
! 		if (!modelGrid.GetClosestAvailable(obj, center)) {
  			AfxMessageBox("Too Many Models! Internal Program Error!",MB_OK | MB_ICONSTOP);
  			throw hresult_exception();
--- 5556,5564 ----
  void CGMEView::SyncOnGrid(CGuiObject *obj, int aspectIndexFrom, int aspectIndexTo)
  {
! 	// aspectIndexTo might be equal with aspectIndexFrom
! 	CPoint center = obj->GetLocation(aspectIndexFrom).CenterPoint();//take the pos from the aspFrom (source) aspect
  
! 	if (!modelGrid.IsAvailable(obj, aspectIndexFrom)) {//is enough space to occupy the pos taken from the aspFrom aspect?
! 		if (!modelGrid.GetClosestAvailable(obj, center, aspectIndexTo)) { // if cannot get any position close to the position got above
  			AfxMessageBox("Too Many Models! Internal Program Error!",MB_OK | MB_ICONSTOP);
  			throw hresult_exception();
***************
*** 5565,5569 ****
  	}
  	obj->SetCenter(center, aspectIndexTo);
! 	modelGrid.Set(obj);
  }
  
--- 5566,5570 ----
  	}
  	obj->SetCenter(center, aspectIndexTo);
! 	modelGrid.Set(obj, FALSE, aspectIndexTo);
  }
  

Index: ModelGrid.cpp
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/Gme/ModelGrid.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** ModelGrid.cpp	25 Aug 2004 20:36:31 -0000	1.5
--- ModelGrid.cpp	13 Oct 2004 22:03:24 -0000	1.6
***************
*** 186,192 ****
  // Public methods - accepts objects as parameters
  
! void CModelGrid::Set(CGuiObject *model,bool reset)
  {
! 	CRect loc = model->GetLocation();
  	CPoint pt = loc.CenterPoint();
  	CSize s = loc.Size();
--- 186,198 ----
  // Public methods - accepts objects as parameters
  
! /*
! Mod by ZolMol:  If called from CGMEView::SyncOnGrid then
! 				the object (*model) might not have the same aspects as its parent so
! 				calling GetLocation or GetNameLocation with default parameter might
! 				cause null ptr dereferencing
! */
! void CModelGrid::Set(CGuiObject *model,bool reset, int aspIdx)
  {
! 	CRect loc = model->GetLocation( aspIdx);
  	CPoint pt = loc.CenterPoint();
  	CSize s = loc.Size();
***************
*** 194,198 ****
  
  	if (theApp.labelAvoidance) {
! 		loc = model->GetNameLocation();
  		pt = loc.CenterPoint();
  		s = loc.Size();
--- 200,204 ----
  
  	if (theApp.labelAvoidance) {
! 		loc = model->GetNameLocation( aspIdx);
  		pt = loc.CenterPoint();
  		s = loc.Size();
***************
*** 219,228 ****
  }
  
! bool CModelGrid::GetClosestAvailable(CGuiObject *model,CPoint &pt)
  {
  	CRect unionLoc;
! 	CRect loc = model->GetLocation();
  	if (theApp.labelAvoidance) {
! 		CRect nameLoc = model->GetNameLocation();
  		unionLoc.UnionRect(&loc, &nameLoc);
  	}
--- 225,240 ----
  }
  
! /*
! Mod by ZolMol:  If called from CGMEView::SyncOnGrid then
! 				the object (*model) might not have the same aspects as its parent so
! 				calling GetLocation or GetNameLocation with default parameter might
! 				cause null ptr dereferencing
! */
! bool CModelGrid::GetClosestAvailable(CGuiObject *model,CPoint &pt, int aspIdx)
  {
  	CRect unionLoc;
! 	CRect loc = model->GetLocation( aspIdx);
  	if (theApp.labelAvoidance) {
! 		CRect nameLoc = model->GetNameLocation( aspIdx);
  		unionLoc.UnionRect(&loc, &nameLoc);
  	}
***************
*** 248,252 ****
  {
  	ASSERT(right == 0 || down == 0); // no diagonal nudge!
! 	CRect r = model->GetLocation();
  	right *= GME_GRID_SIZE;
  	down *= GME_GRID_SIZE;
--- 260,264 ----
  {
  	ASSERT(right == 0 || down == 0); // no diagonal nudge!
! 	CRect r = model->GetLocation(); // comment by ZolMol: this is correct since the parent aspect is always valid, and an object is moved (nudged) within the parents aspect only
  	right *= GME_GRID_SIZE;
  	down *= GME_GRID_SIZE;

Index: ModelGrid.h
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/Gme/ModelGrid.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** ModelGrid.h	19 Jul 2004 17:19:29 -0000	1.4
--- ModelGrid.h	13 Oct 2004 22:03:24 -0000	1.5
***************
*** 20,28 ****
  	void Clear();
  	
! 	void Set(CGuiObject *model,bool reset = FALSE);
  	void Reset(CGuiObject *model);
  
  	bool IsAvailable(CGuiObject *model, int aspIdx = -1);
! 	bool GetClosestAvailable(CGuiObject *model,CPoint &pt);
  	
  	bool CanNudge(CGuiObject *model,int right,int down);	
--- 20,28 ----
  	void Clear();
  	
! 	void Set(CGuiObject *model,bool reset = FALSE, int aspIdx = -1);//last param introd by zolmol
  	void Reset(CGuiObject *model);
  
  	bool IsAvailable(CGuiObject *model, int aspIdx = -1);
! 	bool GetClosestAvailable(CGuiObject *model,CPoint &pt, int aspIdx = -1);//last param introd by zolmol
  	
  	bool CanNudge(CGuiObject *model,int right,int down);	



More information about the GME-commit mailing list