void
ShapeHandler::addPOI(const SUMOSAXAttributes& attrs) {
    bool ok = true;
    const SUMOReal INVALID_POSITION(-1000000);
    std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
    SUMOReal x = attrs.getOpt<SUMOReal>(SUMO_ATTR_X, id.c_str(), ok, INVALID_POSITION);
    SUMOReal y = attrs.getOpt<SUMOReal>(SUMO_ATTR_Y, id.c_str(), ok, INVALID_POSITION);
    SUMOReal lon = attrs.getOpt<SUMOReal>(SUMO_ATTR_LON, id.c_str(), ok, INVALID_POSITION);
    SUMOReal lat = attrs.getOpt<SUMOReal>(SUMO_ATTR_LAT, id.c_str(), ok, INVALID_POSITION);
    SUMOReal lanePos = attrs.getOpt<SUMOReal>(SUMO_ATTR_POSITION, id.c_str(), ok, INVALID_POSITION);
    SUMOReal layer = attrs.getOpt<SUMOReal>(SUMO_ATTR_LAYER, id.c_str(), ok, (SUMOReal)GLO_POI);
    std::string type = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok, "");
    std::string laneID = attrs.getOpt<std::string>(SUMO_ATTR_LANE, id.c_str(), ok, "");
    RGBColor color = attrs.hasAttribute(SUMO_ATTR_COLOR) ? attrs.get<RGBColor>(SUMO_ATTR_COLOR, id.c_str(), ok) : RGBColor::RED;
    SUMOReal angle = attrs.getOpt<SUMOReal>(SUMO_ATTR_ANGLE, id.c_str(), ok, Shape::DEFAULT_ANGLE);
    std::string imgFile = attrs.getOpt<std::string>(SUMO_ATTR_IMGFILE, id.c_str(), ok, Shape::DEFAULT_IMG_FILE);
    if (imgFile != "" && !FileHelpers::isAbsolute(imgFile)) {
        imgFile = FileHelpers::getConfigurationRelative(getFileName(), imgFile);
    }
    SUMOReal width = attrs.getOpt<SUMOReal>(SUMO_ATTR_WIDTH, id.c_str(), ok, Shape::DEFAULT_IMG_WIDTH);
    SUMOReal height = attrs.getOpt<SUMOReal>(SUMO_ATTR_HEIGHT, id.c_str(), ok, Shape::DEFAULT_IMG_HEIGHT);
    if (!ok) {
        return;
    }
    Position pos(x, y);
    if (x == INVALID_POSITION || y == INVALID_POSITION) {
        // try computing x,y from lane,pos
        if (laneID != "") {
            pos = getLanePos(id, laneID, lanePos);
        } else {
            // try computing x,y from lon,lat
            if (lat == INVALID_POSITION || lon == INVALID_POSITION) {
                WRITE_ERROR("Either (x,y), (lon,lat) or (lane,pos) must be specified for poi '" + id + "'.");
                return;
            } else if (!GeoConvHelper::getFinal().usingGeoProjection()) {
                WRITE_ERROR("(lon, lat) is specified for poi '" + id + "' but no geo-conversion is specified for the network.");
                return;
            }
            pos.set(lon, lat);
            GeoConvHelper::getFinal().x2cartesian_const(pos);
        }
    }
    if (!myShapeContainer.addPOI(id, type, color, layer, angle, imgFile, pos, width, height)) {
        WRITE_ERROR("PoI '" + id + "' already exists.");
    }
}
Beispiel #2
0
QT_BEGIN_NAMESPACE

InputPage::InputPage(AdpReader *reader, QWidget *parent)
    : QWizardPage(parent)
{
    m_adpReader = reader;
    setTitle(tr("Input File"));
    setSubTitle(tr("Specify the .adp or .dcf file you want "
        "to convert to the new Qt help project format and/or "
        "collection format."));

    m_ui.setupUi(this);
    connect(m_ui.browseButton, SIGNAL(clicked()),
        this, SLOT(getFileName()));

    registerField(QLatin1String("adpFileName"), m_ui.fileLineEdit);
}
void DownloadWidget::init()
{
    if (m_download) {
        connect(m_download.data(), SIGNAL(downloadProgress(qint64,qint64)),
                this, SLOT(downloadProgress(qint64,qint64)));
        connect(m_download.data(), SIGNAL(finished()),
                this, SLOT(finished()));
    }

    // reset info
    downloadInfoLabel->clear();
    progressBar->setValue(0);
    getFileName();

    // start timer for the download estimation
    m_downloadTime.start();
}
Beispiel #4
0
void MeshLayerEditDialog::createWithRasters()
{
	// _use_rasters=true is needed for this, this is the default setting however
	if (_n_layers>0)
		this->_radioButtonBox->setEnabled(false);
	const QString selectText = (_n_layers>0) ?
			"Please specify a raster file for mapping each layer:" :
			"Please specify raster file for surface mapping:";
	this->_layerBox = new QGroupBox(this);
	this->_layerBox->setTitle(selectText);

	for (unsigned i = 0; i <= _n_layers; ++i)
	{
		QString text("");
		if (i==0) text = "Surface";
		else if (i == _n_layers) text = "Layer" + QString::number(_n_layers) + "-Bottom";
		else text="Layer" + QString::number(i+1) + "-Top";
		QLineEdit* edit (new QLineEdit(this));
		QPushButton* button (new QPushButton("...", _layerBox));

		this->_edits.push_back(edit);
		this->_fileButtonMap.insert(button, edit);
		connect(button, SIGNAL(clicked()), this, SLOT(getFileName()));

		this->_layerSelectionLayout->addWidget(new QLabel(text, _layerBox),  i, 0);
		this->_layerSelectionLayout->addWidget(_edits[i],   i, 1);
		this->_layerSelectionLayout->addWidget(button, i, 2);

		// don't add bottom layer if mesh contains only surface
		if (this->_n_layers==0) break;
	}
	if (this->_n_layers == 0)
	{
		QLabel* noDataReplacementLabel = new QLabel("Set NoData values to ", _layerBox);
		_noDataReplacementEdit = new QLineEdit("0.0", _layerBox);
		_noDataReplacementEdit->setValidator(new QDoubleValidator(_noDataReplacementEdit));

		this->_layerSelectionLayout->addWidget(noDataReplacementLabel, 1, 0);
		this->_layerSelectionLayout->addWidget(_noDataReplacementEdit, 1, 1);
	}
	this->_layerBox->setLayout(this->_layerSelectionLayout);
	this->gridLayoutLayerMapping->addWidget(_layerBox, 4, 0, 1, 3);
	if (this->_n_layers > 0)
		this->createMeshToolSelection();
}
//http://courses.cs.vt.edu/cs2604/fall02/binio.html
//Binary files
int FileIO::dataOpenFile()
{
   std::string fileName;// = getFileName();
   std::string input;
   bool newFile=false;
   
   while (true){
      fileName = getFileName();
      system("CLS");
      cout<<"I will now try to open the file \""<<fileName<<"\"."<<endl;
      cout<<"Is this right? Enter Y to continue, Q to quit, and anything else to try again."<<endl;
      cout<<"If the file does not exist, please press C instead."<<endl;
      cin>>input;
      if (input=="Y"||input=="y"){
         break;
      }
      if (input=="C"||input=="c"){
         newFile=true;
         break;
      }
      if (input=="Q"||input=="q"){
         return 0;
      }
      
   }
   
   if (newFile){
      myfile.open(filePath.c_str(), ios::out | ios::binary);//creates the file
      myfile.close();
      myfile.open(filePath.c_str(), ios::out | ios::in | ios::binary);//Actually leaves it open.
      isBinary=true;
      fileLength=0;
      fileConstructor();
      return 1;
   }
   
   myfile.open(filePath.c_str(), ios::out | ios::in | ios::binary);
   isBinary=true;
   
   myfile.seekg (0, myfile.end);
   fileLength = myfile.tellg();//Finds the length of the file.
   myfile.seekg (0, myfile.beg);
   fileConstructor();
   return 1;
}
Beispiel #6
0
static int ProcessPhotoFile(const char *filePath)
{
	ZInfo4(DBG_MISC, "photo: %s", filePath);

	ZDB_METAPHOTO 	*metadata = NULL;
	char		 	filename[MAX_PATH_SIZE] = {0};
	char 			dstPath[MAX_PATH_SIZE] = {0};
	int 			isDir;

	if((metadata = GetPhotoMetadata((char *)filePath)) == NULL) {
		ZError(DBG_MISC, "Get audio metadata failed!");
		return -1;
	}

	getFileName(filePath, &filename[0]);
	sprintf(dstPath, "%s/%s", PHOTO_SORT_FOLDER, filename);
	
	if(ZUtilIsFilePresent(dstPath, &isDir)) {
		getNewFileName(pzfs, filename);
		sprintf(dstPath, "%s/%s", PHOTO_SORT_FOLDER, filename);
		ZInfo3(DBG_MISC, "File exist, will use new filename [%s]", filename);
	}

	if(metadata->res)
		free(metadata->res);
	metadata->res = strdup(dstPath);
	
	if (rename (filePath, dstPath) != 0) {
		ZError (DBG_MISC, "Move file failed -> %s -> %s", filePath, dstPath);
	}
	
	//add by Joe on 2008-10-30
#ifdef 		Z_CFG_PHOTO_THUMBNAIL
	createThumbnailPhoto(dstPath, &metadata->attr2);
#endif
	//end
	
	if(ZDBInsertPhoto(zfs.zPDBHandle, metadata)) {
		ZError(DBG_MISC, "Insert photo to DB failed!");
		free(metadata);
		return -2;
	}
	free(metadata);
	return 0;
}
//<<<<<<<<<<<<<<<<<<<<<<<< myKeyboard >>>>>>>>>>>>>>>>>>>>>>
void myKeyboard(unsigned char key, int x, int y)
{
	// let user type 2-char string to specify a command
	static int numGot = 0; // # of char's so far typed
	static string s = "";
	
	if(key == 27) exit(-1);
	if(key == '.'|| key == ' '){numGot = 0; return;} // reset the 2-char string
	if(numGot % 2 == 0)	{s = ""; numGot = 0;}
	s += key; numGot++;
	if(numGot == 1) return; // still need another char for command
	//-------------------------------------------
	//now have two letter command; process it
	if(s == "LS"){/* increase light strength */}
	else if(s == "ls"){/* decrease light strength */}
	else if(s == "qu") exit(-1);
	else if(s == "AM") amount *= 2;
	else if(s == "am") amount /= 2;
	else if(s == "sf") cam.slide(0,0, -amount);  // slide camera forward
	else if(s == "sb") cam.slide(0,0,amount);  //slide camera back
	else if(s == "sl") cam.slide(-amount,0,0);  // slide camera to left
	else if(s == "sr") cam.slide( amount, 0,0);  //slide camera right
	else if(s == "su") cam.slide(0, amount,0);  //slide camera up
	else if(s == "sd") cam.slide(0,-amount,0);  //slide camera down
	else if(s == "pu") cam.pitch(-10 * amount);
	else if(s == "pd") cam.pitch( 10 * amount);
	else if(s == "rl") cam.roll( 10 * amount);  //roll CCW
	else if(s == "rr") cam.roll(-10 * amount);  //roll CW
	else if(s == "yl") cam.yaw( -10 * amount);
	else if(s == "yr") cam.yaw(  10 * amount);
	else if(s == "c1") cam.set(20.0,15.0,20.0,0,0,0,0,1,0);
  	else if(s == "c2") cam.set(20,20,0,0,0,0,0,1,0);
	else if(s == "CV"){/* open camera viewangle */}
	else if(s == "cv"){/* close camera viewangle */}
	else if(s == "r1"){ blockSize = 1; doRayTrace = 1;}
	else if(s == "r4"){ blockSize = 4; doRayTrace = 1;}
	else if(s == "r2"){ blockSize = 2; doRayTrace = 1;}
	else if(s == "r8"){ blockSize = 8; doRayTrace = 1;}
	else if(s == "rs") {
		getFileName(fname);
		scn.read(fname);
	}
	else cout << "\nnot a valid command\n";
	glutPostRedisplay();
}
Beispiel #8
0
MshEditDialog::MshEditDialog(const MeshLib::CFEMesh* mesh, QDialog* parent)
	: QDialog(parent), _msh(mesh), _noDataDeleteBox(NULL)
{
	setupUi(this);

	this->gridLayoutLayerMapping->setMargin(5);
	this->gridLayoutLayerMapping->setColumnMinimumWidth(2,10);
	this->gridLayoutLayerMapping->setColumnStretch(0, 80);
	this->gridLayoutLayerMapping->setColumnStretch(1, 200);
	this->gridLayoutLayerMapping->setColumnStretch(2, 10);

	size_t nLayers = mesh->getNumberOfMeshLayers();

	for (size_t i = 0; i <= nLayers+1; i++)
	{
		QString text("");
		if (i==0) text="Surface";
		else if (i>nLayers) text="Layer" + QString::number(nLayers) + "-Bottom";
		else text="Layer" + QString::number(i) + "-Top";
		QLabel* label = new QLabel(text);
		QLineEdit* edit = new QLineEdit();
		QPushButton* button = new QPushButton("...");

		_labels.push_back(label);
		_edits.push_back(edit);
		_buttons.push_back(button);
		_fileButtonMap.insert(button, edit);
		connect(button, SIGNAL(clicked()), this, SLOT(getFileName()));

		this->gridLayoutLayerMapping->addWidget(_labels[i],   i, 0);
		this->gridLayoutLayerMapping->addWidget(_edits[i],    i, 1);
		this->gridLayoutLayerMapping->addWidget(_buttons[i],  i, 2);

		if (nLayers==0) break; // don't add bottom layer if mesh contains only surface
	}

	_noDataDeleteBox = new QCheckBox("Remove mesh nodes at NoData values");
	_noDataDeleteBox->setChecked(false);
	_noDataDeleteBox->setEnabled(false);
	if (nLayers == 0)
	{
		_noDataDeleteBox->setEnabled(true);
		this->gridLayoutLayerMapping->addWidget(_noDataDeleteBox, 2, 1);
	}
}
/** 
To prepare for the responce message
Input : http get msg
**/
char *responceMsg(char *getMsg){
	char *fileName = getFileName(getMsg);
	if(fileName!=NULL && strlen(fileName)!=0){
		char *contents = getFileContents(fileName);
		free(fileName-1);
		char *respMsg;
		if(contents!=NULL){
			respMsg =  createResponceMsg(contents);	
		}else{
			respMsg = createFileNotFoundMsg();
		}
		return respMsg;
	}else{
		char *respMsg  = createBadRequestMsg();
		return respMsg;
	}
	return NULL;
}
Beispiel #10
0
Magic3D::XMLElement* Magic3D::Model::save(XMLElement* root)
{
    Object::save(root);

    if (root)
    {
        XMLElement* model = root->GetDocument()->NewElement(M3D_MODEL_XML);
        root->LinkEndChild(model);

        saveString(model, M3D_MODEL_XML_FILE, getFileName());

        if (getSkeleton())
        {
            getSkeleton()->save(model);
        }
    }
    return root;
}
Beispiel #11
0
std::string
CADReader::fileinarchive(DOMElement* element)
throw(CADReadException)
{
	std::string file_name = XMLString::transcode(element->getAttribute(X("name")));
	std::string file = path_ + getFileName( file_name );

	//
	// extract the file
	//
	if (package_->extractFile(file_name, file) != 0)
	{
		NORMAL_ERR2( "CADReader: error during extracting file ", file_name );
		throw CADReadException();
	}

	return file;
}
Beispiel #12
0
Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);

    udpSocket = new QUdpSocket(this);
    port = 45454;
    udpSocket->bind(port, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint);
    connect(udpSocket, SIGNAL(readyRead()), this, SLOT(processPendingDatagrams()));
    sendMessage(NewParticipant);

    server = new TcpServer(this);
    connect(server, SIGNAL(sendFileName(QString)), this, SLOT(getFileName(QString)));

    connect(ui->messageTextEdit, SIGNAL(currentCharFormatChanged(QTextCharFormat)),
            this, SLOT(currentFormatChanged(const QTextCharFormat)));
}
Beispiel #13
0
void processTestException(const char* file, size_t line, const tchar* error)
{
	s_currentResult = FAILED;

	const tchar*  result = TXT("FAILED");
	const char*   filename = getFileName(file);
	const tstring assert = Core::fmt(TXT(" %s [%hs, %3u] Threw: %s"), result, filename, line, error);

	s_currentTestCaseAsserts.push_back(assert);

	if (s_verbose)
	{
		tcout << assert << std::endl;
	}

	if (s_debug)
		::DebugBreak();
}
Beispiel #14
0
void BitmapAnnotation::duplicate()
{
  BitmapAnnotation *pBitmapAnnotation = new BitmapAnnotation(mClassFileName, "", false, mpGraphicsView);
  QPointF gridStep(mpGraphicsView->getCoOrdinateSystem()->getHorizontalGridStep(),
                   mpGraphicsView->getCoOrdinateSystem()->getVerticalGridStep());
  pBitmapAnnotation->setOrigin(mOrigin + gridStep);
  pBitmapAnnotation->setRotationAngle(mRotation);
  pBitmapAnnotation->initializeTransformation();
  pBitmapAnnotation->setExtents(getExtents());
  pBitmapAnnotation->setFileName(getFileName());
  pBitmapAnnotation->setImageSource(getImageSource());
  pBitmapAnnotation->setImage(getImage());
  pBitmapAnnotation->drawCornerItems();
  pBitmapAnnotation->setCornerItemsPassive();
  pBitmapAnnotation->update();
  mpGraphicsView->addClassAnnotation();
  mpGraphicsView->setCanAddClassAnnotation(true);
}
Beispiel #15
0
Widget::Widget(QWidget *parent, QString usrname)
    : QWidget(parent),
      ui(new Ui::Widget)
{
    ui->setupUi(this);
    uName = usrname;
    udpSocket = new QUdpSocket(this);
    port = 23232;
    udpSocket->bind(port, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint);
    connect(udpSocket, SIGNAL(readyRead()), this, SLOT(processPendingDategrams()));
    sndMsg(UsrEnter);

    srv = new Server(this);
    connect(srv, SIGNAL(sndFileName(QString)), this, SLOT(getFileName(QString)));

    connect(ui->msgTxtEdit, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this,
            SLOT(curFmtChanged(const QTextCharFormat)));
}
Beispiel #16
0
FILE * FITSLargeHeaderR( char * FITSDir, char * FITSFileName, long maxKeys, 
		long * nHeader, struct keyword * headerCards[])
/*  *    *    *    *    *    *    *    *    *    *    *    *    *    *    *  */
/* FITSLargeHeaderR() reads and returns all FITS file header cards           */
/* INPUTS: FITSDir - directory where data will be placed. Lowest level dir   */
/*         will be created if not present.                                   */
/*         FITSFileName - name of file to be read. if Null, then error       */
/*         nHeader - number of FITS file header cards to read from the file  */
/*  *    *    *    *    *    *    *    *    *    *    *    *    *    *    *  */
{ char fileName[256] = "", inType[100] = "";
  FILE * largeFITSFile = NULL;

  getFileName( FITSDir, FITSFileName, inType, fileName);

  largeFITSFile = openFITS( fileName, maxKeys, nHeader, headerCards);

  return(largeFITSFile);
} /* end of FITSLargeHeaderR() */
int main()
{
	do
	{
		string fileName = getFileName();

		vector<int> numberArray;
		initializeArray(fileName, numberArray);

		cout << "The lowest number is: " << getLowest(numberArray) << endl;
		cout << "The highest number is: " << getHighest(numberArray) << endl;
		cout << "The sum of all these numbers is: " << getSum(numberArray) << endl;
		cout << "The average of all these numbers is: " << setprecision(10) << fixed << getAverage(numberArray) << endl;

	} while (!wantToExit());

	return 0;
}
int FileIO::textOpenFile()
{
   std::string fileName;
   std::string input;
   bool newFile=false;
   
   while (true){
      fileName = getFileName();
      system("CLS");
      cout<<"I will now try to open the file \""<<fileName<<"\"."<<endl;
      cout<<"Is this right? Enter Y to continue, Q to quit, and anything else to try again."<<endl;
      cout<<"If the file does not exist, please press C instead."<<endl;
      cin>>input;
      if (input=="Y"||input=="y"){
         break;
      }
      if (input=="C"||input=="c"){
         newFile=true;
         break;
      }
      if (input=="Q"||input=="q"){
         return 0;
      }
   }
   
   //fileName = getFileName();
   if (newFile){
      myfile.open(filePath.c_str(), ios::out);//creates the file
      myfile.close();
      myfile.open(filePath.c_str(), ios::out | ios::in);
      isBinary=false;
      fileLength=0;
      fileConstructor();
      return 1;
   }
   
   myfile.open(filePath.c_str(), ios::out | ios::in);
   if (myfile.is_open()){
      isBinary=false;
      fileConstructor();
      return 1;
   }
}
ExportMeanDialog::ExportMeanDialog(QWidget* parent, const char* name)
    : QWidget(parent, name)
{
    // just need some buttons and a qline edit..
    setCaption("Export Means");
    QPushButton* requestButton = new QPushButton("Export Means", this, "requestButton");
    connect(requestButton, SIGNAL(clicked()), this, SLOT(requestMeans()) );

    QPushButton* cancelButton = new QPushButton("Cancel", this, "cancelButton");
    connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancelRequest()) );

    QPushButton* fileButton = new QPushButton("Specify File", this, "fileButton");
    connect(fileButton, SIGNAL(clicked()), this, SLOT(getFileName()) );

    fileName = new QLineEdit(this, "fileName");

    // a button Group and a number of buttons..
    QLabel* normLabel = new QLabel("Normalisation Method", this, "normLabel");
    QButtonGroup* normGroup = new QButtonGroup("normGroup");
    zscore = new QRadioButton("z-score", this, "zscore");
    mscore = new QRadioButton("m-score", this, "mscore");
    raw = new QRadioButton("raw", this, "raw");
    // this is very ugly, but I can't seem to get it to work.. so well otherwise.
    normGroup->insert(zscore);
    normGroup->insert(mscore);
    normGroup->insert(raw);

    // and set up some sort of layout .. 
    QVBoxLayout* vbox = new QVBoxLayout(this, 2, 2, "vbox");
    vbox->addWidget(normLabel);
    vbox->addWidget(zscore);
    vbox->addWidget(mscore);
    vbox->addWidget(raw);

    QHBoxLayout* fileBox = new QHBoxLayout(vbox);
    fileBox->addWidget(fileName);
    fileBox->addWidget(fileButton);
    vbox->addStretch();
    QHBoxLayout* buttonBox = new QHBoxLayout(vbox);
    buttonBox->addWidget(cancelButton);
    buttonBox->addStretch();
    buttonBox->addWidget(requestButton);
}
// called by CProjectDoc::OnOpenDocument() for each \+Lang field it encounters
// This STATIC method will read the parameters and then try to open the language
// file.
CLangModelsDoc* CLangModelsDoc::loadDocument(LPCTSTR lpszField,  LPCTSTR sProjectPath)
{
	CString sPath(lpszField); // sAbrev,
//	CParseStream stream(lpszField);
//	stream.word(sAbrev, FALSE);	// i'm  thinking the abrev appearing in the project file is not used anymore
//	stream.getQuotedString(sPath);
	//CCarlaLanguage *pLang = new CCarlaLanguage(sAbrev);
	CFileStatus status;
	// is the file there?
	if(!CFile::GetStatus(sPath, status))
	{
	// if not, look in the same directory as this project
		//CString sPossiblePath = getLang()->getFilePath(getLang()->getLanguageDirectory(sProjectPath, FALSE));
		CString sPossiblePath = ::getDirectory(sProjectPath);
		sPossiblePath += getFileName(sPath);
		sPossiblePath += " control files\\";
		sPossiblePath += getFullFileName(sPath);
		// if it's there, switch the path and don't bother the user
		if(CFile::GetStatus(sPossiblePath, status))
			sPath = sPossiblePath;
		else
		{	// ask the user to find it

			if(!theApp.askUserToFindFile(sPath, CLangModelsDoc::getRegFileTypeID()))
			{
				THROWSTRING3("The language file", getFullFileName(sPath), " could not be found.");
			}
		}
	}

	CLangModelsDoc *pLangDoc = (CLangModelsDoc *)theApp.internalOpenDocumentFile(sPath);
	if(!pLangDoc)
	{
		checkForFileError(sPath);
		THROWSTRING3("The language file ", sPath, " could not be opened.");
	}
	else if(!pLangDoc->IsKindOf(RUNTIME_CLASS(CLangModelsDoc)))
	{
		ASSERTX(FALSE); // to do notify user or something
	}

	return pLangDoc;
}
Beispiel #21
0
void ZGui::slot_fileOpen()
{
	ZFileOpenDialog *zfod  = new ZFileOpenDialog();
	zfod->exec();
	if ( zfod->result() == 1 )
	{
		if ( zfod->getFileName() != "" )
		{
			if ( !edit->text().isEmpty() )
				slot_newDlg();
			slot_fileNew();
    		sFileName = getFileName(zfod->getFileName());
    		sFilePath = getFilePath(zfod->getFileName());
    		load(sFilePath+sFileName);
		}
	}
	delete zfod;
	zfod = NULL;
}
Beispiel #22
0
Reader::Reader(const Options& options)
    : pdal::Reader(options)
    , m_format(TERRASOLID_Format_Unknown)
    , m_haveColor(false)
    , m_haveTime(false)
{
    std::string filename= getFileName();

    std::istream* stream = FileUtils::openFile(filename);

    stream->seekg(0);

    TerraSolidHeaderPtr h(new TerraSolidHeader);
    m_header.swap(h);
    Utils::read_n(*m_header, *stream, sizeof(TerraSolidHeader));

    if (m_header->RecogVal != 970401)
        throw terrasolid_error("Header identifier was not '970401', is this a TerraSolid .bin file?");


    setNumPoints(m_header->PntCnt);

    m_haveColor = (m_header->Color != 0);
    m_haveTime = (m_header->Time != 0);
    m_format = static_cast<TERRASOLID_Format_Type>(m_header->HdrVersion);


    if (!((m_format==TERRASOLID_Format_1) || (m_format == TERRASOLID_Format_2)))
    {
        std::ostringstream oss;
        oss << "Version was '" << m_format << "', not '" << TERRASOLID_Format_1 << "' or '" << TERRASOLID_Format_2 << "'";
        throw terrasolid_error(oss.str());

    }

    registerFields();

    m_offset = 56;
    const Schema& schema = getSchema();
    m_size = schema.getByteSize();

    delete stream;
}
Beispiel #23
0
std::string
CCDReader::descriptor (DOMElement* element)
throw(CCDReadException)
{
    std::string cfile;
    DOMNode* child = element->getFirstChild();
    while (child != 0)
    {
        if (child->getNodeType() == DOMNode::ELEMENT_NODE)
        {
            //
            // link
            //
            if (!XMLString::compareString(child->getNodeName(), X("link")))
            {
                cfile = link((DOMElement*)(child));
            }

            //
            // fileinarchive
            //
            else if (!XMLString::compareString(child->getNodeName(), X("fileinarchive")))
            {
                std::string cfile_name = fileinarchive((DOMElement*)(child));
                cfile = path_ + getFileName( cfile );

                //
                // extract the file
                //
                if (package_->extractFile(cfile_name, cfile) != 0)
                {
                    std::cerr << "Error during extracting file " << cfile_name << std::endl;
                    throw CCDReadException();
                }
            }
        }

        // get next child
        child = child->getNextSibling();
    }

    return cfile;
}
Beispiel #24
0
void LLTextParser::loadKeywords()
{
    if (mLoaded)
    {   // keywords already loaded
        return;
    }
    std::string filename=getFileName();
    if (!filename.empty())
    {
        llifstream file;
        file.open(filename.c_str());
        if (file.is_open())
        {
            LLSDSerialize::fromXML(mHighlights, file);
        }
        file.close();
        mLoaded = true;
    }
}
Beispiel #25
0
FileDialog::FileDialog(QWidget *parent) :
    QWidget(parent), model(new QDirModel()), treeview(new QTreeView()),
    okButton(new QPushButton("OK")), pathField(new QLineEdit()), path("")

{
    treeview->setModel(model);
    QObject::connect(treeview, SIGNAL(clicked(QModelIndex)),
                     this, SLOT(getFileName(QModelIndex)));
    QObject::connect(okButton, SIGNAL(clicked()), this, SLOT(sendFileName()));
    QVBoxLayout *vlayout = new QVBoxLayout(this);
    this->setLayout(vlayout);
    vlayout->addWidget(treeview, 2);
    QHBoxLayout* hlayout = new QHBoxLayout();
    vlayout->addLayout(hlayout, 1);
    hlayout->addWidget(pathField, 2);
    hlayout->addWidget(okButton);
    this->setFixedSize(600, 400);

}
Beispiel #26
0
void
CADReader::readCAD(std::string package, AssemblyData* data, std::string path)
throw(CADReadException)
{
	data_ = data;
	path_ = path;
	package_ = new Package(package);

	//
	// find and extract the assembly descriptor
    //
	std::string cadfile_name = package_->getFileNameWithSuffix( ".cad" );
	std::string cadfile = path_ + getFileName( cadfile_name );
    if ( cadfile_name == std::string( "" ) )
	{
		NORMAL_ERR( "CADReader: the format of the package file is not correct" );
        throw CADReadException();
	}
    if ( package_->extractFile( cadfile_name, cadfile) != 0 )
	{
		NORMAL_ERR2( "CADReader: error during extracting descriptor file ", cadfile_name );
        throw CADReadException();
	}

	//
	// parse the component assembly descriptor
    //
	DOMXMLParser parser;
	char* xmlfile = strdup(cadfile.c_str());
    if ( parser.parse( xmlfile ) != 0 ) 
	{
		NORMAL_ERR2( "CADReader: error during parsing ", cadfile );
        throw CADReadException();
	}
	cad_document_ = parser.getDocument();

	// handle componentassembly
	componentassembly(cad_document_->getDocumentElement());

	// remove assembly descriptor and package
    removeFileOrDirectory(cadfile);
	delete package_;
}
Beispiel #27
0
void TextEdit::createWindow()
{
    if (GWindow::m_Display == 0)
    {  if (!GWindow::initX()) { perror("A connection with X server could not be established"); exit(1); } }

    // Load font, calculate window size, etc.
    initialize();

    strncpy(m_WindowTitle, getFileName(), 127);
    setBgColorName("LightGray");
    setFgColorName("black");

    GWindow::createWindow();

    // Save background and foreground colors
    bgColor = getBackground();
    fgColor = getForeground();

    // Status line colors               /usr/X11R6/lib/X11/rgb.txt
    bgStatusLineColor = allocateColor("MidnightBlue");
    fgStatusLineColor = allocateColor("white");

    setFont(textFont);

    // Hints for window manager
    XSizeHints sizeHints;
    memset(&sizeHints, 0, sizeof(sizeHints));

    // Minimal size 16 * 1
    sizeHints.min_width = 44*dx + leftMargin + rightMargin;
    sizeHints.min_height = 1*dy + topMargin + bottomMargin;

    // Base size
    sizeHints.base_width = 0*dx + leftMargin + rightMargin;
    sizeHints.base_height = 0*dy + topMargin + bottomMargin;

    // Resize increment
    sizeHints.width_inc = dx;
    sizeHints.height_inc = dy;

    sizeHints.flags = (PMinSize | PBaseSize | PResizeInc);
    XSetWMNormalHints(m_Display, m_Window, &sizeHints);
}
  bool openEdgeFile(int iter_counter) {
 	 if (block_id < 0) {
 		 return false;
 	 }
 	 std::string fileName = getFileName(block_id);
 	 if (fin.is_open()) {
 		 fin.close();
 	 }
 	 fin.open(fileName.c_str(), std::ios::binary);
 	 if (!fin) {
 		 return false;
 	 } else {
 		 //logstream(LOG_INFO) << "open edge block-" << block_id << std::endl;
 		 struct stat info;
 		 stat(fileName.c_str(), &info);
 		 read_bytes = read_bytes + info.st_size;
 		 return true;
 	 }
  }
Beispiel #29
0
void getPrevSound(int x, int y)
{
	if(hold && getControlID() != CONTROL_L)
		return;
	
	if(sndMode == TYPE_PLS)
	{
		previousPlaylistField();
		return;
	}
	
	if(soundMode == SOUND_ONESHOT)
		return;
	
	destroySound();
	
	switch(soundMode)
	{
		case SOUND_NEXTFILE:
			if(getPrevSong()) // if there is a prev song
				soundLoaded = false;
			else
			{
				exitSound(0,0);
			}
			break;
		case SOUND_RANDFILE:
			int tmpCur = 0;
			
			if(prevRandomList(getFileName(), &tmpCur))
			{
				moveCursorAbsolute(tmpCur);
				soundLoaded = false;
			}
			else
			{
				destroyRandomList();
				exitSound(0,0);
			}
			break;
	}
}
Beispiel #30
0
// get files name list given the path;
// path like, F:\\DataSet\\retrievalResuts_videos_ranking;
void   CCFileClass::getFileName(string path,int layer,vector<string>&  filename)
{
	int                  nFileNum = 0;   //指示要查找的file个数;
	struct _finddata_t   filefind;   
	string               curr = path + "\\*.*";   
	int                  done = 0;
	int                  handle = 0;   

	if((handle=_findfirst(curr.c_str(),&filefind))==-1)
		return; 

	while(!(done=_findnext(handle,&filefind)))   
	{   
		if(!strcmp(filefind.name,".."))
		{
			continue;
		}
		if((_A_SUBDIR==filefind.attrib))   // 是目录;
		{           
			if (layer !=0)
			{
				curr = path + "\\" + filefind.name; 

				getFileName(curr,layer+1,filename);
			}
			
		}   
		else     // 不是目录,是文件;
		{   
			if (layer != 1)
			{
				nFileNum = filename.size() + 1;

				filename.resize(nFileNum);

				filename[nFileNum-1] = path + "\\" + filefind.name;
			}
			
		}   
	}           
	_findclose(handle);      
}