Пример #1
0
bool GMXXXPort::exportContacts( const KABC::AddresseeList &list, const QString& )
{
  KURL url = KFileDialog::getSaveURL( ":xxport_gmx", GMX_FILESELECTION_STRING );
  if ( url.isEmpty() )
      return true;

  if ( !url.isLocalFile() ) {
    KTempFile tmpFile;
    if ( tmpFile.status() != 0 ) {
      QString txt = i18n( "<qt>Unable to open file <b>%1</b>.%2.</qt>" );
      KMessageBox::error( parentWidget(), txt.arg( url.url() )
                          .arg( strerror( tmpFile.status() ) ) );
      return false;
    }

    doExport( tmpFile.file(), list );
    tmpFile.close();

    return KIO::NetAccess::upload( tmpFile.name(), url, parentWidget() );
  } else {
    QString filename = url.path();
    QFile file( filename );

    if ( !file.open( IO_WriteOnly ) ) {
      QString txt = i18n( "<qt>Unable to open file <b>%1</b>.</qt>" );
      KMessageBox::error( parentWidget(), txt.arg( filename ) );
      return false;
    }

    doExport( &file, list );
    file.close();

    return true;
  }
}
Пример #2
0
int QTshotWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMAINWINDOW::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: doHelp(); break;
        case 1: doQuit(); break;
        case 2: doOpen(); break;
        case 3: doNew(); break;
        case 4: doSave(); break;
        case 5: doData(); break;
        case 6: doExport(); break;
        case 7: doExportOK(); break;
        case 8: doOptions(); break;
        case 9: doToggle(); break;
        case 10: doCollapse(); break;
        case 11: doPlan(); break;
        case 12: doExtended(); break;
        case 13: do3D(); break;
        case 14: doCrossSection((*reinterpret_cast< DBlock*(*)>(_a[1])),(*reinterpret_cast< bool(*)>(_a[2])),(*reinterpret_cast< bool(*)>(_a[3]))); break;
        case 15: doCrossSection((*reinterpret_cast< DBlock*(*)>(_a[1])),(*reinterpret_cast< bool(*)>(_a[2]))); break;
        case 16: value_changed((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 17: double_clicked((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3])),(*reinterpret_cast< const QPoint(*)>(_a[4]))); break;
        }
        _id -= 18;
    }
    return _id;
}
Пример #3
0
// =============================================================================
std::shared_ptr<Tpetra::Vector<double,int,int>>
mesh_tri::
compute_control_volumes_() const
{
#ifdef NOSH_TEUCHOS_TIME_MONITOR
  Teuchos::TimeMonitor tm(*compute_control_volumes_time_);
#endif
#ifndef NDEBUG
  TEUCHOS_ASSERT(vertices_map_);
  TEUCHOS_ASSERT(vertices_overlap_map_);
#endif

  auto _control_volumes = std::make_shared<Tpetra::Vector<double,int,int>>(
      Teuchos::rcp(vertices_map_)
      );

  // Create temporaries to hold the overlap values for control volumes.
  Tpetra::Vector<double,int,int> cv_overlap(Teuchos::rcp(vertices_overlap_map_));

  this->compute_control_volumes_t_(cv_overlap);

  // Export control volumes to a non-overlapping map, and sum the entries.
  Teuchos::RCP<const Tpetra::Export<int,int>> exporter = Tpetra::createExport(
      Teuchos::rcp(vertices_overlap_map_),
      Teuchos::rcp(vertices_map_)
      );

  _control_volumes->doExport(cv_overlap, *exporter, Tpetra::ADD);

  return _control_volumes;
}
void ExportSymlinks::execute()
{
    // test the destination directory
    if (m_destinationDir->isEmpty()) {
        tracer->error(__func__, "The specified 'destinationDir' is null or empty!");
        return;
    }
    QDir dir(*m_destinationDir);
    if (!dir.exists()) {
        tracer->error(__func__, "The specified 'destinationDir' does not exist or is not a directory!");
        return;
    }
    
    // test the files to export
    if (!m_sourceFiles || m_sourceFiles->isEmpty()) {
        tracer->info(__func__, "No files to export!");
        return;
    }
    
    // setup progress dialog
    m_progressDialog = new KProgressDialog(m_parent, "exportSymlinksProgressDialog", i18n("Exporting symbolic links"), i18n("Initializing export..."), true);
    m_progressDialog->progressBar()->setTotalSteps(m_sourceFiles->count());
    m_progressDialog->setAllowCancel(true);
    connect(m_progressDialog, SIGNAL(cancelClicked()), this, SLOT(slotCancel()));
    m_progressDialog->show();
    
    // do the job
    doExport();
}
Пример #5
0
void CupsAddSmb::slotActionClicked()
{
	if (m_state == None)
		doExport();
	else if (m_proc.isRunning())
		m_proc.kill();
}
	//---------------------------------------------------------------
	void CameraExporter::doExport( ExportNode* exportNode )
	{
		if ( exportNode->getType() == ExportNode::CAMERA )
			exportCamera(exportNode);

		size_t numberOfChildren = exportNode->getNumberOfChildren();
		for ( size_t i = 0; i < numberOfChildren; ++i )
			doExport ( exportNode->getChild ( i ) );
	}
	//---------------------------------------------------------------
	void LightExporter::doExport( ExportNode* exportNode )
	{
		if ( exportNode->getType() == ExportNode::LIGHT )
			exportLight(exportNode);

		size_t numberOfChildren = exportNode->getNumberOfChildren();
		for ( size_t i = 0; i < numberOfChildren; ++i )
			doExport( exportNode->getChild ( i ) );
	}
	//---------------------------------------------------------------
	void ControllerExporter::doExport( ExportNode* exportNode )
	{
		if ( !exportNode->getIsInVisualScene() )
			return;

		exportControllers(exportNode);

		size_t numberOfChildren = exportNode->getNumberOfChildren();
		for ( size_t i = 0; i < numberOfChildren; ++i )
			doExport ( exportNode->getChild ( i ) );
	}
Пример #9
0
bool CSVXXPort::exportContacts( const KABC::AddresseeList &list, const QString& )
{
  KUrl url = KFileDialog::getSaveUrl( KUrl("addressbook.csv") );
  if ( url.isEmpty() )
      return true;

  if( QFileInfo( url.isLocalFile() ? url.toLocalFile() : url.path() ).exists() ) {
      if(KMessageBox::questionYesNo( parentWidget(), i18n("Do you want to overwrite file \"%1\"", url.isLocalFile() ? url.toLocalFile() : url.path()) ) == KMessageBox::No)
        return true;
  }

  if ( !url.isLocalFile() ) {
    KTemporaryFile tmpFile;
    if ( !tmpFile.open() ) {
      QString txt = i18n("<qt>Unable to open file <b>%1</b></qt>", url.url());
      KMessageBox::error( parentWidget(), txt );
      return false;
    }

    doExport( &tmpFile, list );
    tmpFile.flush();

    return KIO::NetAccess::upload( tmpFile.fileName(), url, parentWidget() );
  } else {
    QFile file( url.toLocalFile() );
    if ( !file.open( QIODevice::WriteOnly ) ) {
      QString txt = i18n( "<qt>Unable to open file <b>%1</b>.</qt>", url.toLocalFile() );
      KMessageBox::error( parentWidget(), txt );
      return false;
    }

    doExport( &file, list );
    file.close();

    KMessageBox::information( parentWidget(), i18n( "The contacts have been exported successfully." ) );

    return true;
  }
}
    //---------------------------------------------------------------
    void GeometriesExporter::doExport ( ExportNode* exportNode )
    {
        GeometryExporter geometryExporter ( exportNode, this, mDocumentExporter );

        geometryExporter.doExport();


        //export the geometries of the child nodes
        size_t numberOfChildren = exportNode->getNumberOfChildren();

        for ( size_t i = 0; i < numberOfChildren; ++i )
            doExport ( exportNode->getChild ( i ) );

    }
    //---------------------------------------------------------------
    void GeometriesExporter::doExport()
    {
        doExport ( mExportSceneGraph->getRootExportNode() );

		const MorphControllerHelperGeometryList& morphControllerHelperGeometryList = mExportSceneGraph->getMorphControllerHelperGeometryList();

		for ( MorphControllerHelperGeometryList::const_iterator it = morphControllerHelperGeometryList.begin(); it != morphControllerHelperGeometryList.end(); ++it)
		{
			const MorphControllerHelperGeometry& morphControllerHelperGeometry = *it;
			GeometryExporter geometryExporter ( &morphControllerHelperGeometry, this, mDocumentExporter );

			geometryExporter.doExport();
		}

        closeLibrary();
    }
Пример #12
0
    Pin::Pin(Chip& chip, const int number): chip(chip), number(number)
    {
        path = GPIO_PATH + "/gpio" + std::to_string(number);

        doExport();
        
        directionFile = new std::fstream();
        valueFile = new std::fstream();
        edgeFile = new std::fstream();

        directionFile->open(path + "/direction");
        valueFile->open(path + "/value");
        edgeFile->open(path + "/edge");

        lastInterrupt = 0;
        interruptDebounce = 0;

        startInterruptThread();
    }
HistoryDlg::HistoryDlg(const XMPP::Jid& j, PsiAccount* pa)
: pa_(pa), jidFull_(j), from_(0), count_(30)
{
	setupUi(this);
	setModal(false);
	setAttribute(Qt::WA_DeleteOnClose);
	pa_->dialogRegister(this, jidFull_);
	setWindowTitle(tr("History for ") + j.full());
#ifndef Q_WS_MAC
	setWindowIcon(IconsetFactory::icon("psi/history").icon());
#endif


	DateTree->setHeaderLabel(tr("Date"));
	DateTree->setSortingEnabled(true);
	DateTree->setColumnHidden(1,true);
	connect(DateTree, SIGNAL(customContextMenuRequested(const QPoint &)), SLOT(doDateContextMenu(const QPoint &)));

	EventsTree->setColumnCount(4);
	QStringList headers;
	headers << tr("Type") << tr("Time") << tr("Origin") << tr("Text");
	EventsTree->setHeaderLabels(headers);
	EventsTree->sortItems(1,Qt::AscendingOrder);
	EventsTree->setSortingEnabled(true);
	EventsTree->setWordWrap(true);
	EventsTree->hideColumn(2);

	connect(EventsTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), SLOT(actionOpenEvent(QTreeWidgetItem *, int)));
	connect(EventsTree, SIGNAL(customContextMenuRequested(const QPoint &)), SLOT(doEventContextMenu(const QPoint &)));
	connect(tb_previousMonth, SIGNAL(clicked()), SLOT(doPrev()));
	connect(tb_latest, SIGNAL(clicked()), SLOT(doLatest()));
	connect(tb_nextMonth, SIGNAL(clicked()), SLOT(doNext()));
	connect(pb_find, SIGNAL(clicked()), SLOT(doFind()));
	connect(pb_export, SIGNAL(clicked()), SLOT(doExport()));
	connect(pb_close, SIGNAL(clicked()), SLOT(close()));

	jid_ = j.bare();
	doLatest();

	X11WM_CLASS("history");
}
Пример #14
0
int LD3dsExporter::doExport(LDLModel *pTopModel)
{
	int retVal = 1;
	TCFloat matrix[16];

	TCVector::initIdentityMatrix(matrix);
	matrix[5] = 0.0;
	matrix[6] = -1.0;
	matrix[9] = 1.0;
	matrix[10] = 0.0;
	m_topModel = pTopModel;
    m_file = lib3ds_file_new();
	m_names.clear();
	m_meshes.clear();
	m_meshCount = 0;
	doExport(pTopModel, NULL, matrix, 7, false, true, false);
	//if (m_includeCamera)
	//{
	//	Lib3dsCamera *pCamera = lib3ds_camera_new("Default");
	//	Lib3dsCameraNode *pCameraNode;
	//	TCVector cameraLoc(m_camera.getPosition().transformPoint(matrix));

	//	pCamera->position[0] = cameraLoc[0];
	//	pCamera->position[1] = cameraLoc[1];
	//	pCamera->position[2] = cameraLoc[2];
	//	pCamera->fov = m_fov;
	//	pCameraNode = lib3ds_node_new_camera(pCamera);
	//	lib3ds_file_append_node(m_file, (Lib3dsNode *)pCameraNode, NULL);
	//}
	if (!lib3ds_file_save(m_file, m_filename.c_str()))
	{
		retVal = 0;
	}
	lib3ds_file_free(m_file);
	return retVal;
}
	//---------------------------------------------------------------
	void ControllerExporter::doExport()
	{
		doExport ( mExportSceneGraph->getRootExportNode() );
		closeLibrary();
	}
Пример #16
0
GenGraphForm::GenGraphForm()
: currentTask(NULL), settingFilter(false)
{
    // signals and slots connections
    connect(browseButton, SIGNAL(clicked()), this, SLOT(doBrowse()));
    connect(exportButton, SIGNAL(clicked()), this, SLOT(doExport()));
    connect(displayButton, SIGNAL(clicked()), this, SLOT(doDisplay()));
    connect(closeButton, SIGNAL(clicked()), this, SLOT(doClose()));
    connect(filename, SIGNAL(textChanged(const QString&)), this, SLOT(change()));
    connect(presetFilter, SIGNAL(activated(const QString&)), this, SLOT(setFilter()));
    connect(showNodes, SIGNAL(toggled(bool)), this, SLOT(changeFilter()));
    connect(showObjects, SIGNAL(toggled(bool)), this, SLOT(changeFilter()));
    connect(showBehaviorModels, SIGNAL(toggled(bool)), this, SLOT(changeFilter()));
    connect(showCollisionModels, SIGNAL(toggled(bool)), this, SLOT(changeFilter()));
    connect(showVisualModels, SIGNAL(toggled(bool)), this, SLOT(changeFilter()));
    connect(showMappings, SIGNAL(toggled(bool)), this, SLOT(changeFilter()));
    connect(showContext, SIGNAL(toggled(bool)), this, SLOT(changeFilter()));
    connect(showCollisionPipeline, SIGNAL(toggled(bool)), this, SLOT(changeFilter()));
    connect(showSolvers, SIGNAL(toggled(bool)), this, SLOT(changeFilter()));
    connect(showMechanicalStates, SIGNAL(toggled(bool)), this, SLOT(changeFilter()));
    connect(showForceFields, SIGNAL(toggled(bool)), this, SLOT(changeFilter()));
    connect(showInteractionForceFields, SIGNAL(toggled(bool)), this, SLOT(changeFilter()));
    connect(showConstraints, SIGNAL(toggled(bool)), this, SLOT(changeFilter()));
    connect(showMass, SIGNAL(toggled(bool)), this, SLOT(changeFilter()));
    connect(showTopology, SIGNAL(toggled(bool)), this, SLOT(changeFilter()));
    connect(showMechanicalMappings, SIGNAL(toggled(bool)), this, SLOT(changeFilter()));

    // init preset filters
	{
		std::set<std::string>& filt = presetFilters["Full Graph"];
		filt.insert("showNodes");
		filt.insert("showObjects");
		filt.insert("showBehaviorModels");
		filt.insert("showCollisionModels");
		filt.insert("showVisualModels");
		filt.insert("showMappings");
		filt.insert("showContext");
		filt.insert("showCollisionPipeline");
		filt.insert("showSolvers");
		filt.insert("showMechanicalStates");
		filt.insert("showForceFields");
		filt.insert("showInteractionForceFields");
		filt.insert("showConstraints");
		filt.insert("showMass");
		filt.insert("showTopology");
		filt.insert("showMechanicalMappings");
	}
	{
		std::set<std::string>& filt = presetFilters["All Objects"];
		filt = presetFilters["Full Graph"];
		filt.erase("showNodes");
	}
	{
		std::set<std::string>& filt = presetFilters["All Nodes"];
		filt.insert("showNodes");
	}
	{
		std::set<std::string>& filt = presetFilters["Mechanical Graph"];
		filt = presetFilters["Full Graph"];
		filt.erase("showCollisionModels");
		filt.erase("showVisualModels");
		filt.erase("showMappings");
		filt.erase("showCollisionPipeline");
	}
	{
		std::set<std::string>& filt = presetFilters["Mechanical Objects"];
		filt = presetFilters["Mechanical Graph"];
		filt.erase("showNodes");
	}
	{
		std::set<std::string>& filt = presetFilters["Visual Graph"];
		filt.insert("showNodes");
		filt.insert("showObjects");
		filt.insert("showVisualModels");
	}
	{
		std::set<std::string>& filt = presetFilters["Visual Objects"];
		filt = presetFilters["Visual Graph"];
		filt.erase("showNodes");
	}
	{
		std::set<std::string>& filt = presetFilters["Collision Graph"];
		filt.insert("showNodes");
		filt.insert("showObjects");
		filt.insert("showCollisionModels");
		filt.insert("showCollisionPipeline");
	}
	{
		std::set<std::string>& filt = presetFilters["Collision Objects"];
		filt = presetFilters["Collision Graph"];
		filt.erase("showNodes");
	}
	{
		std::set<std::string>& filt = presetFilters["Collision Response Graph"];
		filt.insert("showNodes");
		filt.insert("showObjects");
		//filt.insert("showBehaviorModels");
		filt.insert("showCollisionModels");
		//filt.insert("showVisualModels");
		//filt.insert("showMappings");
		//filt.insert("showContext");
		//filt.insert("showCollisionPipeline");
		filt.insert("showSolvers");
		filt.insert("showMechanicalStates");
		//filt.insert("showForceFields");
		filt.insert("showInteractionForceFields");
		filt.insert("showConstraints");
		//filt.insert("showMass");
		//filt.insert("showTopology");
		filt.insert("showMechanicalMappings");
	}
	{
		std::set<std::string>& filt = presetFilters["Collision Response Objects"];
		filt = presetFilters["Collision Response Graph"];
		filt.erase("showNodes");
	}

}
	//---------------------------------------------------------------
	void CameraExporter::doExport()
	{
		doExport ( mExportSceneGraph->getRootExportNode() );
		closeLibrary();
	}
Пример #18
0
int main (int argc, char *argv [])
{
  int i ;

  if (argc == 1)
  {
    fprintf (stderr, "%s\n", usage) ;
    return 1 ;
  }

  if (strcasecmp (argv [1], "-h") == 0)
  {
    printf ("%s: %s\n", argv [0], usage) ;
    return 0 ;
  }

  if (strcasecmp (argv [1], "-v") == 0)
  {
    printf ("gpio version: %s\n", VERSION) ;
    printf ("Copyright (c) 2012 Gordon Henderson\n") ;
    printf ("This is free software with ABSOLUTELY NO WARRANTY.\n") ;
    printf ("For details type: %s -warranty\n", argv [0]) ;
    printf ("\n") ;
    printf ("This Raspberry Pi is a revision %d board.\n", piBoardRev ()) ;
    return 0 ;
  }

  if (strcasecmp (argv [1], "-warranty") == 0)
  {
    printf ("gpio version: %s\n", VERSION) ;
    printf ("Copyright (c) 2012 Gordon Henderson\n") ;
    printf ("\n") ;
    printf ("    This program is free software; you can redistribute it and/or modify\n") ;
    printf ("    it under the terms of the GNU Leser General Public License as published\n") ;
    printf ("    by the Free Software Foundation, either version 3 of the License, or\n") ;
    printf ("    (at your option) any later version.\n") ;
    printf ("\n") ;
    printf ("    This program is distributed in the hope that it will be useful,\n") ;
    printf ("    but WITHOUT ANY WARRANTY; without even the implied warranty of\n") ;
    printf ("    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n") ;
    printf ("    GNU Lesser General Public License for more details.\n") ;
    printf ("\n") ;
    printf ("    You should have received a copy of the GNU Lesser General Public License\n") ;
    printf ("    along with this program. If not, see <http://www.gnu.org/licenses/>.\n") ;
    printf ("\n") ;
    return 0 ;
  }

  if (geteuid () != 0)
  {
    fprintf (stderr, "%s: Must be root to run. Program should be suid root. This is an error.\n", argv [0]) ;
    return 1 ;
  }

// Initial test for /sys/class/gpio operations:

  /**/ if (strcasecmp (argv [1], "exports"    ) == 0)	{ doExports     (argc, argv) ;	return 0 ; }
  else if (strcasecmp (argv [1], "export"     ) == 0)	{ doExport      (argc, argv) ;	return 0 ; }
  else if (strcasecmp (argv [1], "edge"       ) == 0)	{ doEdge        (argc, argv) ;	return 0 ; }
  else if (strcasecmp (argv [1], "unexportall") == 0)	{ doUnexportall (argc, argv) ;	return 0 ; }
  else if (strcasecmp (argv [1], "unexport"   ) == 0)	{ doUnexport    (argc, argv) ;	return 0 ; }

// Check for load command:

  if (strcasecmp (argv [1], "load" ) == 0)	{ doLoad     (argc, argv) ; return 0 ; }

// Gertboard commands

  if (strcasecmp (argv [1], "gbr" ) == 0)	{ doGbr (argc, argv) ; return 0 ; }
  if (strcasecmp (argv [1], "gbw" ) == 0)	{ doGbw (argc, argv) ; return 0 ; }

// Check for -g argument

  if (strcasecmp (argv [1], "-g") == 0)
  {
    if (wiringPiSetupGpio () == -1)
    {
      fprintf (stderr, "%s: Unable to initialise GPIO mode.\n", argv [0]) ;
      exit (1) ;
    }

    for (i = 2 ; i < argc ; ++i)
      argv [i - 1] = argv [i] ;
    --argc ;
    wpMode = WPI_MODE_GPIO ;
  }

// Check for -p argument for PiFace

  else if (strcasecmp (argv [1], "-p") == 0)
  {
    if (wiringPiSetupPiFaceForGpioProg () == -1)
    {
      fprintf (stderr, "%s: Unable to initialise PiFace.\n", argv [0]) ;
      exit (1) ;
    }

    for (i = 2 ; i < argc ; ++i)
      argv [i - 1] = argv [i] ;
    --argc ;
    wpMode = WPI_MODE_PIFACE ;
  }

// Default to wiringPi mode

  else
  {
    if (wiringPiSetup () == -1)
    {
      fprintf (stderr, "%s: Unable to initialise wiringPi mode\n", argv [0]) ;
      exit (1) ;
    }
    wpMode = WPI_MODE_PINS ;
  }

// Check for PWM or Pad Drive operations

  if (wpMode != WPI_MODE_PIFACE)
  {
    if (strcasecmp (argv [1], "pwm-bal") == 0)	{ doPwmMode  (PWM_MODE_BAL) ;	return 0 ; }
    if (strcasecmp (argv [1], "pwm-ms")  == 0)	{ doPwmMode  (PWM_MODE_MS) ;	return 0 ; }
    if (strcasecmp (argv [1], "pwmr")    == 0)	{ doPwmRange (argc, argv) ;	return 0 ; }
    if (strcasecmp (argv [1], "pwmc")    == 0)	{ doPwmClock (argc, argv) ;	return 0 ; }
    if (strcasecmp (argv [1], "drive")   == 0)	{ doPadDrive (argc, argv) ;	return 0 ; }
  }

// Check for wiring commands

  /**/ if (strcasecmp (argv [1], "readall" ) == 0) doReadall  () ;
  else if (strcasecmp (argv [1], "read" )    == 0) doRead     (argc, argv) ;
  else if (strcasecmp (argv [1], "write")    == 0) doWrite    (argc, argv) ;
  else if (strcasecmp (argv [1], "pwm"  )    == 0) doPwm      (argc, argv) ;
  else if (strcasecmp (argv [1], "mode" )    == 0) doMode     (argc, argv) ;
  else
  {
    fprintf (stderr, "%s: Unknown command: %s.\n", argv [0], argv [1]) ;
    exit (1) ;
  }
  return 0 ;
}
Пример #19
0
void LD3dsExporter::doExport(
	LDLModel *pModel,
	Lib3dsNode *pParentNode,
	const TCFloat *matrix,
	int colorNumber,
	bool inPart,
	bool bfc,
	bool invert)
{
	LDLFileLineArray *pFileLines = pModel->getFileLines();

	if (pFileLines != NULL)
	{
		BFCState newBfcState = pModel->getBFCState();
		int count = pModel->getActiveLineCount();
		std::string meshName;
		Lib3dsMesh *pMesh = NULL;
		Lib3dsNode *pChildNode = NULL;
//		Lib3dsMeshInstanceNode *pInst;
		bool linesInvert = invert;
		bool isNew = false;

		if (TCVector::determinant(matrix) < 0.0f)
		{
			linesInvert = !linesInvert;
		}
		bfc = (bfc && newBfcState == BFCOnState) ||
			newBfcState == BFCForcedOnState;
		meshName.resize(128);
		sprintf(&meshName[0], "m_%06d", ++m_meshCount);
//		meshName = getMeshName(pModel, pMesh);
		if (pMesh == NULL)
		{
			pMesh = lib3ds_mesh_new(meshName.c_str());
//			memcpy(pMesh->matrix, matrix, sizeof(pMesh->matrix));
			m_meshes[meshName] = pMesh;
			lib3ds_file_insert_mesh(m_file, pMesh, -1);
			isNew = true;
		}
//		pInst = lib3ds_node_new_mesh_instance(pMesh,
//			NULL/*(meshName + "n").c_str()*/, NULL, NULL, NULL);
//		pChildNode = (Lib3dsNode *)pInst;
//		memcpy(pChildNode->matrix, matrix, sizeof(float) * 16);
//		lib3ds_file_append_node(m_file, pChildNode, pParentNode);
		VertexVector vecVertices;
		FaceVector vecFaces;
		for (int i = 0; i < count; i++)
		{
			LDLFileLine *pFileLine = (*pFileLines)[i];
			if (!pFileLine->isValid())
			{
				continue;
			}
			switch (pFileLine->getLineType())
			{
			case LDLLineTypeTriangle:
			case LDLLineTypeQuad:
				writeShapeLine(vecVertices, vecFaces, (LDLShapeLine *)pFileLine,
					matrix, colorNumber, bfc, linesInvert);
				break;
			case LDLLineTypeModel:
				{
					LDLModelLine *pModelLine = (LDLModelLine *)pFileLine;
					LDLModel *pOtherModel = pModelLine->getModel(true);
					if (pOtherModel != NULL)
					{
						TCFloat newMatrix[16];
						int otherColorNumber = pModelLine->getColorNumber();
						bool otherInPart = inPart;
						bool otherInvert = invert;
						
						if (pModelLine->getBFCInvert())
						{
							otherInvert = !otherInvert;
						}
						if (otherColorNumber == 16)
						{
							otherColorNumber = colorNumber;
						}
						TCVector::multMatrix(matrix, pModelLine->getMatrix(),
							newMatrix);
						if (!inPart && pOtherModel->isPart() && m_seams)
						{
							TCVector min, max;
							TCFloat seamMatrix[16];
							TCFloat tempMatrix[16];

							pOtherModel->getBoundingBox(min, max);
							TCVector::calcScaleMatrix(m_seamWidth, seamMatrix,
								min, max);
							TCVector::multMatrix(newMatrix, seamMatrix,
								tempMatrix);
							memcpy(newMatrix, tempMatrix, sizeof(newMatrix));
							otherInPart = true;
						}
						doExport(pOtherModel, pChildNode, newMatrix,
							otherColorNumber, otherInPart, bfc, otherInvert);
					}
				}
				break;
			default:
				// Get rid of warning
				break;
			}
		}
		if (isNew && vecVertices.size() > 0)
		{
			lib3ds_mesh_resize_vertices(pMesh, (int)vecVertices.size(), 0, 0);
			memcpy(pMesh->vertices, &vecVertices[0],
				sizeof(vecVertices[0]) * vecVertices.size());
			lib3ds_mesh_resize_faces(pMesh, (int)vecFaces.size());
			memcpy(pMesh->faces, &vecFaces[0],
				sizeof(vecFaces[0]) * vecFaces.size());
		}
		else
		{
			--m_meshCount;
		}

	}
}
	//---------------------------------------------------------------
	void LightExporter::doExport()
	{
		exportEnvironmentAmbientLight();
		doExport( mExportSceneGraph->getRootExportNode() );
		closeLibrary();
	}
Пример #21
0
int main (int argc, char *argv [])
{
  int i ;

  if (getenv ("WIRINGPI_DEBUG") != NULL)
  {
    printf ("gpio: wiringPi debug mode enabled\n") ;
    wiringPiDebug = TRUE ;
  }

  if (argc == 1)
  {
    fprintf (stderr, "%s\n", usage) ;
    return 1 ;
  }

// Help

  if (strcasecmp (argv [1], "-h") == 0)
  {
    printf ("%s: %s\n", argv [0], usage) ;
    return 0 ;
  }

// Sort of a special:

  if (strcmp (argv [1], "-R") == 0)
  {
    printf ("%d\n", piBoardRev ()) ;
    return 0 ;
  }

// Version & Warranty

  if (strcmp (argv [1], "-V") == 0)
  {
    printf ("%d\n", piBoardRev ()) ;
    return 0 ;
  }

  if (strcmp (argv [1], "-v") == 0)
  {
    printf ("gpio version: %s\n", VERSION) ;
    printf ("Copyright (c) 2012-2013 Gordon Henderson\n") ;
    printf ("This is free software with ABSOLUTELY NO WARRANTY.\n") ;
    printf ("For details type: %s -warranty\n", argv [0]) ;
    printf ("\n") ;
    printf ("This Raspberry Pi is a revision %d board.\n", piBoardRev ()) ;
    return 0 ;
  }

  if (strcasecmp (argv [1], "-warranty") == 0)
  {
    printf ("gpio version: %s\n", VERSION) ;
    printf ("Copyright (c) 2012-2013 Gordon Henderson\n") ;
    printf ("\n") ;
    printf ("    This program is free software; you can redistribute it and/or modify\n") ;
    printf ("    it under the terms of the GNU Leser General Public License as published\n") ;
    printf ("    by the Free Software Foundation, either version 3 of the License, or\n") ;
    printf ("    (at your option) any later version.\n") ;
    printf ("\n") ;
    printf ("    This program is distributed in the hope that it will be useful,\n") ;
    printf ("    but WITHOUT ANY WARRANTY; without even the implied warranty of\n") ;
    printf ("    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n") ;
    printf ("    GNU Lesser General Public License for more details.\n") ;
    printf ("\n") ;
    printf ("    You should have received a copy of the GNU Lesser General Public License\n") ;
    printf ("    along with this program. If not, see <http://www.gnu.org/licenses/>.\n") ;
    printf ("\n") ;
    return 0 ;
  }

  if (geteuid () != 0)
  {
    fprintf (stderr, "%s: Must be root to run. Program should be suid root. This is an error.\n", argv [0]) ;
    return 1 ;
  }

// Initial test for /sys/class/gpio operations:

  /**/ if (strcasecmp (argv [1], "exports"    ) == 0)	{ doExports     (argc, argv) ;	return 0 ; }
  else if (strcasecmp (argv [1], "export"     ) == 0)	{ doExport      (argc, argv) ;	return 0 ; }
  else if (strcasecmp (argv [1], "edge"       ) == 0)	{ doEdge        (argc, argv) ;	return 0 ; }
  else if (strcasecmp (argv [1], "unexport"   ) == 0)	{ doUnexport    (argc, argv) ;	return 0 ; }
  else if (strcasecmp (argv [1], "unexportall") == 0)	{ doUnexportall (argv [0]) ;	return 0 ; }

// Check for load command:

  if (strcasecmp (argv [1], "load" ) == 0)	{ doLoad     (argc, argv) ; return 0 ; }

// Gertboard commands

  if (strcasecmp (argv [1], "gbr" ) == 0)	{ doGbr (argc, argv) ; return 0 ; }
  if (strcasecmp (argv [1], "gbw" ) == 0)	{ doGbw (argc, argv) ; return 0 ; }

// Check for -g argument

  /**/ if (strcasecmp (argv [1], "-g") == 0)
  {
    wiringPiSetupGpio () ;

    for (i = 2 ; i < argc ; ++i)
      argv [i - 1] = argv [i] ;
    --argc ;
    wpMode = WPI_MODE_GPIO ;
  }

// Check for -1 argument

  else if (strcasecmp (argv [1], "-1") == 0)
  {
    wiringPiSetupPhys () ;

    for (i = 2 ; i < argc ; ++i)
      argv [i - 1] = argv [i] ;
    --argc ;
    wpMode = WPI_MODE_PHYS ;
  }

// Check for -p argument for PiFace

  else if (strcasecmp (argv [1], "-p") == 0)
  {
    piFaceSetup (200) ;

    for (i = 2 ; i < argc ; ++i)
      argv [i - 1] = argv [i] ;
    --argc ;
    wpMode = WPI_MODE_PIFACE ;
  }

// Default to wiringPi mode

  else
  {
    wiringPiSetup () ;
    wpMode = WPI_MODE_PINS ;
  }

// Check for -x argument to load in a new extension

  if (strcasecmp (argv [1], "-x") == 0)
  {
    if (argc < 3)
    {
      fprintf (stderr, "%s: -x missing extension specification.\n", argv [0]) ;
      exit (EXIT_FAILURE) ;
    }

    if (!doExtension (argv [0], argv [2]))	// Prints its own error messages
      exit (EXIT_FAILURE) ;

    for (i = 3 ; i < argc ; ++i)
      argv [i - 2] = argv [i] ;
    argc -= 2 ;
  }

  if (argc <= 1)
  {
    fprintf (stderr, "%s: no command given\n", argv [0]) ;
    exit (EXIT_FAILURE) ;
  }

// Core wiringPi functions

  /**/ if (strcasecmp (argv [1], "mode"   ) == 0) doMode      (argc, argv) ;
  else if (strcasecmp (argv [1], "read"   ) == 0) doRead      (argc, argv) ;
  else if (strcasecmp (argv [1], "write"  ) == 0) doWrite     (argc, argv) ;
  else if (strcasecmp (argv [1], "pwm"    ) == 0) doPwm       (argc, argv) ;
  else if (strcasecmp (argv [1], "awrite" ) == 0) doAwrite    (argc, argv) ;
  else if (strcasecmp (argv [1], "aread"  ) == 0) doAread     (argc, argv) ;

// GPIO Nicies

  else if (strcasecmp (argv [1], "toggle" ) == 0) doToggle    (argc, argv) ;

// Pi Specifics

  else if (strcasecmp (argv [1], "pwm-bal"  ) == 0) doPwmMode   (PWM_MODE_BAL) ;
  else if (strcasecmp (argv [1], "pwm-ms"   ) == 0) doPwmMode   (PWM_MODE_MS) ;
  else if (strcasecmp (argv [1], "pwmr"     ) == 0) doPwmRange  (argc, argv) ;
  else if (strcasecmp (argv [1], "pwmc"     ) == 0) doPwmClock  (argc, argv) ;
  else if (strcasecmp (argv [1], "drive"    ) == 0) doPadDrive  (argc, argv) ;
  else if (strcasecmp (argv [1], "readall"  ) == 0) doReadall   () ;
  else if (strcasecmp (argv [1], "i2cdetect") == 0) doI2Cdetect (argc, argv) ;
  else if (strcasecmp (argv [1], "i2cd"     ) == 0) doI2Cdetect (argc, argv) ;
  else if (strcasecmp (argv [1], "reset"    ) == 0) doReset     (argv [0]) ;
  else if (strcasecmp (argv [1], "wb"       ) == 0) doWriteByte (argc, argv) ;
  else if (strcasecmp (argv [1], "clock"    ) == 0) doClock     (argc, argv) ;
  else if (strcasecmp (argv [1], "wfi"      ) == 0) doWfi       (argc, argv) ;
  else
  {
    fprintf (stderr, "%s: Unknown command: %s.\n", argv [0], argv [1]) ;
    exit (EXIT_FAILURE) ;
  }
  return 0 ;
}
Пример #22
0
int main (int argc, char *argv [])
{
    int i ;
    int model, rev, mem, maker, overVolted ;

    if (getenv ("WIRINGPI_DEBUG") != NULL)
    {
        printf ("gpio: wiringPi debug mode enabled\n") ;
        wiringPiDebug = TRUE ;
    }

    if (argc == 1)
    {
        fprintf (stderr, "%s\n", usage) ;
        return 1 ;
    }

    // Help

    if (strcasecmp (argv [1], "-h") == 0)
    {
        printf ("%s: %s\n", argv [0], usage) ;
        return 0 ;
    }

    // Sort of a special:

    if (strcmp (argv [1], "-R") == 0)
    {
        printf ("%d\n", piBoardRev ()) ;
        return 0 ;
    }

    // Version & Warranty

    if (strcmp (argv [1], "-V") == 0)
    {
        printf ("%d\n", piBoardRev ()) ;
        return 0 ;
    }

    if (strcmp (argv [1], "-v") == 0)
    {
        printf ("gpio version: %s\n", VERSION) ;
        printf ("Copyright (c) 2012-2014 Gordon Henderson\n") ;
        printf ("This is free software with ABSOLUTELY NO WARRANTY.\n") ;
        printf ("For details type: %s -warranty\n", argv [0]) ;
        printf ("\n") ;
        piBoardId (&model, &rev, &mem, &maker, &overVolted) ;
        if (model == PI_MODEL_UNKNOWN)
        {
            printf ("Your Raspberry Pi has an unknown model type. Please report this to\n") ;
            printf ("    [email protected]\n") ;
            printf ("with a copy of your /proc/cpuinfo if possible\n") ;
        }
        else
        {
            printf ("Banana Pro Details:\n") ;
            printf ("  Type: %s, Revision: %s, Memory: %dMB, Maker: %s %s\n",
                    piModelNames [model], piRevisionNames [rev], mem, piMakerNames [maker], overVolted ? "[OV]" : "") ;
        }
        return 0 ;
    }

    if (strcasecmp (argv [1], "-warranty") == 0)
    {
        printf ("gpio version: %s\n", VERSION) ;
        printf ("Copyright (c) 2012-2014 Gordon Henderson\n") ;
        printf ("\n") ;
        printf ("    This program is free software; you can redistribute it and/or modify\n") ;
        printf ("    it under the terms of the GNU Leser General Public License as published\n") ;
        printf ("    by the Free Software Foundation, either version 3 of the License, or\n") ;
        printf ("    (at your option) any later version.\n") ;
        printf ("\n") ;
        printf ("    This program is distributed in the hope that it will be useful,\n") ;
        printf ("    but WITHOUT ANY WARRANTY; without even the implied warranty of\n") ;
        printf ("    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n") ;
        printf ("    GNU Lesser General Public License for more details.\n") ;
        printf ("\n") ;
        printf ("    You should have received a copy of the GNU Lesser General Public License\n") ;
        printf ("    along with this program. If not, see <http://www.gnu.org/licenses/>.\n") ;
        printf ("\n") ;
        return 0 ;
    }

    if (geteuid () != 0)
    {
        fprintf (stderr, "%s: Must be root to run. Program should be suid root. This is an error.\n", argv [0]) ;
        return 1 ;
    }

    // Initial test for /sys/class/gpio operations:

    /**/ if (strcasecmp (argv [1], "exports"    ) == 0)
    {
        doExports     (argc, argv) ;
        return 0 ;
    }
    else if (strcasecmp (argv [1], "export"     ) == 0)
    {
        doExport      (argc, argv) ;
        return 0 ;
    }
    else if (strcasecmp (argv [1], "edge"       ) == 0)
    {
        doEdge        (argc, argv) ;
        return 0 ;
    }
    else if (strcasecmp (argv [1], "unexport"   ) == 0)
    {
        doUnexport    (argc, argv) ;
        return 0 ;
    }
    else if (strcasecmp (argv [1], "unexportall") == 0)
    {
        doUnexportall (argv [0]) ;
        return 0 ;
    }

    // Check for load command:

    if (strcasecmp (argv [1], "load" ) == 0)
    {
        doLoad     (argc, argv) ;
        return 0 ;
    }


    // Check for -g argument

    if (strcasecmp (argv [1], "-g") == 0)
    {
        wiringPiSetupGpio () ;

        for (i = 2 ; i < argc ; ++i)
            argv [i - 1] = argv [i] ;
        --argc ;
        wpMode = WPI_MODE_GPIO ;
    }

    // Check for -1 argument

    else if (strcasecmp (argv [1], "-1") == 0)
    {
        wiringPiSetupPhys () ;

        for (i = 2 ; i < argc ; ++i)
            argv [i - 1] = argv [i] ;
        --argc ;
        wpMode = WPI_MODE_PHYS ;
    }

    // Default to wiringPi mode

    else
    {
        wiringPiSetup () ;
        wpMode = WPI_MODE_PINS ;
    }

    // Check for -x argument to load in a new extension

    if (strcasecmp (argv [1], "-x") == 0)
    {
        if (argc < 3)
        {
            fprintf (stderr, "%s: -x missing extension specification.\n", argv [0]) ;
            exit (EXIT_FAILURE) ;
        }

        if (!doExtension (argv [0], argv [2]))	// Prints its own error messages
            exit (EXIT_FAILURE) ;

        for (i = 3 ; i < argc ; ++i)
            argv [i - 2] = argv [i] ;
        argc -= 2 ;
    }

    if (argc <= 1)
    {
        fprintf (stderr, "%s: no command given\n", argv [0]) ;
        exit (EXIT_FAILURE) ;
    }

    // Core wiringPi functions

    /**/ if (strcasecmp (argv [1], "mode"   ) == 0) doMode      (argc, argv) ;
    else if (strcasecmp (argv [1], "read"   ) == 0) doRead      (argc, argv) ;
    else if (strcasecmp (argv [1], "write"  ) == 0) doWrite     (argc, argv) ;
    else if (strcasecmp (argv [1], "pwm"    ) == 0) doPwm       (argc, argv) ;
    else if (strcasecmp (argv [1], "awrite" ) == 0) doAwrite    (argc, argv) ;
    else if (strcasecmp (argv [1], "aread"  ) == 0) doAread     (argc, argv) ;

    // GPIO Nicies

    else if (strcasecmp (argv [1], "toggle" ) == 0) doToggle    (argc, argv) ;

    // Pi Specifics

    else if (strcasecmp (argv [1], "pwm-bal"  ) == 0) doPwmMode    (PWM_MODE_BAL) ;
    else if (strcasecmp (argv [1], "pwm-ms"   ) == 0) doPwmMode    (PWM_MODE_MS) ;
    else if (strcasecmp (argv [1], "pwmr"     ) == 0) doPwmRange   (argc, argv) ;
    else if (strcasecmp (argv [1], "pwmc"     ) == 0) doPwmClock   (argc, argv) ;
    else if (strcasecmp (argv [1], "pwmTone"  ) == 0) doPwmTone    (argc, argv) ;
    else if (strcasecmp (argv [1], "usbp"     ) == 0) doUsbP       (argc, argv) ;
    else if (strcasecmp (argv [1], "readall"  ) == 0) doReadall    () ;
    else if (strcasecmp (argv [1], "nreadall" ) == 0) doReadall    () ;
    else if (strcasecmp (argv [1], "pins"     ) == 0) doPins       () ;
    else if (strcasecmp (argv [1], "i2cdetect") == 0) doI2Cdetect  (argc, argv) ;
    else if (strcasecmp (argv [1], "i2cd"     ) == 0) doI2Cdetect  (argc, argv) ;
    else if (strcasecmp (argv [1], "reset"    ) == 0) doReset      (argv [0]) ;
    else if (strcasecmp (argv [1], "wb"       ) == 0) doWriteByte  (argc, argv) ;
    else
    {
        fprintf (stderr, "%s: Unknown command: %s.\n", argv [0], argv [1]) ;
        exit (EXIT_FAILURE) ;
    }
    return 0 ;
}
Пример #23
0
bool VCardXXPort::exportContacts( const KABC::AddresseeList &addrList, const QString &data )
{
  KABC::VCardConverter converter;
  KURL url;
  KABC::AddresseeList list;

  list = filterContacts( addrList );

  bool ok = true;
  if ( list.isEmpty() ) {
    return ok;
  } else if ( list.count() == 1 ) {
    url = KFileDialog::getSaveURL( list[ 0 ].givenName() + "_" + list[ 0 ].familyName() + ".vcf" );
    if ( url.isEmpty() )
      return true;

    if ( data == "v21" )
      ok = doExport( url, converter.createVCards( list, KABC::VCardConverter::v2_1 ) );
    else
      ok = doExport( url, converter.createVCards( list, KABC::VCardConverter::v3_0 ) );
  } else {
    QString msg = i18n( "You have selected a list of contacts, shall they be "
                        "exported to several files?" );

    switch ( KMessageBox::questionYesNo( parentWidget(), msg, QString::null, i18n("Export to Several Files"), i18n("Export to One File") ) ) {
      case KMessageBox::Yes: {
        KURL baseUrl = KFileDialog::getExistingURL();
        if ( baseUrl.isEmpty() )
          return true;

        KABC::AddresseeList::ConstIterator it;
        uint counter = 0;
        for ( it = list.begin(); it != list.end(); ++it ) {
          QString testUrl;
          if ( (*it).givenName().isEmpty() && (*it).familyName().isEmpty() )
            testUrl = baseUrl.url() + "/" + (*it).organization();
          else
            testUrl = baseUrl.url() + "/" + (*it).givenName() + "_" + (*it).familyName();

          if ( KIO::NetAccess::exists( testUrl + (counter == 0 ? "" : QString::number( counter )) + ".vcf", false, parentWidget() ) ) {
            counter++;
            url = testUrl + QString::number( counter ) + ".vcf";
          } else
            url = testUrl + ".vcf";

          bool tmpOk;
          KABC::AddresseeList tmpList;
          tmpList.append( *it );

          if ( data == "v21" )
            tmpOk = doExport( url, converter.createVCards( tmpList, KABC::VCardConverter::v2_1 ) );
          else
            tmpOk = doExport( url, converter.createVCards( tmpList, KABC::VCardConverter::v3_0 ) );

          ok = ok && tmpOk;
        }
        break;
      }
      case KMessageBox::No:
      default: {
        url = KFileDialog::getSaveURL( "addressbook.vcf" );
        if ( url.isEmpty() )
          return true;

        if ( data == "v21" )
          ok = doExport( url, converter.createVCards( list, KABC::VCardConverter::v2_1 ) );
        else
          ok = doExport( url, converter.createVCards( list, KABC::VCardConverter::v3_0 ) );
      }
    }
  }

  return ok;
}