void NetAndUart::init_connect() { //打开串口,根据参数,初始化串口 connect(open_button, SIGNAL(clicked()), this, SLOT(open_button_clicked())); connect(timerData, SIGNAL(timeout()), this, SLOT(timeFunction())); //网络相关接口 connect(hostLineEdit, SIGNAL(textChanged(QString)), this, SLOT(enableGetFortuneButton())); connect(portLineEdit, SIGNAL(textChanged(QString)), this, SLOT(enableGetFortuneButton())); connect(getFortuneButton, SIGNAL(clicked()), this, SLOT(requestNewFortune())); }
tf::PTabVolumeInfo::PTabVolumeInfo(QWidget *parent) : QWidget(parent) { QFont tinyFont = QApplication::font(); #ifdef Q_OS_LINUX tinyFont.setPointSize(9); #endif tabs = new QTabWidget(this); info_tab = new QWidget(tabs); pyramid_tab = new QWidget(tabs); // info panel info_panel = new QWidget(this); vol_format_field = new QLineEdit(); vol_format_field->setAlignment(Qt::AlignLeft); vol_format_field->setReadOnly(true); vol_format_field->setFont(tinyFont); vol_size_field = new QLineEdit(); vol_size_field->setAlignment(Qt::AlignLeft); vol_size_field->setReadOnly(true); vol_size_field->setFont(tinyFont); vol_dims_vxl_field = new QLineEdit(); vol_dims_vxl_field->setAlignment(Qt::AlignLeft); vol_dims_vxl_field->setReadOnly(true); vol_dims_vxl_field->setFont(tinyFont); vol_dims_mm_field = new QLineEdit(); vol_dims_mm_field->setAlignment(Qt::AlignLeft); vol_dims_mm_field->setReadOnly(true); vol_dims_mm_field->setFont(tinyFont); voxel_dims_label = new QLabel(QString("Voxel (").append(QChar(0x03BC)).append("m):")); vxl_field = new QLineEdit(); vxl_field->setAlignment(Qt::AlignLeft); vxl_field->setReadOnly(true); vxl_field->setFont(tinyFont); org_field = new QLineEdit(); org_field->setAlignment(Qt::AlignLeft); org_field->setReadOnly(true); org_field->setFont(tinyFont); // virtual pyramid panel vp_panel = new QGroupBox("Info", this); #ifdef Q_OS_LINUX vp_panel->setStyle(new QWindowsStyle()); #endif vp_path = new QLineEdit(this); vp_path->setReadOnly(true); vp_path->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); vp_path->setTextMargins(5, 0, 0, 0); vp_open = new QPushButton("Open", this); vp_size = new QLineEdit(this); vp_size->setTextMargins(5, 0, 0, 0); vp_recheck = new QPushButton("Recheck", this); vp_size->setReadOnly(true); vp_size->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); vp_subsampling = new QLineEdit(this); vp_subsampling->setReadOnly(true); vp_subsampling->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); vp_subsampling->setTextMargins(5, 0, 0, 0); vp_tiledims = new QLineEdit(this); vp_tiledims->setReadOnly(true); vp_tiledims->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); vp_tiledims->setTextMargins(5, 0, 0, 0); // virtual pyramid RAM panel vp_ram_panel = new QGroupBox("RAM usage", this); #ifdef Q_OS_LINUX vp_ram_panel->setStyle(new QWindowsStyle()); #endif for(size_t i=0; i<vp_ram_max_size; i++) { vp_ram_labels.push_back(new QLabel(this)); vp_ram_used_labels.push_back(new QLabel(this)); vp_ram_bars.push_back(new QGradientBar(this)); vp_ram_clear_buttons.push_back(new QPushButton("Clear", this)); vp_ram_bars[i]->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); } vp_max_ram_spinbox = new QDoubleSpinBox(this); vp_max_ram_spinbox->setSuffix(" GB"); vp_max_ram_spinbox->setDecimals(1); vp_max_ram_spinbox->setMinimum(0.5); vp_max_ram_spinbox->setAlignment(Qt::AlignCenter); vp_max_ram_spinbox->setSingleStep(0.1); vp_ram_show_res_buttons = new QPushButton(this); vp_ram_show_res_buttons->setCheckable(true); /*** LAYOUT SECTION ***/ /* ---------------- info panel ------------------- */ QGridLayout* info_panel_layout = new QGridLayout(); QLabel* size_label = new QLabel("Size:"); size_label->setFixedWidth(80); info_panel_layout->addWidget(size_label, 0,0,1,1); info_panel_layout->addWidget(vol_size_field, 0,2,1,1); info_panel_layout->addWidget(new QLabel("Dims (mm):"), 1,0,1,1); info_panel_layout->addWidget(vol_dims_mm_field, 1,2,1,1); info_panel_layout->addWidget(new QLabel("Dims (vxl):"), 2,0,1,1); info_panel_layout->addWidget(vol_dims_vxl_field, 2,2,1,1); info_panel_layout->addWidget(new QLabel("Format:"), 3,0,1,1); info_panel_layout->addWidget(vol_format_field, 3,2,1,1); info_panel_layout->addWidget(voxel_dims_label, 4,0,1,1); info_panel_layout->addWidget(vxl_field, 4,2,1,1); info_panel_layout->addWidget(new QLabel("Origin (mm):"), 5,0,1,1); info_panel_layout->addWidget(org_field, 5,2,1,1); info_panel->setLayout(info_panel_layout); /* ----------- virtual pyramid panel ------------- */ QGridLayout* vp_layout = new QGridLayout(); QLabel* path_label = new QLabel("Path:"); path_label->setFixedWidth(70); vp_layout->addWidget(path_label, 0,0,1,1); vp_layout->addWidget(vp_path, 0,1,1,1); vp_layout->addWidget(vp_open, 0,2,1,1); vp_layout->addWidget(new QLabel("Size on disk:"), 1,0,1,1); vp_layout->addWidget(vp_size, 1,1,1,1); vp_layout->addWidget(vp_recheck, 1,2,1,1); vp_layout->addWidget(new QLabel("Layers:"), 2,0,1,1); vp_layout->addWidget(vp_subsampling, 2,1,1,2); vp_layout->addWidget(new QLabel("Block dims:"), 3,0,1,1); vp_layout->addWidget(vp_tiledims, 3,1,1,2); vp_panel->setLayout(vp_layout); /* ----------- allocated RAM panel --------------- */ QGridLayout* vp_RAM_layout = new QGridLayout(); vp_RAM_layout->addWidget(new QLabel("Set limit to:"), 0,0,1,1); vp_RAM_layout->addWidget(vp_max_ram_spinbox, 0,1,1,1); vp_ram_labels[0]->setFixedWidth(70); vp_RAM_layout->addWidget(vp_ram_labels[0], 1,0,1,1); vp_RAM_layout->addWidget(vp_ram_bars[0], 1,1,1,1); vp_RAM_layout->addWidget(vp_ram_used_labels[0], 1,2,1,1); vp_RAM_layout->addWidget(vp_ram_clear_buttons[0], 1,3,1,1); vp_RAM_layout->addWidget(new QWidget(this), 2,0,1,4); vp_RAM_layout->addWidget(vp_ram_show_res_buttons, 3,0,1,4); for(size_t i=1; i<vp_ram_max_size; i++) { vp_RAM_layout->addWidget(vp_ram_labels[i], i+3,0,1,1); vp_RAM_layout->addWidget(vp_ram_bars[i], i+3,1,1,1); vp_RAM_layout->addWidget(vp_ram_used_labels[i], i+3,2,1,1); vp_RAM_layout->addWidget(vp_ram_clear_buttons[i], i+3,3,1,1); } vp_ram_panel->setLayout(vp_RAM_layout); /* ---------------- MAIN LAYOUT ------------------ */ QVBoxLayout* pyramid_layout = new QVBoxLayout(); pyramid_layout->addWidget(vp_panel, 0); pyramid_layout->addWidget(vp_ram_panel, 0); pyramid_layout->addStretch(1); pyramid_layout->setContentsMargins(10,10,10,10); pyramid_tab->setLayout(pyramid_layout); QVBoxLayout* info_layout = new QVBoxLayout(); info_layout->addWidget(info_panel, 0); info_layout->addStretch(1); info_layout->setContentsMargins(10,10,10,10); info_tab->setLayout(info_layout); QVBoxLayout* layout = new QVBoxLayout(); tabs->addTab(pyramid_tab, "Virtual Pyramid"); tabs->addTab(info_tab, "Volume's info"); tabs->setContentsMargins(0,0,0,0); layout->addWidget(tabs); layout->setContentsMargins(0,0,0,0); setLayout(layout); #ifdef Q_OS_LINUX setStyle(new QWindowsStyle()); #endif updateTimer.setInterval(1000); updateTimer.start(); connect(vp_open, SIGNAL(clicked()), this, SLOT(open_button_clicked())); connect(vp_recheck, SIGNAL(clicked()), this, SLOT(recheck_button_clicked())); connect(&updateTimer, SIGNAL(timeout()), this, SLOT(update())); connect(vp_max_ram_spinbox, SIGNAL(valueChanged(double)), this, SLOT(ram_limit_changed(double))); connect(vp_ram_show_res_buttons, SIGNAL(toggled(bool)), this, SLOT(show_ram_layers_toggled(bool))); for(size_t i=0; i<vp_ram_clear_buttons.size(); i++) connect(vp_ram_clear_buttons[i], SIGNAL(clicked()), this, SLOT(clear_button_clicked())); }