#include <smallmaps.h>

Definition at line 43 of file smallmaps.h.
Public Member Functions | |
| SmallMaps (QWidget *parent=0, const char *name=0) | |
| ~SmallMaps () | |
Data Fields | |
| QLineEdit * | ed1 |
| QLineEdit * | ed2 |
| QLineEdit * | ed3 |
| QLineEdit * | ed4 |
| QLineEdit * | ed5 |
| QTextView * | med |
Private Slots | |
| void | createmap () |
| void | createtraffic () |
| SmallMaps::SmallMaps | ( | QWidget * | parent = 0, |
|
| const char * | name = 0 | |||
| ) |
Definition at line 26 of file smallmaps.cpp.
References createmap(), createtraffic(), ed1, ed2, ed3, ed4, ed5, and med.
00027 : QWidget( parent, name ) 00028 { 00029 // Make the top-level layout; a vertical box to contain all widgets 00030 // and sub-layouts. 00031 QBoxLayout *topLayout = new QVBoxLayout( this, 5 ); 00032 00033 // Create a menubar... 00034 QMenuBar *menubar = new QMenuBar( this ); 00035 menubar->setSeparator( QMenuBar::InWindowsStyle ); 00036 QPopupMenu* popup; 00037 popup = new QPopupMenu( this ); 00038 popup->insertItem( "&Quit", qApp, SLOT(quit()) ); 00039 menubar->insertItem( "&File", popup ); 00040 00041 // ...and tell the layout about it. 00042 topLayout->setMenuBar( menubar ); 00043 00044 // Make an hbox that will hold a row of buttons. 00045 QBoxLayout *buttons = new QHBoxLayout( topLayout ); 00046 00047 QPushButton* but1 = new QPushButton( this ); 00048 QString s; 00049 s.sprintf( "Create Small Map "); 00050 but1->setText( s ); 00051 00052 // Set horizontal stretch factor to 10 to let the buttons 00053 // stretch horizontally. The buttons will not stretch 00054 // vertically, since bigWidget below will take up vertical 00055 // stretch. 00056 buttons->addWidget( but1, 10 ); 00057 // (Actually, the result would have been the same with a 00058 // stretch factor of 0; if no items in a layout have non-zero 00059 // stretch, the space is divided equally between members.) 00060 00061 00062 QPushButton* but2 = new QPushButton( this ); 00063 s.sprintf( "Create random Traffic "); 00064 but2->setText( s ); 00065 buttons->addWidget( but2, 10 ); 00066 00067 00068 00069 // Make a grid that will hold a vertical table of QLabel/QLineEdit 00070 // pairs next to a large QMultiLineEdit. 00071 00072 // Don't use hard-coded row/column numbers in QGridLayout, you'll 00073 // regret it when you have to change the layout. 00074 const int labelCol = 0; 00075 const int linedCol = 1; 00076 const int multiCol = 2; 00077 00078 // Let the grid-layout have a spacing of 10 pixels between 00079 // widgets, overriding the default from topLayout. 00080 QGridLayout *grid = new QGridLayout( topLayout, 0, 0, 10 ); 00081 int row=0; 00082 00083 00084 ed1 = new QLineEdit( this ); 00085 // The line edit goes in the second column 00086 grid->addWidget( ed1, row, linedCol ); 00087 ed1->setText("frida_bidi_plain.nod.xml"); 00088 00089 // Make a label that is a buddy of the line edit 00090 s.sprintf( "Original Map:" ); 00091 QLabel *label1 = new QLabel( ed1, s, this ); 00092 // The label goes in the first column. 00093 grid->addWidget( label1, row, labelCol ); 00094 row++; 00095 00096 00097 ed2 = new QLineEdit( this ); 00098 grid->addWidget( ed2, row, linedCol ); 00099 s.sprintf( "\tX1:" ); 00100 QLabel *label2 = new QLabel( ed2, s, this ); 00101 grid->addWidget( label2, row, labelCol ); 00102 row++; 00103 00104 00105 ed3 = new QLineEdit( this ); 00106 grid->addWidget( ed3, row, linedCol ); 00107 s.sprintf( "\tX2:" ); 00108 QLabel *label3 = new QLabel( ed3, s, this ); 00109 grid->addWidget( label3, row, labelCol ); 00110 row++; 00111 00112 00113 ed4 = new QLineEdit( this ); 00114 grid->addWidget( ed4, row, linedCol ); 00115 s.sprintf( "\tY1:" ); 00116 QLabel *label4 = new QLabel( ed4, s, this ); 00117 grid->addWidget( label4, row, labelCol ); 00118 row++; 00119 00120 00121 ed5 = new QLineEdit( this ); 00122 grid->addWidget( ed5, row, linedCol ); 00123 s.sprintf( "\tY2:" ); 00124 QLabel *label5 = new QLabel( ed5, s, this ); 00125 grid->addWidget( label5, row, labelCol ); 00126 row++; 00127 00128 00129 // The multiline edit will cover the entire vertical range of the 00130 // grid (rows 0 to numRows) and stay in column 2. 00131 00132 med = new QTextView( this ); 00133 grid->addMultiCellWidget( med, 0, -1, multiCol, multiCol ); 00134 00135 // The labels will take the space they need. Let the remaining 00136 // horizontal space be shared so that the multiline edit gets 00137 // twice as much as the line edit. 00138 grid->setColStretch( linedCol, 10 ); 00139 grid->setColStretch( multiCol, 20 ); 00140 00141 // Add a widget at the bottom. 00142 QLabel* sb = new QLabel( this ); 00143 sb->setText( "Florides Andreas 2006 UCY" ); 00144 sb->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 00145 // This widget will use all horizontal space, and have a fixed height. 00146 00147 // we should have made a subclass and implemented sizePolicy there... 00148 sb->setFixedHeight( sb->sizeHint().height() ); 00149 00150 sb->setAlignment( AlignVCenter | AlignLeft ); 00151 topLayout->addWidget( sb ); 00152 00153 topLayout->activate(); 00154 00155 // signals and slots connections 00156 connect( but1, SIGNAL( clicked() ), SLOT( createmap() ) ); 00157 connect( but2, SIGNAL( clicked() ), SLOT( createtraffic() ) ); 00158 }
| SmallMaps::~SmallMaps | ( | ) |
Definition at line 160 of file smallmaps.cpp.
00161 { 00162 // All child widgets are deleted by Qt. 00163 // The top-level layout and all its sub-layouts are deleted by Qt. 00164 }
| void SmallMaps::createmap | ( | ) | [private, slot] |
Definition at line 167 of file smallmaps.cpp.
References ed1, ed2, ed3, ed4, ed5, and med.
Referenced by SmallMaps().
00168 { 00169 char buffer[1024]; 00170 FILE* fd ; 00171 00172 string fileName=ed1->text(); 00173 int x1=atoi(ed2->text()); 00174 int x2=atoi(ed3->text()); 00175 int y1=atoi(ed4->text()); 00176 int y2=atoi(ed5->text()); 00177 char tempstring[500]; 00178 //declares filename 00179 ifstream d_file; 00180 ofstream OUT ("smallfrida.nod.xml"); 00181 string strb,temp; 00182 int x,y; 00183 char str[2000]; 00184 int whereid,wherex,wherey,whereend; 00185 00186 d_file.open(ed1->text()); //attempts to open file 00187 00188 if (!d_file.is_open()) 00189 { 00190 //if file doesn't exist; don't create a new one 00191 med->append(tr("File")); 00192 med->append(ed1->text()); 00193 med->append(tr("does not exist in the client's current directory\n ")); 00194 00195 } 00196 else 00197 { 00198 sprintf(tempstring, "File OK. Start parsing with x:%d-%d and y:%d-%d",x1,x2,y1,y2); 00199 med->append(tempstring); 00200 00201 while(!d_file.eof()) 00202 { 00203 d_file.getline(str,2000); 00204 strb=str; 00205 whereid=strb.find("id=",0); 00206 if (whereid != string::npos) 00207 { 00208 wherex=strb.find("x=",0); 00209 wherey=strb.find("y=",0); 00210 whereend=strb.find(">",0); 00211 x = atoi(strb.substr(wherex+3,wherey-12).c_str()); 00212 if (x>x1&&x<x2) 00213 { 00214 y = atoi(strb.substr(wherey+3,whereend-2).c_str()); 00215 if (y>y1&&y<y2) OUT << str << endl; 00216 } 00217 00218 } 00219 else OUT << str << endl; 00220 } 00221 d_file.close(); 00222 00223 fd= popen("./netconvert --xml-node-files=smallfrida.nod.xml --xml-edge-files=frida_bidi_plain.edg.xml --output-file=smallfrida.net.xml --omit-corrupt-edges", "r"); 00224 if (fd == NULL) { 00225 med->append( tr("Error executing netconvert, try manualy")); //error occured 00226 } 00227 while(fgets(buffer, sizeof(buffer), fd)!=NULL) { 00228 med->append(buffer); 00229 } 00230 pclose (fd); 00231 00232 } 00233 }
| void SmallMaps::createtraffic | ( | ) | [private, slot] |
Definition at line 236 of file smallmaps.cpp.
References med.
Referenced by SmallMaps().
00237 { 00238 00239 char buffer[1024]; 00240 FILE* fd ; 00241 00242 med->append( tr("Creating random routes with jtrrouter...\n") ); 00243 00244 fd= popen("export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/:/usr/lib/ ; jtrrouter --net=smallfrida.net.xml -R 2 --output-file=smallfrida.rou.xml -b 0 -e 100 --continue-on-unbuild ", "r"); 00245 if (fd == NULL) { 00246 med->append( tr("Error executing jtrrouter, try manualy")); //error occured 00247 } 00248 while(fgets(buffer, sizeof(buffer), fd)!=NULL) { 00249 med->append(buffer); 00250 } 00251 pclose (fd); 00252 00253 }
| QLineEdit* SmallMaps::ed1 |
| QLineEdit * SmallMaps::ed2 |
| QLineEdit * SmallMaps::ed3 |
| QLineEdit * SmallMaps::ed4 |
| QLineEdit * SmallMaps::ed5 |
| QTextView* SmallMaps::med |
Definition at line 50 of file smallmaps.h.
Referenced by createmap(), createtraffic(), and SmallMaps().
1.5.6