Exemplo n.º 1
0
TabbedComponent::~TabbedComponent()
{
    clearTabs();
    tabs = nullptr;
}
Exemplo n.º 2
0
 void CbcRegistersTab::reset()
 {
     clearTabs();
 }
TabbedComponent::~TabbedComponent()
{
    clearTabs();
    tabs.reset();
}
VstPluginWindowTabPanel::~VstPluginWindowTabPanel ()
{
    DBG ("VstPluginWindowTabPanel::~VstPluginWindowTabPanel");

    clearTabs ();
}
Exemplo n.º 5
0
void TabPanel::removeAllTabs(void)
{
    clearChildren();
    clearTabs();
    clearTabContents();
}
Exemplo n.º 6
0
void QgsEditFormConfig::readXml( const QDomNode& node )
{
  QDomNode editFormNode = node.namedItem( "editform" );
  if ( !editFormNode.isNull() )
  {
    QDomElement e = editFormNode.toElement();
    mUiFormPath = QgsProject::instance()->readPath( e.text() );
  }

  QDomNode editFormInitNode = node.namedItem( "editforminit" );
  if ( !editFormInitNode.isNull() )
  {
    mInitFunction = editFormInitNode.toElement().text();
  }

  QDomNode editFormInitCodeSourceNode = node.namedItem( "editforminitcodesource" );
  if ( !editFormInitCodeSourceNode.isNull() || ( !editFormInitCodeSourceNode.isNull() && !editFormInitCodeSourceNode.toElement().text().isEmpty() ) )
  {
    setInitCodeSource( static_cast< QgsEditFormConfig::PythonInitCodeSource >( editFormInitCodeSourceNode.toElement().text().toInt() ) );
  }

  QDomNode editFormInitCodeNode = node.namedItem( "editforminitcode" );
  if ( !editFormInitCodeNode.isNull() )
  {
    setInitCode( editFormInitCodeNode.toElement().text() );
  }

  // Temporary < 2.12 b/w compatibility "dot" support patch
  // @see: https://github.com/qgis/QGIS/pull/2498
  // For b/w compatibility, check if there's a dot in the function name
  // and if yes, transform it in an import statement for the module
  // and set the PythonInitCodeSource to CodeSourceDialog
  int dotPos = mInitFunction.lastIndexOf( '.' );
  if ( dotPos >= 0 ) // It's a module
  {
    setInitCodeSource( QgsEditFormConfig::CodeSourceDialog );
    setInitCode( QString( "from %1 import %2\n" ).arg( mInitFunction.left( dotPos ), mInitFunction.mid( dotPos + 1 ) ) );
    setInitFunction( mInitFunction.mid( dotPos + 1 ) );
  }

  QDomNode editFormInitFilePathNode = node.namedItem( "editforminitfilepath" );
  if ( !editFormInitFilePathNode.isNull() || ( !editFormInitFilePathNode.isNull() && !editFormInitFilePathNode.toElement().text().isEmpty() ) )
  {
    setInitFilePath( QgsProject::instance()->readPath( editFormInitFilePathNode.toElement().text() ) );
  }

  QDomNode fFSuppNode = node.namedItem( "featformsuppress" );
  if ( fFSuppNode.isNull() )
  {
    mSuppressForm = QgsEditFormConfig::SuppressDefault;
  }
  else
  {
    QDomElement e = fFSuppNode.toElement();
    mSuppressForm = static_cast< QgsEditFormConfig::FeatureFormSuppress >( e.text().toInt() );
  }

  // tab display
  QDomNode editorLayoutNode = node.namedItem( "editorlayout" );
  if ( editorLayoutNode.isNull() )
  {
    mEditorLayout = QgsEditFormConfig::GeneratedLayout;
  }
  else
  {
    if ( editorLayoutNode.toElement().text() == "uifilelayout" )
    {
      mEditorLayout = QgsEditFormConfig::UiFileLayout;
    }
    else if ( editorLayoutNode.toElement().text() == "tablayout" )
    {
      mEditorLayout = QgsEditFormConfig::TabLayout;
    }
    else
    {
      mEditorLayout = QgsEditFormConfig::GeneratedLayout;
    }
  }

  // tabs and groups display info
  clearTabs();
  QDomNode attributeEditorFormNode = node.namedItem( "attributeEditorForm" );
  QDomNodeList attributeEditorFormNodeList = attributeEditorFormNode.toElement().childNodes();

  for ( int i = 0; i < attributeEditorFormNodeList.size(); i++ )
  {
    QDomElement elem = attributeEditorFormNodeList.at( i ).toElement();

    QgsAttributeEditorElement *attributeEditorWidget = attributeEditorElementFromDomElement( elem, this );
    addTab( attributeEditorWidget );
  }


  //// TODO: MAKE THIS MORE GENERIC, SO INDIVIDUALL WIDGETS CAN NOT ONLY SAVE STRINGS
  /// SEE QgsEditorWidgetFactory::writeConfig

  QDomElement widgetsElem = node.namedItem( "widgets" ).toElement();

  QDomNodeList widgetConfigsElems = widgetsElem.childNodes();

  for ( int i = 0; i < widgetConfigsElems.size(); ++i )
  {
    QgsEditorWidgetConfig cfg;

    QDomElement wdgElem = widgetConfigsElems.at( i ).toElement();

    QDomElement cfgElem = wdgElem.namedItem( "config" ).toElement();

    for ( int j = 0; j < cfgElem.attributes().size(); ++j )
    {
      QDomAttr attr = cfgElem.attributes().item( j ).toAttr();
      cfg.insert( attr.name(), attr.value() );
    }

    QDomNodeList optionElements = cfgElem.elementsByTagName( "option" );
    for ( int j = 0; j < optionElements.size(); ++j )
    {
      QString key = optionElements.at( j ).toElement().attribute( "key" );
      QString value = optionElements.at( j ).toElement().attribute( "value" );
      cfg.insert( key, value );
    }

    setWidgetConfig( wdgElem.attribute( "name" ), cfg );
  }
  //// END TODO
}
Exemplo n.º 7
0
void runshell(){
    int flag, inp_flag, out_flag, ifd, ofd, stdin_copy, stdout_copy;
    char pth[BUFFER];
    char fileIn[BUFFER], fileOut[BUFFER];
    strcpy(pth,"");
    while(1){
        printf("myshell@%s> ", getcwd(line,BUFFER));
        line[0] = '\0';
        fgets(line, BUFFER, stdin);
        clearTabs(line);
        removeLastEnter(line);
        // printf("\nLINE = {%s}\n",line);

        int pipeCount = isPipingNeeded(line);
        // printf("\npipeCount = %d\n",pipeCount);
        if(pipeCount>0){
        	piping(line,pipeCount);
        	continue;
        }
        

        /************ NO PIPING IS REQUIRED ***********/
        inp_flag = extractWord(line, '<' ,fileIn);
        out_flag = extractWord(line,'>', fileOut);
        
        if(inp_flag != -1 && out_flag != -1){
        	if(inp_flag == 1){
        		stdin_copy = dup(0);
        		close(0);
        		ifd = open(fileIn, O_RDONLY);
				if (ifd < 0) {
		        	fprintf(stderr, "Unable to open input file in read mode...\n");
		        	continue;
				} 
        	}
        	if(out_flag == 1){
        		stdout_copy = dup(1);
        		close(1);
        		ofd = open(fileOut, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
				if (ofd < 0) {
    			    fprintf(stderr, "Unable to open output file in write mode...\n");
		        	continue;
				} 
        	}
        }
        
        if(feof(stdin)){
        	printf("\n");
        	exit(0);
        }
        separateWord(line);
        //printf("%s",words[0]);
        if(!strcmp(words[0],"cd")){
            strcpy(pth,"");
            strcat(pth,getcwd(line,BUFFER));
            //if(words[1][0] != '/')
            strcat(pth,"/");
            strcat(pth,words[1]);
            flag = chdir(pth);
            if(flag == -1){
            	flag = chdir(words[1]);
            	if(flag == -1) printf("\nNo Such file or directory !!\n");
                	// runProg(words[0],"",words[1]);
            }       
        }
        else if(!strcmp(words[0],"pwd")){
            printf("%s\n",getcwd(line,BUFFER));
        }
        else if(!strcmp(words[0],"mkdir")){
            strcpy(pth,"");
            strcat(pth,getcwd(line,BUFFER));
            strcat(pth,"/");
            strcat(pth,words[1]);
            flag = mkdir(pth,0777);
            if(flag == -1){
            	flag = mkdir(words[1],0777);
            	if(flag == -1)
                	runProg(words[0],"",words[1],0);
            }               
        }
        else if(!strcmp(words[0],"rmdir")){
            strcpy(pth,"");
            strcat(pth,getcwd(line,BUFFER));
            strcat(pth,"/");
            strcat(pth,words[1]);
            flag = rmdir(pth);
            if(flag == -1){
            	flag = rmdir(words[1]);
            	if(flag == -1)
                	runProg(words[0],"",words[1],0);
            }
        }
        else if(!strcmp(words[0],"ls") && !(words[1][0] == '-' && words[1][1] == 'l')){
            DIR *dp;
            struct dirent *ep;
            dp = opendir ("./");
            if (dp != NULL)
            {
                while (ep = readdir (dp))
                puts (ep->d_name);
                    (void) closedir (dp);
            }
            else
                puts ("Couldn't open the directory.");
        }
        else if(!strcmp(words[0],"ls") && words[1][0] == '-' && words[1][1] == 'l'){
            DIR *d;
            struct dirent *de;
            struct stat buf;
            int i,j;
            char P[10]="rwxrwxrwx",AP[10]=" ";
            struct passwd *p;
            struct group *g;
            struct tm *t;
            char time[26];
            d=opendir(".");
            readdir(d);
            readdir(d);
            while((de=readdir(d))!=NULL)
            {
                stat(de->d_name,&buf);

                // File Type
                if(S_ISDIR(buf.st_mode))
                printf("d");
                else if(S_ISREG(buf.st_mode))
                printf("-");
                else if(S_ISCHR(buf.st_mode))
                printf("c");
                else if(S_ISBLK(buf.st_mode))
                printf("b");
                else if(S_ISLNK(buf.st_mode))
                printf("l");
                else if(S_ISFIFO(buf.st_mode))
                printf("p");
                else if(S_ISSOCK(buf.st_mode))
                printf("s");
                //File Permissions P-Full Permissions AP-Actual Permissions
                for(i=0,j=(1<<8);i<9;i++,j>>=1)
                AP[i]= (buf.st_mode & j ) ? P[i] : '-' ;
                printf("%s",AP);
                //No. of Hard Links
                printf("%lu",buf.st_nlink);
                //User Name
                p=getpwuid(buf.st_uid);
                printf(" %.8s",p->pw_name);
                //Group Name
                g=getgrgid(buf.st_gid);
                printf(" %-8.8s",g->gr_name);
                //File Size
                printf(" %lu",buf.st_size);
                //Date and Time of modification
                t=localtime(&buf.st_mtime);
                strftime(time,sizeof(time),"%b %d %H:%M",t);
                printf(" %s",time);
                //File Name
                printf(" %s\n",de->d_name);
            }
        }
        else if(!strcmp(words[0],"exit")){
Exemplo n.º 8
0
void RmShaderDialog::fillTabsWithPass(int index)
{
	clearTabs();
	if (index < 0 || eff_selected == NULL || index >= eff_selected->size())
		return;

	pass_selected = &(eff_selected->at(index));

	// Set the source code of vertex shader
	ui.textVertex->setText(pass_selected->getVertex());

	// Set the source code of fragment shader
	ui.textFragment->setText(pass_selected->getFragment());

	// General Info in the first tab
	QString info;
	if (pass_selected->hasRenderTarget())
		info += "Render Target: " + pass_selected->getRenderTarget().name + "\n";

	for (int i = 0; i < 2; i++)
		for (int j = 0;
		     j < (i == 0 ? pass_selected->vertexUniformVariableSize() : pass_selected->fragmentUniformVariableSize());
		     j++) {
			UniformVar v = pass_selected->getUniform(j, i == 0 ? RmPass::VERTEX : RmPass::FRAGMENT);

			if(v.representerTagName == "RmRenderTarget") {
				if (i == 0)
					info += "Vertex";
				else
					info += "Fragment";

				info += " render Input: " + v.name;

				for (int k = 0; k < eff_selected -> size(); k++)
					if (eff_selected->at(k).getRenderTarget().name == v.textureName) {
						info += " (from pass: "******")";
						break;
					}

				info += "\n";
			}
		}

	if (!info.isEmpty()) {
		QLabel *lblinfo = new QLabel(info);
		layoutUniform->addWidget(lblinfo, 0, 0, 1, 5);
		shown.append(lblinfo);
	}

	// any value change is sent to the state holder with this mapper
	// Signal are send from signaler in the form "varnameNM" where
	// NM is the index of row and column in case of matrix. (00 if
	// it is a simple variable).
	delete signaler;
	signaler = new QSignalMapper();
	connect(signaler, SIGNAL(mapped(const QString &)), this, SLOT(valuesChanged(const QString &)));


	// Uniform Variables in the first Tab
	QList<QString> usedVarables; // parser can give same variable twice in the vertex and fragment
	int row = 1;
	for (int ii = 0; ii < 2; ii++)
		for (int jj = 0;
		     jj < (ii == 0 ? pass_selected->vertexUniformVariableSize() : pass_selected->fragmentUniformVariableSize());
		     jj++) {
			UniformVar v = pass_selected->getUniform(jj, ii == 0 ? RmPass::VERTEX : RmPass::FRAGMENT);
			if (v.representerTagName == "RmRenderTarget" || usedVarables.contains(v.name))
				continue;
			usedVarables.append(v.name);

			QString varname = (ii == 0 ? "Vertex: " : "Fragment: ");
			varname += UniformVar::getStringFromUniformType(v.type) +
			           " " + v.name + (v.minSet || v.maxSet ? "\n" : "");

			switch (v.type) {
			case UniformVar::INT:
			case UniformVar::IVEC2:
			case UniformVar::IVEC3:
			case UniformVar::IVEC4: {
				int n = v.type == UniformVar::INT ? 1 : (v.type == UniformVar::IVEC2 ? 2 : (v.type == UniformVar::IVEC3 ? 3 : 4 ));
				for (int i = 0; i < n; i++) {
					QSpinBox *input = new QSpinBox();
					input->setObjectName(v.name + "0" + QString().setNum(i));
					if (v.minSet)
						input->setMinimum(v.fmin);
					else
						input -> setMinimum(-1000);

					if (v.maxSet)
						input->setMaximum(v.fmax);
					else
						input->setMaximum(1000);

					input->setSingleStep((v.minSet && v.maxSet )? std::max(( v.imax - v.imin )/10, 1) : 1 );
					input->setValue(v.ivec4[i]);
					layoutUniform->addWidget(input, row, 1 + i, 1,
					                         ((i + 1)==n ? 5-n : 1));
					shown.append(input);

					connect(input, SIGNAL(valueChanged(int)), signaler, SLOT(map()));
					signaler->setMapping(input, v.name + "0" + QString().setNum(i));
				}
				if (v.minSet) {
					varname += "min: " + QString().setNum(v.imin) + " ";
				}
				if (v.maxSet) {
					varname += " max: " + QString().setNum(v.imax);
				}
				break;
			}
			case UniformVar::BOOL:
			case UniformVar::BVEC2:
			case UniformVar::BVEC3:
			case UniformVar::BVEC4:
			{
				int n = v.type == UniformVar::BOOL ? 1 : (v.type == UniformVar::BVEC2 ? 2 : (v.type == UniformVar::BVEC3 ? 3 : 4 ));
				for( int i = 0; i < n; i++ ) {
					QCheckBox * input = new QCheckBox();
					input -> setObjectName( v.name + "0" + QString().setNum(i) );
					input -> setCheckState( v.bvec4[i] ? Qt::Checked : Qt::Unchecked );
					layoutUniform->addWidget(input, row, 1+i, 1, ((i+1)==n ? 5-n : 1));
					shown.append(input);

					connect(input, SIGNAL(stateChanged(int)), signaler, SLOT(map()));
					signaler->setMapping(input, v.name + "0" + QString().setNum(i) );
				}
				break;
			}
			case UniformVar::FLOAT:
			case UniformVar::VEC2:
			case UniformVar::VEC3:
			case UniformVar::VEC4:
			{
				int n = v.type == UniformVar::FLOAT ? 1 : (v.type == UniformVar::VEC2 ? 2 : (v.type == UniformVar::VEC3 ? 3 : 4 ));
				for( int i = 0; i < n; i++ )
				{
					QDoubleSpinBox * input = new QDoubleSpinBox();
					input -> setObjectName( v.name + "0" + QString().setNum(i) );
					input -> setDecimals(4);
					if( v.minSet ) input -> setMinimum( v.fmin ); else input -> setMinimum( -1000 );
					if( v.maxSet ) input -> setMaximum( v.fmax ); else input -> setMaximum( 1000 );
					input -> setSingleStep( (v.minSet && v.maxSet ) ? std::max(( v.fmax - v.fmin )/10., 0.0001) : 0.0001 );
					input -> setValue( v.vec4[i] );
					layoutUniform->addWidget( input, row, 1+i, 1, ((i+1)==n ? 5-n : 1) );
					shown.append(input);

					connect(input, SIGNAL(valueChanged(double)), signaler, SLOT(map()));
					signaler->setMapping(input, v.name + "0" + QString().setNum(i) );
				}
				if( v.minSet ) { varname += "min: " + QString().setNum(v.fmin) + " "; }
				if( v.maxSet ) { varname += " max: " + QString().setNum(v.fmax); }
				break;
			}
			case UniformVar::MAT2:
			case UniformVar::MAT3:
			case UniformVar::MAT4:
			{
				int n = v.type == UniformVar::MAT2 ? 2 : (v.type == UniformVar::MAT3 ? 3 : 4 );
				for( int i = 0; i < n; i++ ) {
					for( int j = 0; j < n; j++ ) {
						QDoubleSpinBox * input = new QDoubleSpinBox();
						input -> setObjectName( v.name + QString().setNum(i) + QString().setNum(j));
						input -> setDecimals(4);
						if( v.minSet ) input -> setMinimum( v.fmin ); else input -> setMinimum( -1000 );
						if( v.maxSet ) input -> setMaximum( v.fmax ); else input -> setMaximum( 1000 );
						input -> setSingleStep( (v.minSet && v.maxSet ) ? std::max(( v.fmax - v.fmin )/10., 0.0001) : 0.0001 );
						input -> setValue( v.vec4[(i*n)+j] );
						layoutUniform->addWidget(input, row, 1+j, 1, ((j+1)==n ? 5-n : 1));
						shown.append(input);

						connect(input, SIGNAL(valueChanged(double)), signaler, SLOT(map()));
						signaler->setMapping(input, v.name + QString().setNum(i) + QString().setNum(j));
					}
					if( (i+1) < n ) row += 1;
				}
				if( v.minSet ) { varname += "min: " + QString().setNum(v.fmin) + " "; }
				if( v.maxSet ) { varname += " max: " + QString().setNum(v.fmax); }
				break;
			}
			case UniformVar::SAMPLER1D:
			case UniformVar::SAMPLER2D:
			case UniformVar::SAMPLER3D:
			case UniformVar::SAMPLERCUBE:
			case UniformVar::SAMPLER1DSHADOW:
			case UniformVar::SAMPLER2DSHADOW:
			{
				QLabel * link = new QLabel( "<font color=\"blue\">See texture tab</font>" );
				layoutUniform->addWidget(link, row, 1, 1, 4);
				shown.append(link);
				break;
			}
			case UniformVar::OTHER:
			{
				QLabel * unimpl = new QLabel( "[Unimplemented mask]" );
				layoutUniform->addWidget( unimpl, row, 1, 1, 4);
				shown.append(unimpl);
			}
			}

			QLabel * lblvar = new QLabel(varname);
			layoutUniform->addWidget( lblvar, row, 0 );
			shown.append(lblvar);

			row += 1;
		}


	// Texture in the second tab
	for( int ii = 0, row = 0; ii < 2; ii++ )
		for( int jj = 0; jj < ( ii == 0 ? pass_selected -> vertexUniformVariableSize() : pass_selected -> fragmentUniformVariableSize()); jj++ )
		{
			UniformVar v = pass_selected -> getUniform( jj, ii == 0 ? RmPass::VERTEX : RmPass::FRAGMENT );
			if( v.textureFilename.isNull() ) continue;

			QFileInfo finfo(v.textureFilename);

			QDir textureDir = QDir(qApp->applicationDirPath());
#if defined(Q_OS_WIN)
			if (textureDir.dirName() == "debug" || textureDir.dirName() == "release" || textureDir.dirName() == "plugins"  ) textureDir.cdUp();
#elif defined(Q_OS_MAC)
			if (textureDir.dirName() == "MacOS") { for(int i=0;i<4;++i){ textureDir.cdUp(); if(textureDir.exists("textures")) break; } }
#endif
			textureDir.cd("textures");
			QFile f( textureDir.absoluteFilePath(finfo.fileName()));

			QString varname = ( ii == 0 ? "Vertex texture: " : "Fragment texture: ");
			varname += UniformVar::getStringFromUniformType(v.type) + " " + v.name + "<br>";
			varname += "Filename: " + finfo.fileName() + (f.exists() ? "" : " [<font color=\"red\">not found</font>]");

			for( int k = 0; k < v.textureGLStates.size(); k++ )
			{
				varname += "<br>OpenGL state: " + v.textureGLStates[k].getName() + ": " +
					parser->convertGlStateToString(v.textureGLStates[k]);
			}

			QLabel * lblvar = new QLabel(varname);
			lblvar -> setTextFormat( Qt::RichText );
			lblvar -> setObjectName( v.name + "00" );
			layoutTextures->addWidget( lblvar, row++, 0, 1, 2 );
			shown.append(lblvar);

			QLineEdit * txtChoose = new QLineEdit( textureDir.absoluteFilePath(finfo.fileName()) );
			txtChoose -> setObjectName( v.name + "11" );
			layoutTextures->addWidget( txtChoose, row, 0 );
			shown.append(txtChoose);

			connect(txtChoose, SIGNAL(editingFinished()), signaler, SLOT(map()));
			signaler->setMapping(txtChoose, v.name + "11");

			QPushButton * btnChoose = new QPushButton( "Browse" );
			btnChoose -> setObjectName( v.name + "22" );
			layoutTextures->addWidget( btnChoose, row, 1 );
			shown.append(btnChoose);

			connect(btnChoose, SIGNAL(clicked()), signaler, SLOT(map()));
			signaler->setMapping(btnChoose, v.name + "22");

			row++;
		}

	// OpenGL Status
	if( pass_selected -> openGLStatesSize() == 0 )
	{
		QLabel * lblgl = new QLabel( "No openGL states set" );
		layoutOpengl->addWidget( lblgl, row, 0 );
		shown.append(lblgl);
	}
	else
	{
		for( int i = 0, row = 0; i < pass_selected -> openGLStatesSize(); i++ )
		{
			QString str = "OpenGL state: " + pass_selected -> getOpenGLState(i).getName();
			str += " (" + QString().setNum(pass_selected -> getOpenGLState(i).getState()) + "): " +
				QString().setNum(pass_selected -> getOpenGLState(i).getValue());
			QLabel * lblgl = new QLabel(str);
			layoutOpengl->addWidget( lblgl, row++, 0 );
			shown.append(lblgl);
		}
	}
}