-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcategory_page_set.cpp
More file actions
213 lines (176 loc) · 5.54 KB
/
Copy pathcategory_page_set.cpp
File metadata and controls
213 lines (176 loc) · 5.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
/******************************************************************************************
**** PROGRAM: subnet_traffic_dia.cpp
**** AUTHOR: Chengan 4/01/04
**** douboer@gmail.com
******************************************************************************************/
#include <qtoolbutton.h>
//Added by qt3to4:
#include <QPixmap>
#include <iostream>
#include <fstream>
#include "category_wid.h"
#include "category_page_set.h"
#include "icons_test.h"
#include "psdcaparam.h"
#include "csdcaparam.h"
#include "generalparam.h"
#include "wlan_generalparam.h"
#include "wisim.h"
#include "wlan.h"
#include "cconst.h"
#define CGDEBUG 0
static void set_caption( CategoryWid* xx, CategoryInterface *c, int i )
{
// QWidget *w = qApp->mainWidget();
QWidget *w = xx;
if ( !w )
return;
QString title = QString("Parameters" );
title += " - " + c->categoryName( i - c->categoryOffset() );
w->setCaption( title );
}
CategoryPage::CategoryPage( NetworkClass *np_param, Q3WidgetStack *s, CategoryWid* v_category_wid ) : CategoryInterface( s ),
created( FALSE ), np( np_param ), category_wid( v_category_wid )
{
// category_wid = new CategoryWid;
// m_stack = category_wid->stack;
}
CategoryPage::~CategoryPage( )
{
}
QString CategoryPage::categoryName( int i ) const
{
switch ( i ) {
case 0:
return QString(qApp->translate( "CategoryPage", "General - PHS" ));
break;
case 1:
return QString(qApp->translate( "CategoryPage", "General - WLAN" ));
break;
case 2:
return QString(qApp->translate( "CategoryPage", "PS DCA" ));
break;
case 3:
return QString(qApp->translate( "CategoryPage", "CS DCA" ));
break;
}
return QString::null;
}
QIcon CategoryPage::icon(int i) const
{
switch (i ) {
case 0:
return QPixmap( TestIcon::icon_general );
break;
case 1:
return QPixmap( TestIcon::icon_general);
break;
case 2:
return QPixmap( TestIcon::icon_ps);
break;
case 3:
return QPixmap( TestIcon::icon_cs);
break;
default:
return QPixmap( QString::null );
break;
}
}
void CategoryPage::setCurrentCategory( int i)
{
create();
m_stack->raiseWidget( i );
set_caption( category_wid, this, i );
connect( category_wid->g, SIGNAL( clicked( int ) ), category_wid, SLOT( setBkColor(int) ) );
#if CGDEBUG
for ( int i=0; i<category_wid->g->count(); i++ )
{
printf("test category_wid->g->count() %d \n", category_wid->g->count() );
//category_wid->g->selected()->setPaletteBackgroundColor( green );
if ( i == category_wid->g->selectedId() )
{
printf(" test \n ");
category_wid->g->selected()->setPaletteBackgroundColor( Qt::green );
} else {
category_wid->g->find(i)->setBackgroundMode(Qt::PaletteBase);
}
}
#endif
}
#if 0
void CategoryPage::setBkColor( int i )
{
for ( int j=0; j<category_wid->g->count(); j++ )
{
printf("test category_wid->g->count() %d \n", category_wid->g->count() );
//category_wid->g->selected()->setPaletteBackgroundColor( green );
if ( j == i )
{
printf(" test \n ");
category_wid->g->find(j)->setPaletteBackgroundColor( Qt::green );
} else {
category_wid->g->find(j)->setBackgroundMode(Qt::PaletteBase);
}
}
}
#endif
void CategoryPage::create( )
{
#if 0
std::cout << "CategoryPage::create() \n";
#endif
if ( created )
return;
created = TRUE;
gp = new generalParam( np, m_stack );
m_stack->addWidget( gp, categoryOffset() + 0 );
wgp = new WLANGeneralParam( np, m_stack );
m_stack->addWidget( wgp, categoryOffset() + 1 );
pp = new psDcaParam( np, m_stack );
m_stack->addWidget( pp, categoryOffset() + 2 );
cp = new csDcaParam( np, m_stack );
m_stack->addWidget( cp, categoryOffset() + 3 );
if ( np->technology() == CConst::PHS )
{
wgp->setDisabled (true);
}
else if ( np->technology() == CConst::WLAN ) {
gp->setDisabled (true);
pp->setDisabled (true);
cp->setDisabled (true);
}
#if CGDEBUG
// xxxxxxx
int cell_idx = 0;
int ap_idx = 0;
bool flag = true;
int num = 0;
double radius = 120.0;
double threshold = 2000.0;
double* sir_list = ( double* ) NULL;
WLANCellClass* cell = (WLANCellClass*) NULL;
WLANSectorClass* ap = (WLANSectorClass*) NULL;
if ( flag ) {
std::ofstream sir_aps_output;
sir_aps_output.open("sir_aps.txt");
if( !sir_aps_output )
std::cout << "File sir_aps.txt not exist.\n";
// Calculate SIR
num = 0;
for (cell_idx=0; cell_idx<np->num_cell; cell_idx++) {
cell = (WLANCellClass*) np->cell_list[cell_idx];
for (ap_idx=0; ap_idx<cell->num_sector; ap_idx++) num ++;
}
sir_list = (double*) malloc ( (num+1) * sizeof(double) );
((WLANNetworkClass* ) np)->comp_sir_aps( sir_list, radius, threshold );
// Print results to file.
for ( int i=0; i<num; i++ ) {
sir_aps_output << "AP " << i << " SIR " << sir_list[i] << std::endl;
std::cout << "AP " << i << " SIR " << sir_list[i] << std::endl;
}
sir_aps_output.close();
flag = false;
}
free( sir_list ); sir_list = (double*) NULL;
#endif
}