Example #1
0
void ObjectEditorWidget::keyPressEvent( QKeyEvent *e )
{
	if ( (e->key() == Qt::Key_S)  && QApplication::keyboardModifiers() && Qt::ControlModifier)
    {
		saveCurrent();
	}
}
RemoteCommandConfigWidget::RemoteCommandConfigWidget(Transport* t, QWidget *parent) :
		QWidget(parent),
		ui(new Ui::RemoteCommandConfigWidget)
{
	Q_ASSERT(t);
	qDebug() << "RemoteCommandConfigWidget::RemoteCommandConfigWidget for" << t->getDescription();
	current = NULL;
	transport = t;
	ui->setupUi(this);

	connect(ui->commandTable, SIGNAL(clicked(QModelIndex)), this, SLOT(commandTableClicked(QModelIndex)));
	connect(ui->saveCommandButton, SIGNAL(clicked()), this, SLOT(saveCurrent()));
	connect(ui->addCommandButton, SIGNAL(clicked()), this, SLOT(addNewCommand()));
	connect(ui->removeCommandButton, SIGNAL(clicked()), this, SLOT(deleteCurrent()));
	connect(ui->testCommandButton, SIGNAL(clicked()), this, SLOT(testCurrent()));

	connect(ui->commandEdit, SIGNAL(textEdited(QString)), this, SLOT(madeUpdate()));
	connect(ui->timeoutSpin, SIGNAL(valueChanged(int)), this, SLOT(madeUpdate()));
	connect(ui->reconnectCheck, SIGNAL(toggled(bool)), this, SLOT(madeUpdate()));
	connect(ui->retiesSpin, SIGNAL(valueChanged(int)), this, SLOT(madeUpdate()));

	model.setHorizontalHeaderLabels(QStringList() << "Section" << "Remote Command Description");
	ui->commandTable->setModel(&model);
	ui->commandTable->horizontalHeader()->setStretchLastSection(true);

	populateTable();

	if (model.rowCount()>0)
	{
		ui->commandTable->selectRow(0);
		commandTableClicked(ui->commandTable->currentIndex());
	}
}
void EditStaffType::accept()
      {
      QListWidgetItem* item = staffTypeList->currentItem();
      if (item)
            saveCurrent(item);
      QDialog::accept();
      }
Example #4
0
void toEditExtensionSetup::changed(void)
{
    if (Started)
    {
        saveCurrent();
        try
        {
            Example->setText(toSQLParse::indent(Example->text(), Example->analyzer()));
        }
        TOCATCH;
    }
}
void EditStaffType::typeChanged(QListWidgetItem* n, QListWidgetItem* o)
      {
      if (n == 0)
            return;
      if (o)
            saveCurrent(o);
      // retrieve staff type corresponding to new current item in type list
      int idx = n->data(Qt::UserRole).toInt();
      StaffType* st = staffTypes[idx];

      // switch to stack page and set props specific to each staff group

      switch(st->group()) {
            case STANDARD_STAFF_GROUP:
                  {
                  StaffTypePitched* ps = static_cast<StaffTypePitched*>(st);
                  stack->setCurrentIndex(0);
                  name->setText(st->name());
                  lines->setValue(st->lines());
                  lineDistance->setValue(st->lineDistance().val());
                  genClef->setChecked(st->genClef());
                  showBarlines->setChecked(st->showBarlines());
                  genTimesig->setChecked(st->genTimesig());
                  genKeysigPitched->setChecked(ps->genKeysig());
                  showLedgerLinesPitched->setChecked(ps->showLedgerLines());
                  stemlessPitched->setChecked(st->slashStyle());
                  }
                  break;

            case TAB_STAFF_GROUP:
                  {
                  StaffTypeTablature* stt = static_cast<StaffTypeTablature*>(st);
                  blockTabPreviewSignals(true);
                  setDlgFromTab(stt);
                  name->setText(stt->name());   // setDlgFromTab() does not copy the name and it shouldn't
                  stack->setCurrentIndex(1);
                  blockTabPreviewSignals(false);
                  }
                  break;

            case PERCUSSION_STAFF_GROUP:
                  {
                  StaffTypePercussion* ps = static_cast<StaffTypePercussion*>(st);
                  blockPercPreviewSignals(true);
                  setDlgFromPerc(ps);
                  name->setText(ps->name());   // setDlgFromPerc() does not copy the name and it shouldn't
                  stack->setCurrentIndex(2);
                  blockPercPreviewSignals(false);
                  }
                  break;
            }
      }
Example #6
0
void DialogMultisave::save()
{
    ASSERT(multiplicity()>0);
    switch(currentSaveModeIdx.val()) {
    case 0:
        saveCurrent();
        break;
    case 1:
        saveJointfile();
        break;
    case 2:
        saveMultifile();
        break;
    default:
        qFatal("impossible case %d in DialogMultisave::save()", currentSaveModeIdx.val());
    }
}
Example #7
0
void ObjectEditorWidget::changingSelection()
{
	if( objectList->currentRow() != -1 )
	{
		std::cout << "Changing Selection: " << objectList->currentRow() << " -- " << objectList->currentItem()->text().toStdString() << std::endl;
	
		if( editingIndex != objectList->currentRow() )
		{
			bool followThrough = true;
			if( hasChanged )
			{
				QMessageBox msgBox;
				msgBox.setWindowTitle("Unsaved Changes");
				msgBox.setText("Would you like to save the current object?");
				msgBox.setStandardButtons(QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel);
				msgBox.setDefaultButton(QMessageBox::Yes);
				int result = msgBox.exec();
				if( result == QMessageBox::Yes )
				{
					saveCurrent();
				}
				if( result == QMessageBox::Cancel )
				{
					followThrough = false;
				}
			}
			if( followThrough )
			{
				editingIndex = objectList->currentRow();
				display( StructureObject::load( objectList->currentItem()->text().toStdString() ) );
				hasChanged = false;
			}
			else
			{
				objectList->setCurrentRow( editingIndex );
			}
		}
	}

	if( editingIndex == -1 )
	{
		hide();
	}
}
DataDisplayEditorForm::DataDisplayEditorForm(QWidget *parent) :
		QWidget(parent),
		ui(new Ui::DataDisplayEditorForm),
		current(NULL)
{
	ui->setupUi(this);


	connect(ui->displayTable, SIGNAL(clicked(QModelIndex)), this, SLOT(displayTableClicked(QModelIndex)));
	connect(ui->saveButton, SIGNAL(clicked()), this, SLOT(saveCurrent()));
	connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addNewDataDisplay()));
	connect(ui->removeButton, SIGNAL(clicked()), this, SLOT(deleteCurrent()));
	connect(ui->testButton, SIGNAL(clicked()), this, SLOT(testCurrent()));
        connect(&GnosticApp::getInstance(), SIGNAL(configUpdated(GnosticApp::ConfigType)), this, SLOT(externalUpdate(GnosticApp::ConfigType)));

	model.setHorizontalHeaderLabels(QStringList() << "Section" << "Display Description");
	ui->displayTable->setModel(&model);
	ui->displayTable->horizontalHeader()->setStretchLastSection(true);
	populateTable();

	ui->saveButton->setEnabled(false);
}
Example #9
0
XSLExpress::XSLExpress(QWidget *parent)
    : QWidget(parent),
      ui(new Ui::XSLExpressClass)
{
    ui->setupUi(this);

    mSettings = new QSettings("AdamBaker","XSLExpress");

    setParameterBoxVisibility();

    populateCombo();

    connect( ui->process, SIGNAL(clicked()), this, SLOT(process()) );
    connect( ui->inputFiles, SIGNAL(drop()), this, SLOT(autoProcess()) );
    connect( ui->saveCurrent, SIGNAL(clicked()), this, SLOT(saveCurrent()) );
    connect( ui->deleteCurrent, SIGNAL(clicked()), this, SLOT(deleteCurrent()) );
    connect( ui->savedSettings, SIGNAL(currentIndexChanged(QString)), this, SLOT(settingsChosen(QString)) );
    connect( ui->getParametersWithDefaults, SIGNAL(clicked()), this, SLOT(loadParametersWithDefaults()));
    connect( ui->clearValues, SIGNAL(clicked()), this, SLOT(clearValues()) );
    connect( ui->xslFile, SIGNAL(textChanged(QString)), this, SLOT(loadParametersWithDefaults()) );
    connect( ui->copyButton, SIGNAL(clicked(bool)), this, SLOT(copyCall()) );
}
//应用程式的主菜单:显示
int menuShow()
{
	//变量定义表
	uint MenuItem=1;

    scrcls();
	
	puts("<=-------------------------------------=>");
	puts("         小 学 数 学 考 试 系 统");
	puts("        Designed by www.fcsys.us.");
	puts("<=-------------------------------------=>");
	puts("       [1]随机生成10数学试题");
	puts("       [2]开始进行本次数学考试");
	puts("       [3]保存本次数学考试记录");
	puts("       [4]查询历史数学考试记录");
	puts("       [5]当次前次考试成绩对比");
	puts("       [6]保存考试成绩到文件中");
	puts("       [7]退出小学数学考试系统");
	puts("<=-------------------------------------=>");
	printf("\n请输入当前的选择项目[1-7限定]:");

	//处理用户输入选项
	scanf("%d",&MenuItem);
	if(MenuItem>7||MenuItem<1)
		menuShow();				//0:控制重新显示菜单
	else
		switch(MenuItem)		//N:控制菜单执行
		{
			case 1:genItem();break;
			case 2:doWork();break;
			case 3:saveCurrent(0);break;
			case 4:viewHistory(0);break;
			case 5:viewAll();break;
			case 6:saveAll();break;
			case 7:exit(0);
		}
	return 0;
}
Example #11
0
ObjectEditorWidget::ObjectEditorWidget()
{
	this->setLayout( new QHBoxLayout() );

	QWidget * objectListContainer = new QWidget;
	objectListContainer->setLayout( new QVBoxLayout );

	objectListContainer->layout()->addWidget( new QLabel( "Objects" ) );

	objectList = new ObjectListWidget();
	objectList->refreshList();

	connect( objectList->selectionModel(), &QItemSelectionModel::selectionChanged, [this](){ this->changingSelection(); } );


	objectListContainer->setFixedWidth( 150 );

	objectListContainer->layout()->addWidget( objectList );

	QPushButton * newObjButt = new QPushButton( "New" );
	connect( newObjButt, &QPushButton::clicked, [this](){
		bool ok;
		QString s = QInputDialog::getText(this, tr("New Object"), tr("Name:"), QLineEdit::Normal, tr( "NewObject" ), &ok);
		if (ok && !s.isEmpty())
		{
			StructureObject obj;
			obj.name = s.toStdString();
			display( obj );
			saveCurrent();
			objectList->refreshList();
			hasChanged = false;
			objectList->seekObject( s );
		}
	} );
	objectListContainer->layout()->addWidget( newObjButt );

	QPushButton * deleteObjButt = new QPushButton( "Delete" );
	connect( deleteObjButt, &QPushButton::clicked, [this](){
		if( objectList->currentRow() != -1 )
		{
			QMessageBox msgBox;
			msgBox.setWindowTitle("Deleting Object");
			msgBox.setText("Are you sure you want to delete the object \"" + objectList->item( objectList->currentRow() )->text() + "\"?");
			msgBox.setStandardButtons(QMessageBox::Yes|QMessageBox::No);
			msgBox.setDefaultButton(QMessageBox::No);
			int result = msgBox.exec();
			if( result == QMessageBox::Yes )
			{
				remove( ( "Assets/objs/" + ( objectList->item( objectList->currentRow() )->text() + ".rpobj" ).toStdString() ).c_str() );
				editingIndex = -1;
				objectList->selectionModel()->reset();
				objectList->refreshList();				
				hide();
			}
		}
	} );
	objectListContainer->layout()->addWidget( deleteObjButt );

	this->layout()->addWidget( objectListContainer ); //Existing objects widget

	noObjectSelected = new QWidget();
	noObjectSelected->setLayout( new QVBoxLayout() );
	noObjectSelected->layout()->setAlignment( Qt::AlignHCenter );
	noObjectSelected->layout()->addWidget( new QLabel( "No object has been selected for editing" ) );
	QFont nf("Tahoma");
	nf.setPixelSize( 24 );
	noObjectSelected->setFont( nf );
	this->layout()->addWidget( noObjectSelected );

	currentObjectContainer = new QSplitter( Qt::Vertical );
	//currentObjectContainer->setLayout( new QVBoxLayout );

	QWidget * currentObjectEditorContainer = new QWidget;
	currentObjectEditorContainer->setLayout( new QVBoxLayout );

	nameEditor = new QLineEdit;
	QFont lf("Tahoma");
	lf.setPixelSize( 24 );
	nameEditor->setFont(lf);
	nameEditor->setMaximumWidth( 320 );
	connect( nameEditor, &QLineEdit::textEdited, [this](){ hasChanged = true; } );
	currentObjectEditorContainer->layout()->addWidget( nameEditor );

	codeEditTabs = new QTabWidget();

	const char * signatures[] = { "subsetRayMarch( x, y, z, out r, out g, out b ) : boolean", "distanceRayMarch( x, y, z, out r, out g, out b ) : number", "rayTrace( x, y, z, dx, dy, dy, out dist, out r, out g, out b ) : boolean" };

	for( int i = 0; i < 3; i++ )
	{
		QWidget * de = new QWidget;
		de->setLayout( new QVBoxLayout );

	
		QCheckBox * check = new QCheckBox;
		check->setChecked( false );
		check->setText( "Enabled" );
		de->layout()->addWidget( check );

	
		de->layout()->addWidget( new QLabel( signatures[i] ) );

		CodeEditWidget * edit = new CodeEditWidget();
		de->layout()->addWidget( edit );
		edit->setEnabled( false );
		connect( edit, &QTextEdit::textChanged, [this](){ hasChanged = true; } );

		connect( check, &QCheckBox::stateChanged, [edit, check](){ edit->setEnabled( check->isChecked() ); } );
		connect( check, &QCheckBox::clicked, [this](){ hasChanged = true; } );

		codeEditTabs->addTab( de, tr("Test"));
	}

	codeEditTabs->setTabText(0, "Subset Ray Marching" );
	codeEditTabs->setTabText(1, "Distance Estimated Ray Marching" );
	codeEditTabs->setTabText(2, "Absolute Ray Tracing" );

	//QObject::connect(
	//connect( check, SIGNAL( stateChanged( int ) ), [edit](int state){ edit->setEnabled( state == 0 ); } );


	currentObjectEditorContainer->layout()->addWidget( codeEditTabs ); 

	QSplitter * horizontalBottomBar = new QSplitter( Qt::Horizontal );
	//horizontalBottomBar->setLayout( new QHBoxLayout );

	currentObjectContainer->addWidget( currentObjectEditorContainer );

	
	horizontalBottomBar->setFixedHeight( 256 );

	QWidget * previewVerticalContainer = new QWidget;
	previewVerticalContainer->setLayout( new QVBoxLayout );

	QLabel * prevLabel = new QLabel( "Preview" );
	prevLabel->setFixedHeight( 24 );
	previewVerticalContainer->layout()->addWidget( prevLabel ); 
	NewRayMarchWidget * march = new NewRayMarchWidget( 256, 256 );
		NewRayMarchCL * under = new NewRayMarchCL();
		under->initialize();
		march->gpu = under;
	
	previewVerticalContainer->layout()->addWidget( march ); //preview
	march->init();

	//previewVerticalContainer->setFixedWidth( 256 );

	QWidget * previewButtonBar = new QWidget;
	previewButtonBar->setFixedHeight( 38 );
	previewButtonBar->setLayout( new QHBoxLayout );
	previewButtonBar->layout()->setAlignment( Qt::AlignHCenter );

	//Making the parser
	ScriptParser * parser = ScriptParser::makeRegular();

	QPushButton * compButt = new QPushButton( "Compile Selected" );
	connect( compButt, &QPushButton::clicked, [this,parser,march](){
		console->log( "Parsing started" );
		Block * script = parser->parse( this->codeEditTabs->currentWidget()->findChild<QTextEdit*>()->toPlainText().toStdString() );
		console->log( "Parsing ended" );
		console->log( "Compiling started" );

		std::string outlets = "";

		try
		{
			for( int i = 0; i < this->outlets->rowCount(); i++ )
			{
				outlets += ( "frac " + this->outlets->getName( i ) + " = " + std::to_string( this->outlets->getValue( i ) ).c_str() + ";" ).toStdString();
				script->variablesInScope[ this->outlets->getName( i ).toStdString() ] = VariablePacket( Value() );
			}

			if( ( this->codeEditTabs->currentIndex() ) == 0 )
			{
				script->variablesInScope[ "x" ] = VariablePacket( Value() );
				script->variablesInScope[ "y" ] = VariablePacket( Value() );
				script->variablesInScope[ "z" ] = VariablePacket( Value() );
				script->variablesInScope[ "r" ] = VariablePacket( Value(), true );
				script->variablesInScope[ "g" ] = VariablePacket( Value(), true );
				script->variablesInScope[ "b" ] = VariablePacket( Value(), true );

				std::ifstream if_a("Assets/clparts/clheader.cl", std::ios_base::binary);
				std::ifstream if_b("Assets/clparts/clfootergutsSUBSET.cl", std::ios_base::binary);
				std::ofstream of_c("Assets/temp/testAll.cl", std::ios_base::binary);

				std::string output = parser->textOf( script, 0, true );

				of_c << if_a.rdbuf() << "bool subsetFunction( frac x, frac y, frac z, frac * r, frac * g, frac * b ){ " << outlets << output << "}" << if_b.rdbuf();
				of_c.close();

				march->load( "Assets/temp/testAll.cl" );
			}
			else
			if( ( this->codeEditTabs->currentIndex() ) == 1 )
			{
				script->variablesInScope[ "x" ] = VariablePacket( Value() );
				script->variablesInScope[ "y" ] = VariablePacket( Value() );
				script->variablesInScope[ "z" ] = VariablePacket( Value() );
				script->variablesInScope[ "r" ] = VariablePacket( Value(), true );
				script->variablesInScope[ "g" ] = VariablePacket( Value(), true );
				script->variablesInScope[ "b" ] = VariablePacket( Value(), true );

				std::ifstream if_a("Assets/clparts/clheader.cl", std::ios_base::binary);
				std::ifstream if_b("Assets/clparts/clfooterguts.cl", std::ios_base::binary);
				std::ofstream of_c("Assets/temp/testAll.cl", std::ios_base::binary);

				std::string output = parser->textOf( script, 0, true );

				of_c << if_a.rdbuf() << "frac distanceFunction( frac x, frac y, frac z, frac * r, frac * g, frac * b, __global const float* sceneVarData ){ " << outlets << output << "}" << if_b.rdbuf();
				of_c.close();

				march->load( "Assets/temp/testAll.cl" );
			}
			else
			if( ( this->codeEditTabs->currentIndex() ) == 2 )
			{
				script->variablesInScope[ "x" ] = VariablePacket( Value() );
				script->variablesInScope[ "y" ] = VariablePacket( Value() );
				script->variablesInScope[ "z" ] = VariablePacket( Value() );
				script->variablesInScope[ "dx" ] = VariablePacket( Value() );
				script->variablesInScope[ "dy" ] = VariablePacket( Value() );
				script->variablesInScope[ "dz" ] = VariablePacket( Value() );
				script->variablesInScope[ "r" ] = VariablePacket( Value(), true );
				script->variablesInScope[ "g" ] = VariablePacket( Value(), true );
				script->variablesInScope[ "b" ] = VariablePacket( Value(), true );
				script->variablesInScope[ "dist" ] = VariablePacket( Value(), true );

				std::ifstream if_a("Assets/clparts/clheader.cl", std::ios_base::binary);
				std::ifstream if_b("Assets/clparts/clfootergutsTRACE.cl", std::ios_base::binary);
				std::ofstream of_c("Assets/temp/testAll.cl", std::ios_base::binary);

				std::string output = parser->textOf( script, 0, true );

				of_c << if_a.rdbuf() << "bool traceFunction( frac x, frac y, frac z, frac dx, frac dy, frac dz, frac * r, frac * g, frac * b, frac * dist ){ " << outlets << output << "}" << if_b.rdbuf();
				of_c.close();

				march->load( "Assets/temp/testAll.cl" );
			}
		}
		catch( char * error )
		{
			console->log( ( "UNEXPECTED COMPILATION ERROR: " + std::string( error ) ).c_str(), ConsoleWidget::MESSAGE_TYPE::MSG_DIREERROR );
		}
		console->log( "Compiling ended" );
	} );
	previewButtonBar->layout()->addWidget( compButt );
	QPushButton * viewButt = new QPushButton( "Reset View" );
	connect( viewButt, &QPushButton::clicked, [march](){ march->reset(); } );
	previewButtonBar->layout()->addWidget( viewButt );

	previewVerticalContainer->layout()->addWidget( previewButtonBar ); //preview

	horizontalBottomBar->addWidget( previewVerticalContainer );

	QWidget * consoleVerticalContainer = new QWidget;
	consoleVerticalContainer->setLayout( new QVBoxLayout );
	consoleVerticalContainer->setMinimumWidth( 256 );

	consoleVerticalContainer->layout()->addWidget( new QLabel( "Console" ) ); 

	console = new ConsoleWidget;

	consoleVerticalContainer->layout()->addWidget( console ); 

	horizontalBottomBar->addWidget( consoleVerticalContainer );

	currentObjectContainer->addWidget( horizontalBottomBar );

	
	this->layout()->addWidget( currentObjectContainer );//Script edit widget
	currentObjectContainer->setVisible( false );

	outletContainer = new QWidget;
	outletContainer->setLayout( new QVBoxLayout );

	outletContainer->layout()->addWidget( new QLabel( "Outlets" ) );

	outlets = new ValueTableWidget();

	outletContainer->setFixedWidth( 150 );

	outletContainer->layout()->addWidget( outlets );

	QPushButton * addButt = new QPushButton( "Add" );
	connect( addButt, &QPushButton::clicked, [this](){
		outlets->addFullRow();
		hasChanged = true;
	} );
	outletContainer->layout()->addWidget( addButt );

	QPushButton * deleteButt = new QPushButton( "Delete" );
	connect( deleteButt, &QPushButton::clicked, [this](){
		if( outlets->currentRow() != -1 )
		{
			QMessageBox msgBox;
			msgBox.setWindowTitle("Deleting outlet");
			msgBox.setText("Are you sure you want to delete the outlet \"" + outlets->getName( outlets->currentRow() ) + "\"?");
			msgBox.setStandardButtons(QMessageBox::Yes|QMessageBox::No);
			msgBox.setDefaultButton(QMessageBox::No);
			int result = msgBox.exec();
			if( result == QMessageBox::Yes )
			{
				outlets->removeRow( outlets->currentRow() );
				hasChanged = true;
			}
		}
	} );
	outletContainer->layout()->addWidget( deleteButt );

	this->layout()->addWidget( outletContainer ); //Outlet widget
	hasChanged = false;
	editingIndex = -1;
	hide();
}