umbrello API Documentation

autolayoutdlg.cpp

00001 /***************************************************************************
00002  *  copyright (C) 2005                                                     *
00003  *  Umbrello UML Modeller Authors <uml-devel @uml.sf.net>                  *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  ***************************************************************************/
00011 
00012 #include "autolayoutdlg.h"
00013 #include "../associationwidget.h"
00014 #include "../umlwidget.h"
00015 #include "autolayout.h"
00016 #include "newautolayoutdialog.h"
00017 #include <qcheckbox.h>
00018 #include <qspinbox.h>
00019 #include <qslider.h>
00020 #include <kdebug.h>
00021 
00022 
00023 AutolayoutDlg::AutolayoutDlg(KConfig* c,UMLView* v,QWidget *parent, const char *name)
00024         :MyDialog1(parent, name)
00025 {
00026     view=v;
00027     readConfig(c);
00028     config=c;
00029 }
00030 
00031 void AutolayoutDlg::slotSetAssociationWeight(int i)
00032 {
00033     associationWeight=i;
00034 }
00035 
00036 
00037 void AutolayoutDlg::slotSetDependenciesWeight(int i)
00038 {
00039     dependenciesWeight=i;
00040 }
00041 
00042 
00043 void AutolayoutDlg::slotSetGeneralizationWeight(int i)
00044 {
00045     generalizationWeight=i;
00046 }
00047 void AutolayoutDlg::slotSetGenralizationAsEdges(bool b)
00048 {
00049     genralizationAsEdges=b;
00050 }
00051 
00052 
00053 void AutolayoutDlg::slotSetDependenciesAsEdges(bool b)
00054 {
00055     dependenciesAsEdges=b;
00056 }
00057 
00058 
00059 void AutolayoutDlg::slotSetAssociationAsEdges(bool b)
00060 {
00061     associationAsEdges=b;
00062 }
00063 
00064 
00065 
00066 void AutolayoutDlg::slotSetCompressShapes(bool b)
00067 {
00068     compressShapes=b;
00069 }
00070 
00071 
00072 void AutolayoutDlg::slotSetCenterDiagram(bool b)
00073 {
00074     centerDiagram=b;
00075 }
00076 
00077 
00078 void AutolayoutDlg::slotSetClusterizeHierarchies(bool b)
00079 
00080 {
00081     clusterizeHierarchies=b;
00082 }
00083 
00084 
00085 void AutolayoutDlg::slotSetShapeSeparation(int i)
00086 {
00087     shapeSeparation=i;
00088 }
00089 
00090 void AutolayoutDlg::slotReloadSettings()
00091 {
00092     readConfig(config);
00093 }
00094 
00095 
00096 void AutolayoutDlg::slotSaveSettings()
00097 {
00098     writeConfig(config);
00099 }
00100 
00101 
00102 void AutolayoutDlg::slotDoAutolayout()
00103 {
00104 
00105     Autolayout::Autolayouter* a=getAutolayouter();;
00106 
00107     a->setAssociationAsEdges( associationAsEdges);
00108     a->setAssociationWeight( associationWeight );
00109     a->setCenterDiagram( centerDiagram);
00110     a->setDependenciesAsEdges( dependenciesAsEdges);
00111     a->setClusterizeHierarchies( clusterizeHierarchies);
00112     a->setCompressShapes( compressShapes);
00113     a->setDependenciesWeight( dependenciesWeight);
00114     a->setGeneralizationAsEdges( genralizationAsEdges);
00115     a->setGeneralizationWeight( generalizationWeight);
00116     a->setNoteConnectionWeight( 1);
00117     a->setNoteConnectionsAsEdges(true);
00118     a->setShapeSeparation( shapeSeparation);
00119     a->autolayout( view);
00120     delete a;
00121     a=0;
00122     accept();
00123 }
00124 
00125 void AutolayoutDlg::readConfig( KConfig * conf)
00126 {
00127     conf->setGroup("AutolayoutDlg");
00128     associationEdgesCB->setChecked((bool)(conf->readBoolEntry( "associationAsEdges",false)));
00129     centerDiagramCB->setChecked((bool)(conf->readBoolEntry( "centerDiagram",true)));
00130     dependenciesEdgesCB->setChecked((bool)(conf->readBoolEntry( "dependenciesAsEdges",false)));
00131     clusterizeHierarchiesCB->setChecked((bool)(conf->readBoolEntry( "clusterizeHierarchies",false)));
00132     compressShapesCB->setChecked((bool)(conf->readBoolEntry( "compressShapes",true)));
00133     dependenciedEdgesSL->setValue((int)(conf->readNumEntry( "dependenciesWeight",0)));
00134     generalizationCB->setChecked((bool)(conf->readBoolEntry( "genralizationAsEdges",true)));
00135     generalizationEdgessSL->setValue((int)(conf->readNumEntry( "generalizationWeight",1)));
00136     associationEdgesSL->setValue((int)(conf->readNumEntry( "associationWeight",0)));
00137     shapeSeparationSB->setValue((int)(conf->readNumEntry( "shapeSeparation",0)));
00138     algorithmCOB->setCurrentItem((int)(conf->readNumEntry( "algorithm",0)));
00139 }
00140 
00141 void AutolayoutDlg::writeConfig( KConfig * conf)
00142 {
00143     //  conf=kapp->config();
00144     conf->setGroup("AutolayoutDlg");
00145     conf->writeEntry( "associationAsEdges",associationEdgesCB->isChecked());
00146     conf->writeEntry( "centerDiagram", centerDiagramCB->isChecked());
00147     conf->writeEntry("dependenciesAsEdges",dependenciesEdgesCB->isChecked());
00148     conf->writeEntry("clusterizeHierarchies",clusterizeHierarchiesCB->isChecked());
00149     conf->writeEntry("dependenciesWeight", dependenciedEdgesSL->value());
00150     conf->writeEntry("genralizationAsEdges",generalizationCB->isChecked());
00151 
00152     conf->writeEntry("generalizationWeight",generalizationEdgessSL->value());
00153     conf->writeEntry("associationWeight",associationEdgesSL->value());
00154     conf->writeEntry("shapeSeparation",shapeSeparationSB->value());
00155     //conf->writeEntry("al
00156 
00157 
00158     //algorithmCOB->setCurrentItem(conf->readNumEntry( "algorithm",0));
00159 
00160 }
00161 
00162 void AutolayoutDlg::slotSelectAlgorithm( const QString& _algname)
00163 {
00164     algname=_algname;
00165 
00166 }
00167 
00168 Autolayout::Autolayouter * AutolayoutDlg::getAutolayouter( )
00169 {
00170     const QString text = algorithmCOB->currentText();
00171     kDebug() << "Autolayout Algorithm " << algname << " found " << text << endl;
00172     if (text == "dot")
00173         return new Autolayout::DotAutolayouter();
00174     if (text == "circo")
00175         return new Autolayout::CircoAutolayouter();
00176     if (text ==  "neato")
00177         return new Autolayout::NeatoAutolayouter();
00178     kError() << "Autolayout Algorithm not found" << endl;
00179     return new Autolayout::DotAutolayouter();
00180 }
00181 
00182 
00183 
00184 #include "autolayoutdlg.moc"
KDE Logo
This file is part of the documentation for umbrello Version 3.1.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Jun 26 08:07:54 2007 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003