[Uml-devel] CVS: kdesdk/umbrello/umbrello associationwidget.cpp,1.3,1.4 floatingtext.cpp,1.4,1.5 objectwidget.cpp,1.6,1.7 seqlinewidget.cpp,1.2,1.3 umlview.cpp,1.11,1.12 umlview.h,1.6,1.7 umlwidget.cpp,1.6,1.7

kde at office.kde.org kde at office.kde.org
Sun Feb 2 13:00:58 UTC 2003


Update of /home/kde/kdesdk/umbrello/umbrello
In directory office:/tmp/cvs-serv30377

Modified Files:
	associationwidget.cpp floatingtext.cpp objectwidget.cpp 
	seqlinewidget.cpp umlview.cpp umlview.h umlwidget.cpp 
Log Message:
Canvas is now resized dynamically when widgets are dragged to or away from it's edge.
Replaced canvas size boxes in Diagram Properties dialogue with zoom.


Index: associationwidget.cpp
===================================================================
RCS file: /home/kde/kdesdk/umbrello/umbrello/associationwidget.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- associationwidget.cpp	25 Jan 2003 19:00:40 -0000	1.3
+++ associationwidget.cpp	2 Feb 2003 20:51:06 -0000	1.4
@@ -21,11 +21,11 @@
 #include <klineeditdlg.h>
 #include <klocale.h>
 
-AssociationWidget::AssociationWidget(QWidget *parent, AssociationWidgetData * pData) 
-	: QObject(parent),m_pMultiA(0), m_pMultiB(0), m_pRole(0), m_pWidgetA(0), m_pWidgetB(0), 
-	  m_nCornerARegion(-1), m_nCornerBRegion(-1), 
-	  m_pView((UMLView *)parent), m_pData(pData),m_WidgetARegion(Error), m_WidgetBRegion(Error), m_bActivated(false), 
-	  m_unRoleLineSegment(0), m_pMenu(0), m_bSelected(false), m_nMovingPoint(-1) 
+AssociationWidget::AssociationWidget(QWidget *parent, AssociationWidgetData * pData)
+	: QObject(parent),m_pMultiA(0), m_pMultiB(0), m_pRole(0), m_pWidgetA(0), m_pWidgetB(0),
+	  m_nCornerARegion(-1), m_nCornerBRegion(-1),
+	  m_pView((UMLView *)parent), m_pData(pData),m_WidgetARegion(Error), m_WidgetBRegion(Error), m_bActivated(false),
+	  m_unRoleLineSegment(0), m_pMenu(0), m_bSelected(false), m_nMovingPoint(-1)
 {
 	if (!m_pData)
 	{
@@ -38,11 +38,11 @@
 }
 
 AssociationWidget::AssociationWidget(QWidget *parent, UMLWidget* WidgetA,
-                                       Association_Type Type, UMLWidget* WidgetB)  
-	: QObject(parent), m_pMultiA(0), m_pMultiB(0), m_pRole(0), m_pWidgetA(WidgetA), m_pWidgetB(WidgetB), 
-	  m_nCornerARegion(-1), m_nCornerBRegion(-1), 
-	  m_pView((UMLView *)parent), m_WidgetARegion(Error), m_WidgetBRegion(Error), m_bActivated(false), 
-	  m_unRoleLineSegment(0), m_pMenu(0), m_bSelected(false), m_nMovingPoint(-1) 
+                                       Association_Type Type, UMLWidget* WidgetB)
+	: QObject(parent), m_pMultiA(0), m_pMultiB(0), m_pRole(0), m_pWidgetA(WidgetA), m_pWidgetB(WidgetB),
+	  m_nCornerARegion(-1), m_nCornerBRegion(-1),
+	  m_pView((UMLView *)parent), m_WidgetARegion(Error), m_WidgetBRegion(Error), m_bActivated(false),
+	  m_unRoleLineSegment(0), m_pMenu(0), m_bSelected(false), m_nMovingPoint(-1)
 {
 	m_pData = new AssociationWidgetData();
 	m_pData -> m_LinePath.setAssociation( this );
@@ -1900,6 +1900,7 @@
 	//move event called now
 	QMoveEvent m(p, oldp);
 	moveEvent(&m);
+	m_pView->resizeCanvasToItems();
 }
 AssociationWidget::Region AssociationWidget::getWidgetRegion(AssociationWidget * widget) {
 	if(widget  -> getWidgetA()== m_pWidgetA)
@@ -2167,7 +2168,7 @@
 			} else if( m_pWidgetA == assocwidget -> getWidgetB() ) {
 					assocwidget -> updateRegionLineCount(index++, totalCount, region, false);
 			}
-		} else { //end widgetA 
+		} else { //end widgetA
 			if(m_pWidgetB == assocwidget -> getWidgetA() )
 			{
 					assocwidget -> updateRegionLineCount(index++, totalCount, region, true);

Index: floatingtext.cpp
===================================================================
RCS file: /home/kde/kdesdk/umbrello/umbrello/floatingtext.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- floatingtext.cpp	2 Feb 2003 17:29:11 -0000	1.4
+++ floatingtext.cpp	2 Feb 2003 20:51:06 -0000	1.5
@@ -327,6 +327,7 @@
 		if(m_pAssoc) {
 			m_pAssoc->calculateRoleTextSegment();
 		}
+		m_pView->resizeCanvasToItems();
 		moveEvent(0);
 	}
 }

Index: objectwidget.cpp
===================================================================
RCS file: /home/kde/kdesdk/umbrello/umbrello/objectwidget.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- objectwidget.cpp	2 Feb 2003 17:29:11 -0000	1.6
+++ objectwidget.cpp	2 Feb 2003 20:51:07 -0000	1.7
@@ -264,6 +264,7 @@
 		setX( newX );
 		setY( newY );
 		adjustAssocs(newX, newY);
+		m_pView->resizeCanvasToItems();
 		moveEvent(0);
 	}
 }

Index: seqlinewidget.cpp
===================================================================
RCS file: /home/kde/kdesdk/umbrello/umbrello/seqlinewidget.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- seqlinewidget.cpp	2 Feb 2003 01:06:46 -0000	1.2
+++ seqlinewidget.cpp	2 Feb 2003 20:51:07 -0000	1.3
@@ -77,14 +77,10 @@
 			newY = m_nMinY;
 		}
 
-		int maxY = m_pView->canvas()->height();
-		if (newY > maxY - 10) {
-			newY = maxY - 10;
-		}
-
 		setPoints( sp.x(), sp.y(), sp.x(), newY );
 		m_nLengthY = newY - (int)m_pObject->y() - m_pObject->height();
 		moveDeconBox();
+		m_pView->resizeCanvasToItems();
 	}
 }
 

Index: umlview.cpp
===================================================================
RCS file: /home/kde/kdesdk/umbrello/umbrello/umlview.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- umlview.cpp	2 Feb 2003 01:52:07 -0000	1.11
+++ umlview.cpp	2 Feb 2003 20:51:07 -0000	1.12
@@ -105,7 +105,6 @@
 	connect( this, SIGNAL(sigRemovePopupMenu()), this, SLOT(slotRemovePopupMenu() ) );
 	connect( (UMLApp *)getDocument() -> parent() , SIGNAL( sigCutSuccessful() ),
 	         this, SLOT( slotCutSuccessful() ) );
-
 }
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -239,6 +238,7 @@
 		temp->setActivated();
 		temp->setFont( m_pData -> getFont() );
 		temp->slotColorChanged( m_pData->getID() );
+		resizeCanvasToItems();
 		return;
 	}
 	//create end activity
@@ -251,6 +251,7 @@
 		temp->setActivated();
 		temp -> setFont( m_pData -> getFont() );
 		temp->slotColorChanged( m_pData->getID() );
+		resizeCanvasToItems();
 		return;
 	}
 	//create branch/merge activity
@@ -263,6 +264,7 @@
 		temp->setActivated();
 		temp -> setFont( m_pData -> getFont() );
 		temp->slotColorChanged( m_pData->getID() );
+		resizeCanvasToItems();
 		return;
 	}
 	//create fork/join activity
@@ -275,6 +277,7 @@
 		temp->setActivated();
 		temp -> setFont( m_pData -> getFont() );
 		temp->slotColorChanged( m_pData->getID() );
+		resizeCanvasToItems();
 		return;
 	}
 	//create a activity widget
@@ -294,6 +297,7 @@
 			temp->setFont( m_pData -> getFont() );
 			temp->slotColorChanged( m_pData->getID() );
 		}
+		resizeCanvasToItems();
 		return;
 	}
 	//create a state widget
@@ -311,6 +315,7 @@
 			temp -> setFont( m_pData -> getFont() );
 			temp->slotColorChanged( m_pData->getID() );
 		}
+		resizeCanvasToItems();
 		return;
 	}
 	//create an initial state widget
@@ -323,6 +328,7 @@
 		temp->setActivated();
 		temp -> setFont( m_pData -> getFont() );
 		temp->slotColorChanged( m_pData->getID() );
+		resizeCanvasToItems();
 		return;
 	}
 	//create end state
@@ -335,6 +341,7 @@
 		temp->setActivated();
 		temp -> setFont( m_pData -> getFont() );
 		temp->slotColorChanged( m_pData->getID() );
+		resizeCanvasToItems();
 		return;
 	}
 	//Create a NoteBox widget
@@ -348,6 +355,7 @@
 		temp->setActivated();
 		temp -> setFont( m_pData -> getFont() );
 		temp->slotColorChanged( m_pData->getID() );
+		resizeCanvasToItems();
 		return;
 	}
 	//Create a Floating Text widget
@@ -366,6 +374,7 @@
 			ft -> setFont( m_pData -> getFont() );
 			ft->slotColorChanged( m_pData->getID() );
 		}
+		resizeCanvasToItems();
 		return;
 	}
 	//Create a Message on a Sequence diagram
@@ -392,6 +401,7 @@
 				messageText->setActivated();
 				message->setActivated();
 				m_pFirstSelectedWidget = 0;
+				resizeCanvasToItems();
 				return;
 			}
 		} else { //did not click on widget line, clear the half made message
@@ -409,6 +419,7 @@
 	}
 	m_bCreateObject = true;
 	getDocument()->createUMLObject(convert_TBB_OT(m_CurrentCursor));
+	resizeCanvasToItems();
 }
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 void UMLView::slotToolBarChanged(int c) {
@@ -2729,15 +2740,13 @@
 void UMLView::zoomIn() {
 	QWMatrix wm = worldMatrix();
 	wm.scale(1.5,1.5); // adjust zooming step here
-	setWorldMatrix(wm);
-	m_pData->setZoom( currentZoom() );
+	setZoom( (int)(wm.m11()*100.0) );
 }
 
 void UMLView::zoomOut() {
 	QWMatrix wm = worldMatrix();
 	wm.scale(2.0/3.0, 2.0/3.0); //adjust zooming step here
-	setWorldMatrix(wm);
-	m_pData->setZoom( currentZoom() );
+	setZoom( (int)(wm.m11()*100.0) );
 }
 
 void UMLView::fileLoaded() {
@@ -2749,6 +2758,22 @@
 	m_pData->setCanvasWidth(width);
 	m_pData->setCanvasHeight(height);
 	canvas()->resize(width, height);
+}
+
+void UMLView::resizeCanvasToItems() {
+	QRect canvasSize = getDiagramRect();
+	int canvasWidth = canvasSize.right() + 5;
+	int canvasHeight = canvasSize.bottom() + 5;
+
+	if ( canvasWidth < width() ) {
+		canvasWidth = width();
+	}
+
+	if ( canvasHeight < height() ) {
+		canvasHeight = height();
+	}
+
+	setCanvasSize(canvasWidth, canvasHeight);
 }
 
 #include "umlview.moc"

Index: umlview.h
===================================================================
RCS file: /home/kde/kdesdk/umbrello/umbrello/umlview.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- umlview.h	1 Feb 2003 22:39:06 -0000	1.6
+++ umlview.h	2 Feb 2003 20:51:07 -0000	1.7
@@ -681,6 +681,11 @@
 	 */
 	void setCanvasSize(int width, int height);
 
+	/**
+	 * Sets the size of the canvas to just fit on all the items
+	 */
+	void resizeCanvasToItems();
+
 	/**                                                                                
 	 *      the width and height of a diagram canvas in pixels                         
 	 */	

Index: umlwidget.cpp
===================================================================
RCS file: /home/kde/kdesdk/umbrello/umbrello/umlwidget.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- umlwidget.cpp	2 Feb 2003 17:29:11 -0000	1.6
+++ umlwidget.cpp	2 Feb 2003 20:51:07 -0000	1.7
@@ -87,12 +87,6 @@
 		if( ((int)y() + moveY) < 0 ) {
 			moveY = moveY - (int)y();
 		}
-		if( ((int)x() + moveX) > (maxX - width()) ) {
-			moveX = maxX - (int)x() - width();
-		}
-		if( ((int)y() + moveY) > (maxY - height()) ) {
-			moveY = maxY - (int)y() - height();
-		}
 
 		if( count > 1 ) {
 			if( m_pView -> getType() == dt_Sequence ) {
@@ -127,6 +121,7 @@
 		setX( newX );
 		setY( newY );
 		adjustAssocs(newX, newY);
+		m_pView->resizeCanvasToItems();
 	}
 }
 ////////////////////////////////////////////////////////////////////////////////////////////////////





More information about the umbrello-devel mailing list