[Uml-devel] CVS: kdesdk/umbrello/umbrello uml.cpp,1.4,1.5 uml.h,1.1,1.2 umlview.cpp,1.6,1.7 umlview.h,1.3,1.4
kde at office.kde.org
kde at office.kde.org
Thu Jan 30 16:11:03 UTC 2003
Update of /home/kde/kdesdk/umbrello/umbrello
In directory office:/tmp/cvs-serv12875/umbrello
Modified Files:
uml.cpp uml.h umlview.cpp umlview.h
Log Message:
New feature: zoom is now available via the zoom submenu in the Diagram menu.
Image quality is very poor - zooming to 75% makes it almost imposible to read the texts, but it still can be useful if you know your diagrams good enough.
luis
Index: uml.cpp
===================================================================
RCS file: /home/kde/kdesdk/umbrello/umbrello/uml.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- uml.cpp 30 Jan 2003 16:47:26 -0000 1.4
+++ uml.cpp 31 Jan 2003 00:10:15 -0000 1.5
@@ -43,6 +43,8 @@
listView = 0;
ldict.setAutoDelete(true);
langSelect = new QPopupMenu(this);
+ zoomSelect = new QPopupMenu(this);
+
loading = false;
m_clipTimer = 0;
m_copyTimer = 0;
@@ -87,6 +89,35 @@
m->insertItem(i18n("Active Language"),langSelect,-1,m->count()-2);
}
}
+
+ //insert zoom menu. see comment above (language selection menu)
+ id=-1;
+ for( int i =0; i<t;i++)
+ {
+ id = menuBar()->idAt(i);
+ if(id == -1)
+ break;
+ if(menuBar()->findItem(id)->popup()->name() == QString("views"))
+ break;
+ }
+ if(id!=-1) {
+ QPopupMenu *m = menuBar()->findItem(id)->popup();
+ if(m) {
+ m->insertItem(i18n("Zoom"),zoomSelect,-1,m->count()-1);
+ }
+ }
+ //setup zoomSelect menu
+ zoomSelect->setCheckable(true);
+ connect(zoomSelect,SIGNAL(aboutToShow()),this,SLOT(setupZoomMenu()));
+ connect(zoomSelect,SIGNAL(activated(int)),this,SLOT(setZoom(int)));
+ //IMPORTANT: The ID's must match the zoom value (text)
+ zoomSelect->insertItem(i18n(" 33 %"),33);
+ zoomSelect->insertItem(i18n(" 50 %"),50);
+ zoomSelect->insertItem(i18n(" 75 %"),75);
+ zoomSelect->insertItem(i18n("100 %"),100);
+ zoomSelect->insertItem(i18n("150 %"),150);
+ zoomSelect->insertItem(i18n("200 %"),200);
+ zoomSelect->insertItem(i18n("300 %"),300);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
UMLApp::~UMLApp() {
@@ -113,6 +144,11 @@
viewStatusBar = KStdAction::showStatusbar(this, SLOT(slotViewStatusBar()), actionCollection());
selectAll = KStdAction::selectAll(this, SLOT( slotSelectAll() ), actionCollection());
+//FIXME - add UI if you want to have zoom in/out by clicking on the diagram
+// note that resultating zoom could not correspond to one of the predefined values if you dont watch the zooming step size
+ //zoomInAction = new KAction(i18n("Zoom In"),"file_new",0,this,SLOT(zoomIn()),actionCollection(),"zoom_in");
+ //zoomOutAction = new KAction(i18n("Zoom Out"),0,this,SLOT(zoomOut()),actionCollection(),"zoom_out");
+
classWizard = new KAction(i18n("New Class Wizard..."),0,this,SLOT(slotClassWizard()),
actionCollection(),"class_wizard");
@@ -202,6 +238,34 @@
createGUI();
}
+//////////////////////////////////////////////////////////////////////////////////////////////
+
+void UMLApp::setZoom(int z)
+{
+ doc->getCurrentView()->setZoom(z);
+}
+
+void UMLApp::setupZoomMenu()
+{
+ int zoom = doc->getCurrentView()->currentZoom();
+
+ //first uncheck all
+ for(int index = 0; index < zoomSelect->count(); index++)
+ zoomSelect->setItemChecked(zoomSelect->idAt(index),false);
+ zoomSelect->setItemChecked(zoom,true);
+}
+
+
+void UMLApp::zoomIn()
+{
+ doc->getCurrentView()->zoomIn();
+}
+
+void UMLApp::zoomOut()
+{
+ doc->getCurrentView()->zoomOut();
+}
+
////////////////////////////////////////////////////////////////////////////////////////////////////
void UMLApp::initStatusBar() {
///////////////////////////////////////////////////////////////////
Index: uml.h
===================================================================
RCS file: /home/kde/kdesdk/umbrello/umbrello/uml.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- uml.h 23 Jan 2003 22:21:13 -0000 1.1
+++ uml.h 31 Jan 2003 00:10:15 -0000 1.2
@@ -465,11 +465,35 @@
*/
void slotDeleteDiagram();
+ /**
+ * zooms in the current diagram
+ */
+ void zoomIn();
+ /**
+ * zooms out of the current diagram
+ */
+ void zoomOut();
+
+ /**
+ * set the zoom factor of the current diagram
+ * the parameter is in percentage
+ */
+ void setZoom(int z);
+
+ /**
+ * prepares the zoom menu for display
+ */
+ void setupZoomMenu();
private:
/**
* to slect the active language
*/
QPopupMenu *langSelect;
+
+ /**
+ * Popup menu for zoom selection
+ */
+ QPopupMenu *zoomSelect;
/**
* active language
@@ -557,6 +581,9 @@
KToggleAction* viewShowGrid;
KAction* viewExportImage;
KAction* viewProperties;
+
+ KAction *zoomInAction;
+ KAction *zoomOutAction;
KToggleAction* showDocumentation;
KAction* genAll;
Index: umlview.cpp
===================================================================
RCS file: /home/kde/kdesdk/umbrello/umbrello/umlview.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- umlview.cpp 30 Jan 2003 23:16:39 -0000 1.6
+++ umlview.cpp 31 Jan 2003 00:10:15 -0000 1.7
@@ -108,6 +108,7 @@
connect( (UMLApp *)getDocument() -> parent() , SIGNAL( sigCutSuccessful() ),
this, SLOT( slotCutSuccessful() ) );
}
+
////////////////////////////////////////////////////////////////////////////////////////////////////
UMLView::~UMLView() {
if( m_pData )
@@ -201,8 +202,12 @@
} while(!finishX || !finishY);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-void UMLView::contentsMouseReleaseEvent(QMouseEvent* mouseEvent) {
- QPoint p = mouseEvent->pos();
+void UMLView::contentsMouseReleaseEvent(QMouseEvent* ome) {
+
+ QMouseEvent *me = new QMouseEvent(QEvent::MouseButtonRelease,
+ inverseWorldMatrix().map(ome->pos()),
+ ome->button(),
+ ome->state());
if(m_bDrawRect) {
viewport()->setMouseTracking( false );
m_bDrawRect = false;
@@ -212,16 +217,16 @@
delete m_pAssocLine;
m_pAssocLine = 0;
}
- m_Pos.setX(p.x());
- m_Pos.setY(p.y());
+ m_Pos.setX(me->x());
+ m_Pos.setY(me->y());
- if( allocateMouseReleaseEvent(mouseEvent) ) {
+ if( allocateMouseReleaseEvent(me) ) {
return;
}
- if( m_CurrentCursor == WorkToolBar::tbb_Arrow || mouseEvent -> state() != LeftButton ) {
+ if( m_CurrentCursor == WorkToolBar::tbb_Arrow || me -> state() != LeftButton ) {
viewport()->setMouseTracking( false );
- if (mouseEvent->state() == RightButton) {
+ if (me->state() == RightButton) {
setMenu();
}
return;
@@ -367,13 +372,13 @@
}
//Create a Message on a Sequence diagram
if(m_CurrentCursor == WorkToolBar::tbb_Seq_Message) {
- UMLWidget* clickedOnWidget = onWidgetLine( mouseEvent->pos() );
+ UMLWidget* clickedOnWidget = onWidgetLine( me->pos() );
if(clickedOnWidget) {
if(!m_pFirstSelectedWidget) { //we are starting a new message
m_pFirstSelectedWidget = clickedOnWidget;
viewport()->setMouseTracking( true );
m_pAssocLine = new QCanvasLine( canvas() );
- m_pAssocLine->setPoints( p.x(), p.y(), p.x(), p.y() );
+ m_pAssocLine->setPoints( me->x(), me->y(), me->x(), me->y() );
m_pAssocLine->setPen( QPen( m_pData -> getLineColor(), 0, DashLine ) );
m_pAssocLine->setVisible( true );
return;
@@ -384,7 +389,7 @@
MessageWidget* message = new MessageWidget(this, m_pFirstSelectedWidget, clickedOnWidget,
messageText, getDocument() -> getUniqueID(),
- mouseEvent -> y());
+ me->y());
connect(this, SIGNAL(sigColorChanged(int)), message, SLOT(slotColorChanged(int)));
messageText->setActivated();
message->setActivated();
@@ -649,13 +654,17 @@
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-void UMLView::contentsMouseMoveEvent(QMouseEvent *mouseEvent) {
- QPoint p = mouseEvent->pos();
- m_LineToPos = p;
+void UMLView::contentsMouseMoveEvent(QMouseEvent *ome)
+{
+ QMouseEvent *me = new QMouseEvent(QEvent::MouseMove,
+ inverseWorldMatrix().map(ome->pos()),
+ ome->button(),
+ ome->state());
+ m_LineToPos = me->pos();
if( m_pFirstSelectedWidget ) {
if( m_pAssocLine ) {
QPoint sp = m_pAssocLine -> startPoint();
- m_pAssocLine -> setPoints( sp.x(), sp.y(), p.x(), p.y() );
+ m_pAssocLine -> setPoints( sp.x(), sp.y(), me->x(), me->y() );
}
return;
}
@@ -664,22 +673,22 @@
if( m_SelectionRect.count() == 4) {
QCanvasLine * line = m_SelectionRect.at( 0 );
- line -> setPoints( m_Pos.x(), m_Pos.y(), p.x(), m_Pos.y() );
+ line -> setPoints( m_Pos.x(), m_Pos.y(), me->x(), m_Pos.y() );
line = m_SelectionRect.at( 1 );
- line -> setPoints( p.x(), m_Pos.y(), p.x(), p.y() );
+ line -> setPoints( me->x(), m_Pos.y(), me->x(), me->y() );
line = m_SelectionRect.at( 2 );
- line -> setPoints( p.x(), p.y(), m_Pos.x(), p.y() );
+ line -> setPoints( me->x(), me->y(), m_Pos.x(), me->y() );
line = m_SelectionRect.at( 3 );
- line -> setPoints( m_Pos.x(), p.y(), m_Pos.x(), m_Pos.y() );
+ line -> setPoints( m_Pos.x(), me->y(), m_Pos.x(), m_Pos.y() );
selectWidgets();
}
}
- allocateMouseMoveEvent(mouseEvent);
+ allocateMouseMoveEvent(me);
}
bool UMLView::serialize(QDataStream *s, bool archive, int fileversion) {
@@ -749,8 +758,14 @@
canvas() -> setAllChanged();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-void UMLView::contentsMouseDoubleClickEvent(QMouseEvent * mouseEvent) {
- if ( allocateMouseDoubleClickEvent(mouseEvent) ) {
+void UMLView::contentsMouseDoubleClickEvent(QMouseEvent * ome)
+{
+
+ QMouseEvent *me = new QMouseEvent(QEvent::MouseButtonDblClick,
+ inverseWorldMatrix().map(ome->pos()),
+ ome->button(),
+ ome->state());
+ if ( allocateMouseDoubleClickEvent(me) ) {
return;
}
clearSelected();
@@ -917,7 +932,12 @@
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-void UMLView::contentsMousePressEvent(QMouseEvent* mouseEvent) {
+void UMLView::contentsMousePressEvent(QMouseEvent* ome)
+{
+ QMouseEvent *me = new QMouseEvent(QEvent::MouseButtonPress,
+ inverseWorldMatrix().map(ome->pos()),
+ ome->button(),
+ ome->state());
getDocument()->setModified(true);
int x, y;
if( m_pAssocLine ) {
@@ -927,12 +947,12 @@
viewport()->setMouseTracking(true);
emit sigRemovePopupMenu();
- if( allocateMousePressEvent(mouseEvent) ) {
+ if( allocateMousePressEvent(me) ) {
return;
}
- x = mouseEvent->x();
- y = mouseEvent->y();
+ x = me->x();
+ y = me->y();
m_Pos.setX( x );
m_Pos.setY( y );
m_LineToPos.setX( x );
@@ -2690,4 +2710,34 @@
emit sigShowGridToggled( m_pData->getShowSnapGrid() );
}
-#include "umlview.moc"
+void UMLView::setZoom(int zoom)
+{
+ if(zoom<10) zoom = 10;
+ else if (zoom > 500) zoom = 500;
+
+ QWMatrix wm;
+ wm.scale(zoom/100.0,zoom/100.0);
+ setWorldMatrix(wm);
+}
+
+int UMLView::currentZoom()
+{
+ return (int)(worldMatrix().m11()*100.0);
+}
+
+
+void UMLView::zoomIn()
+{
+ QWMatrix wm = worldMatrix();
+ wm.scale(2.0,2.0); // adjust zooming step here
+ setWorldMatrix(wm);
+}
+
+void UMLView::zoomOut()
+{
+ QWMatrix wm = worldMatrix();
+ wm.scale(0.5,0.5); //adjust zooming step here
+ setWorldMatrix(wm);
+}
+
+#include "umlview.moc"
\ No newline at end of file
Index: umlview.h
===================================================================
RCS file: /home/kde/kdesdk/umbrello/umbrello/umlview.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- umlview.h 30 Jan 2003 23:16:39 -0000 1.3
+++ umlview.h 31 Jan 2003 00:10:15 -0000 1.4
@@ -57,6 +57,16 @@
~UMLView();
/**
+ * sets the zoom factor of the view
+ */
+ void setZoom(int zoom);
+
+ /**
+ * return the current zoom factor
+ */
+ int currentZoom();
+
+ /**
* Synchronize the views data. Call before saving or a full cip of the view.
*/
void synchronizeData();
@@ -858,6 +868,10 @@
QPtrList<SeqLineWidget> m_SeqLineList;
public slots:
+
+ void zoomIn();
+ void zoomOut();
+
void slotToolBarChanged(int c);
void slotObjectCreated(UMLObject * o);
void slotObjectRemoved(UMLObject * o);
More information about the umbrello-devel
mailing list