Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

graph.cpp

Go to the documentation of this file.
00001 /*
00002  Modular Psi - A graph tracker of the Parapsychologcal scientific development
00003  Copyright (C) 2005 Leonardo Stern
00004 
00005  This program is free software; you can redistribute it and/or modify it under
00006  the terms of the Common Public License Version 1.0 or (at your option) any later version.
00007 
00008  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
00009  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00010  See the Common Public License for more details.
00011 
00012  You should have received a copy of the Common Public License along with this program;
00013 */
00014 
00015 #include "graph.hpp"
00016 #include "edgelist.hpp"
00017 #include <qaction.h>
00018 #include <qpoint.h>
00019 #include <qmessagebox.h>
00020 #include <qlabel.h>
00021 #include <qpushbutton.h>
00022 
00023 Graph::Graph() 
00024     : QDict<Proposition>()
00025 {
00026     init();
00027 }
00028 
00029 Graph::~Graph()
00030 {
00031 
00032 }
00033 
00034 void Graph::setLastName(int newlast)
00035 {
00036     p_lastName = newlast;
00037 }
00038 
00039 void Graph::setLastEdge(int newLastEdge)
00040 {
00041         p_lastEdge = newLastEdge;
00042 }
00043 
00044 void Graph::setStatus(int newstatus)
00045 {
00046         p_status = newstatus;
00047 }
00048 
00049 void Graph::clearAllEdges()
00050 {
00051         QDictIterator<Proposition> it ( *this );
00052     for( ; it.current(); ++it )          {
00053         it.current()->incoming->clear();
00054         it.current()->outgoing->clear();
00055         edges->clear();
00056     }
00057         
00058 }
00059 
00060 void Graph::init()
00061 {
00062         setAutoDelete(true);
00063     setLastName(0);
00064     lastXY = QPoint(0,0);
00065     edges = new EdgeList( );
00066     edges->setAutoDelete(true);
00067 }
00068 
00069 void Graph::checkPos(QPoint po)
00070 {
00071     if (po.x() > lastXY.x()) lastXY.setX(po.x());
00072     if (po.y() > lastXY.y()) lastXY.setY(po.y());
00073     gui->props->setGeometry(gui->props->pos().x(),gui->props->pos().y(),po.x() + 10, po.y() + 50);
00074 }
00075 
00076 void Graph::checkLastName(QString newname)
00077 {
00078     QString temp = newname.right(newname.length()-1);
00079     int x = temp.toInt();
00080     if (x  > lastName()) setLastName(x);
00081 }
00082 
00083 void Graph::checkLastEdge(QString newLastEdge)
00084 {
00085     QString temp = newLastEdge.right(newLastEdge.length()-1);
00086     int x = temp.toInt();
00087     if (x  > lastEdge()) setLastEdge(x);
00088 }
00089 
00090 void Graph::check(Proposition p)
00091 {
00092     QString nm = p.name();
00093     nm = nm.right(nm.length()-1);
00094     checkLastName(p.name());
00095     checkPos(p.pos());
00096 }
00097 
00098 void Graph::error(QString message)
00099 {
00100     QMessageBox::warning(0, "Modular Psi", message);
00101 }
00102 
00103 void Graph::setChanged(bool change)
00104 {
00105         changed = change;
00106         if (changed)
00107         {
00108                 gui->changeButton->setEnabled(false);
00109                 gui->commitAction->setEnabled(false);
00110                 gui->fileSaveAction->setEnabled(true);
00111                 gui->changeMessage->setText("Changed");
00112         }
00113         else 
00114         {
00115                 if (gui->checked)
00116                         gui->commitAction->setEnabled(true);
00117                 gui->changeButton->setEnabled(false);
00118                 gui->fileSaveAction->setEnabled(false);
00119                 gui->changeMessage->setText("");
00120         }
00121 }
Untitled Document Pesquisa Psi SourceForge.net Logo