Esempio n. 1
0
void
SimpleVisApp::openFile(const QString &filename)
{
    if(!filename.isEmpty())
    {
        // Open the file.
        viewer->Methods()->OpenDatabase(filename.toStdString());

        // Get the file's metadata and populate the variable list.
        const avtDatabaseMetaData *md = viewer->GetMetaData(filename.toStdString());
        if(md != 0)
        {
            variables->blockSignals(true);
            for(int i = 0; i < md->GetNumScalars(); ++i)
                variables->addItem(md->GetScalar(i)->name.c_str());
            variables->setCurrentRow(0);
            variables->blockSignals(false);
            if(md->GetNumScalars() > 0)
            {
                variables->setEnabled(true);
                plotTypeWidget->setEnabled(true);
                contourWidget->setEnabled(plotType->checkedId() == 1);
                // Add a plot of the first variable
                changePlotType(plotType->checkedId());
            }
            scalarLabel->setEnabled(true);
            variables->setEnabled(true);
        }
        else
            resetWindow();
    }
    else
        resetWindow();
}
//End of calcDimen() routine
void drawText(char*txt)
{
	resetWindow();
	setcolor(WHITE);
	clearviewport();
	outtextxy(2, 2, txt);
}
//Beginning of initGraphics proceedure. This initializes the graphics window and the arrays used in graphical operations
void initGraphics(struct graphicWindow*dimenPtr, soil_palette*soilPalette)
{
	//Draws graphics window, based on X range in pixels(+200px border for legend) and Y range in px
	initwindow((int)dimenPtr->rangeXScale + 200, (int)dimenPtr->rangeYScale);
	resetWindow();
	drawText("Enter a depth in the console to see the soil info. at that depth.");
	initSoilClr(soilPalette);
	initSoilStr(soilPalette);
	initSoilType(soilPalette);
}
Esempio n. 4
0
// Process a flow's timeout event
void nsHostManager::timeoutEvent(nsFlow *flow, double now)
{
	if (now >= flow->s_timeout) {
		cout << std::fixed << std::setprecision(3) << now << " Send: Timeout Sequence [" << flow->s_base << "]" << endl;
		if (now != flow->start) {
			resetWindow(flow);
			eraseWindow(flow);
		}
		sendPacket(flow, now, true);
	}
}
Esempio n. 5
0
void
MultiWindowVisApp::openFile(const QString &filename)
{
    if(!filename.isEmpty())
    {
        activeFile = filename;
        resetWindow();

        // Get the file's metadata and populate the variable list.
        const avtDatabaseMetaData *md = viewer->GetMetaData(filename.toStdString());
        if(md != 0)
        {
            variables->blockSignals(true);
            for(int i = 0; i < md->GetNumScalars(); ++i)
                variables->addItem(md->GetScalar(i)->name.c_str());
            variables->blockSignals(false);
            variables->setEnabled(md->GetNumScalars() > 0);
        }
    }
}
Esempio n. 6
0
void availableRoomsWindow::login()
{
    hide();
#ifndef NOLOGIN
    //login window
    int result = loginDlg->exec();
    if(1 != result)
    {
        qDebug() << "Unsuccessfull login";
        close();
    }
    else
#else
    parameters->loggedInUser = "******";
    parameters->isAdmin = true;
#endif
    {
        resetWindow();
        show();
    }
}
Esempio n. 7
0
SimpleVisApp::SimpleVisApp(VisItViewer *v, int *argc, char ***argv)
    : QMainWindow()
{
    viewer = v;
    setWindowTitle(tr("Simple visualization"));
    plotType = 0;

    // Create the window.
    QWidget *central = new QWidget(this);
    setCentralWidget(central);

    QHBoxLayout *hLayout = new QHBoxLayout(central);
    hLayout->setMargin(10);
    hLayout->setSpacing(10);
    QVBoxLayout *leftLayout = new QVBoxLayout(0);
    leftLayout->setSpacing(10);
    hLayout->addLayout(leftLayout);

    scalarLabel = new QLabel(tr("Scalar variables"), central);
    leftLayout->addWidget(scalarLabel);

    variables = new QListWidget(central);
    leftLayout->addWidget(variables);
    connect(variables, SIGNAL(currentTextChanged(const QString &)),
            this, SLOT(changeVariable(const QString &)));

    plotTypeWidget = new QWidget(central);
    leftLayout->addWidget(plotTypeWidget);
    QHBoxLayout *ptLayout = new QHBoxLayout(plotTypeWidget);
    ptLayout->setSpacing(10);
    ptLayout->addWidget(new QLabel(tr("Plot type"), plotTypeWidget));
    plotType = new QButtonGroup(plotTypeWidget);
    QRadioButton *rb = new QRadioButton(tr("Pseudocolor"), plotTypeWidget);
    plotType->addButton(rb, 0);
    ptLayout->addWidget(rb);
    rb = new QRadioButton(tr("Contour"), plotTypeWidget);
    plotType->addButton(rb, 1);
    ptLayout->addWidget(rb);
    connect(plotType, SIGNAL(buttonClicked(int)),
            this, SLOT(changePlotType(int)));

    contourWidget = new QWidget(central);
    leftLayout->addWidget(contourWidget);
    QHBoxLayout *cLayout = new QHBoxLayout(contourWidget);
    cLayout->setSpacing(10);
    nContours = new QSpinBox(contourWidget);
    nContours->setRange(1,40);
    nContours->setValue(10);
    connect(nContours, SIGNAL(valueChanged(int)),
            this, SLOT(setNContours(int)));
    cLayout->addWidget(new QLabel(tr("Number of contours"), contourWidget));
    cLayout->addWidget(nContours);

    // Create the vis window directly.
    viswin = new vtkQtRenderWindow(central);
    viswin->setMinimumSize(QSize(500,500));
    hLayout->addWidget(viswin, 100);

    // Create menus
    QMenu *fileMenu = menuBar()->addMenu(tr("File"));
    fileMenu->addAction(tr("Open . . ."), this, SLOT(selectFile()));
    fileMenu->addAction(tr("Open commands. . ."), this, SLOT(execFile()));
    fileMenu->addSeparator();
    fileMenu->addAction(tr("Save window"), this, SLOT(saveWindow()));
    fileMenu->addSeparator();
    fileMenu->addAction(tr("Quit"), this, SLOT(quitApp()));
    
    QMenu *controlsMenu = menuBar()->addMenu(tr("Controls"));
    controlsMenu->addAction(tr("Open GUI"), this, SLOT(openGUI()));

    //
    // Register a window creation function (before Setup) that will
    // return the vtkQtRenderWindow objects that we've already
    // parented into our interface.
    //
    viewer->SetWindowCreationCallback(ReturnVisWin, (void *)this);

    // Set the initial widget sensitivity.
    resetWindow();

    cmd = 0;

    if (*argc > 1)
        clfilename = (*argv)[1];
}
Esempio n. 8
0
// Receives a packet from a link (data or ack)
void nsHostManager::recvPacket(nsPacket * packet, double now)
{
	if (packet->pac_type == TCP_DATA) {
		nsFlow *flow = packet->flow;
		
		if (packet->tcp_seq >= flow->r_base)
			flow->r_frames[packet->tcp_seq] = TCP_RECV;

		nsPacket *r = nsPacketFactory::Object()->createAckPacket(packet->flow);
		r->tcp_ack = flow->r_base;
		r->transmitTime = packet->transmitTime;

		while (flow->r_frames[r->tcp_ack] == TCP_RECV) {
			//flow->r_frames.erase(r->tcp_ack);
			r->tcp_ack++;
		}

		// Gets the amount of data recieved and size of ACK packet sent and puts them in corresponding variables for the host
		nsHost * host = getHost(packet->ip_dst);
		host->receivedBytes += packet->pac_size;
		host->sentBytes += r->pac_size;

		if (flow->r_base > packet->tcp_seq)
			return;

		flow->r_base = r->tcp_ack;

		cout << std::fixed << std::setprecision(3) << now << " Recv: Received Packet [" << packet->tcp_seq << "], Sending Ack [" << flow->r_base << "]" << endl;

		nsLinkManager::Object()->queuePacket(r, now);
	}
	if (packet->pac_type == TCP_ACK) {
		nsFlow *flow = packet->flow;
		// Update the recieved packets for the host recieving ACK
		nsHost * host = getHost(packet->ip_dst);
		host->receivedBytes += packet->pac_size;

		cout << std::fixed << std::setprecision(3) << now << " Send: Received Ack [" << packet->tcp_ack << "]" << endl;
		// Update window
		if (packet->tcp_ack > flow->s_base) {
			if (flow->bytesRemaining != 0)
				flow->bytesRemaining -= (packet->tcp_ack - flow->s_base) * 1000;
			flow->s_base = packet->tcp_ack;
			// Calculate RTT
			double currRTT = now - packet->transmitTime;
			packet->flow->s_rtt = packet->flow->alpha * packet->flow->s_rtt + (1 - packet->flow->alpha) * currRTT; // RTT(i) = a * RTT(i - 1) + (1 - a) * currRTT
			// Set whatever received as first RTT
			if (packet->flow->s_first_rtt) {
				packet->flow->s_first_rtt = false;
				packet->flow->s_rtt = currRTT;
			}
			// Window updates for every window number of packets
			if (flow->s_base > flow->s_next_window_update || flow->s_next_window_update == 0) {
				if (flow->getWindow() < flow->getThresh())
					flow->s_window *= 2;
				else
					flow->s_window += 1;
				flow->s_next_window_update = flow->s_base + flow->getWindow();
				cout << std::fixed << std::setprecision(3) << now << " Send: Update Window Size To [" << flow->s_base + flow->s_window << "]" << endl;;
			}
			// Window updates for every received ACK
			if (flow->getWindow() < flow->getThresh())
				flow->s_window += 1;
			else
				flow->s_window += 1 / flow->s_window;
		}
		// Triple duplicate ack
		if (flow->s_ack_num != packet->tcp_ack) {
			flow->s_ack_num = packet->tcp_ack;
			flow->s_ack_count = 1;
			flow->s_ack_good = true;
		} else {
			flow->s_ack_count++;
			if (flow->s_ack_count >= 3 && flow->s_ack_good) {
				cout << std::fixed << std::setprecision(3) << now << " Triple Duplicate Ack" << endl;
				flow->s_ack_count = 0;
				// Fast recovery
				resetWindow(flow);
				if (flow->type == TCP_TAHOE)
					flow->s_window = 1;
				eraseWindow(flow);
				flow->s_ack_good = false;
			}
		}
		// Transmit more
		sendPacket(packet->flow, now, false);
	}
}