コード例 #1
0
ファイル: ui_utils.cpp プロジェクト: HeryLong/booxsdk
int statusBarHeight()
{
    if (sys::isIRTouch())
    {
        if(isHD())
        {
            return 60;
        }
        return 45;
    }
    return 35;
}
コード例 #2
0
ファイル: XEMStrategy.cpp プロジェクト: openturns/otmixmod
void XEMStrategy::setStrategyInit(XEMStrategyInitName initName, XEMData *& data, int64_t nbNbCluster, int64_t * tabNbCluster, XEMModelType ** tabModelType){
  int64_t nbSample    = data->_nbSample;
  int64_t pbDimension  = data->_pbDimension;
  string fileName = "";
  XEMParameter ** tabInitParameter = NULL;
  XEMPartition ** tabInitPartition = NULL;

  switch (initName){
  case RANDOM :
  case CEM_INIT :
  case SEM_MAX :
  case SMALL_EM :
    _strategyInit->setStrategyInitName(initName);
    break;

  case  USER :
    _strategyInit->setStrategyInitName(initName);
    tabInitParameter = new XEMParameter * [nbNbCluster];

    for (int64_t k=0; k<nbNbCluster; k++){
      if (isEDDA(tabModelType[0]->_nameModel)){
        tabInitParameter[k] = new XEMGaussianGeneralParameter(tabNbCluster[k], pbDimension, tabModelType[0], fileName);
      }
      else if (isBinary(tabModelType[0]->_nameModel)){
        int64_t * tabNbModality = ((XEMBinaryData*)data)->getTabNbModality();
        tabInitParameter[k] = new XEMBinaryEkjhParameter(tabNbCluster[k], pbDimension, tabModelType[0], tabNbModality, fileName);
      }
      else if (isHD(tabModelType[0]->_nameModel)){
        tabInitParameter[k] = new XEMGaussianHDDAParameter(tabNbCluster[k], pbDimension, tabModelType[0], fileName);
      }
      else throw internalMixmodError;
    }
    _strategyInit->setTabInitParameter(tabInitParameter, nbNbCluster);
    break;

  case USER_PARTITION :
    _strategyInit->setStrategyInitName(initName);
    tabInitPartition = new XEMPartition * [nbNbCluster];
    for (int64_t k=0; k<nbNbCluster; k++){
      XEMNumericPartitionFile partitionFile;
      partitionFile._fileName = fileName;
      partitionFile._format = FormatNumeric::defaultFormatNumericFile;
      partitionFile._type = TypePartition::defaultTypePartition;
      tabInitPartition[k] = new XEMPartition(nbSample, tabNbCluster[k], partitionFile);
    }
    _strategyInit->setTabPartition(tabInitPartition, nbNbCluster);
    break;
  }
}
コード例 #3
0
ファイル: XEMModel.cpp プロジェクト: openturns/otmixmod
//------------
// Constructor
//------------
XEMModel::XEMModel(XEMModelType * modelType, int64_t  nbCluster, XEMData *& data, XEMPartition *& knownPartition) {
    int64_t  k;
    int64_t  i;
    _deleteData = false;
    _nbCluster     = nbCluster;
    _data          = data;
    _nbSample      = _data->_nbSample;
    _algoName = UNKNOWN_ALGO_NAME;

    _tabFik = new double*[_nbSample];
    _tabCik = new double*[_nbSample];
    _tabSumF = new double[_nbSample];
    _tabTik = new double*[_nbSample];
    _tabZikKnown = new int64_t *[_nbSample];
    _tabZiKnown = new bool[_nbSample];
    _tabNk = new double[_nbCluster];

    for (i=0; i<_nbSample; i++) {
        _tabFik[i] = new double[_nbCluster];
        _tabTik[i] = new double[_nbCluster];
        _tabZikKnown[i] = new int64_t [_nbCluster];
        _tabCik[i] = new double[_nbCluster];
        for (k=0; k<_nbCluster; k++) {
            _tabFik[i][k] = 0.0;
            _tabTik[i][k] = 0.0;
            _tabZikKnown[i][k] = 0;
            _tabCik[i][k] = 0.0;
        }
        _tabZiKnown[i] = false;
        _tabSumF[i]     = 0.0;
    }

    // _tabNk[k] = 0 even if knownPartition because this partition could be partial
    for (k=0; k<_nbCluster; k++) {
        _tabNk[k] = 0.0;
    }

    FixKnownPartition(knownPartition);
    XEMModelName modelName = modelType->_nameModel;
    // create Param
    if (isSpherical(modelName)) {
        _parameter = new XEMGaussianSphericalParameter(this, modelType);
    }
    if (isDiagonal(modelName)) {
        _parameter = new XEMGaussianDiagParameter(this, modelType);
    }
    if (isGeneral(modelName)) {
        _parameter = new XEMGaussianGeneralParameter(this, modelType);
    }


    //HDDA models
    if (isHD(modelName)) {
        _parameter = new XEMGaussianHDDAParameter(this, modelType);
    }


    switch(modelName) {
    // Binary models //
    case (Binary_p_E):
        _parameter = new XEMBinaryEParameter(this, modelType, ((XEMBinaryData*)data)->getTabNbModality());
        break;
    case (Binary_p_Ek):
        _parameter = new XEMBinaryEkParameter(this, modelType, ((XEMBinaryData*)data)->getTabNbModality());
        break;
    case (Binary_p_Ej):
        _parameter = new XEMBinaryEjParameter(this, modelType, ((XEMBinaryData*)data)->getTabNbModality());
        break;
    case (Binary_p_Ekj):
        _parameter = new XEMBinaryEkjParameter(this, modelType, ((XEMBinaryData*)data)->getTabNbModality());
        break;
    case (Binary_p_Ekjh):
        _parameter = new XEMBinaryEkjhParameter(this, modelType, ((XEMBinaryData*)data)->getTabNbModality());
        break;
    case (Binary_pk_E):
        _parameter = new XEMBinaryEParameter(this, modelType, ((XEMBinaryData*)data)->getTabNbModality());
        break;
    case (Binary_pk_Ek):
        _parameter = new XEMBinaryEkParameter(this, modelType, ((XEMBinaryData*)data)->getTabNbModality());
        break;
    case (Binary_pk_Ej):
        _parameter = new XEMBinaryEjParameter(this, modelType, ((XEMBinaryData*)data)->getTabNbModality());
        break;
    case (Binary_pk_Ekj):
        _parameter = new XEMBinaryEkjParameter(this, modelType, ((XEMBinaryData*)data)->getTabNbModality());
        break;
    case (Binary_pk_Ekjh):
        _parameter = new XEMBinaryEkjhParameter(this, modelType, ((XEMBinaryData*)data)->getTabNbModality());
        break;
    }
}
コード例 #4
0
ファイル: aokts.cpp プロジェクト: DoctorWillCU/aokts
/*
	FileSave: Handles a request to save the currently open file.

	Parameters:
	HWND sheet: Handle to the property sheet.
	bool as:		Save or Save As?
*/
void FileSave(HWND sheet, bool as, bool write)
{
	int error;			//error value from Scenario::save()
	HWND cpage;			//the current property page
	HCURSOR previous;	//the mouse cursor before/after save operation
	OPENFILENAME ofn;
	char titleBuffer[100];
	Game startver;
	Game conv = NOCONV;
    SaveFlags::Value flags = SaveFlags::NONE;

    char w1[] = {84, 104, 105, 115, 32, 115, 99, 101, 110, 97, 114, 105, 111, 32, 105, 115, 32, 112, 114, 111, 116, 101, 99, 116, 101, 100, 0};
    char w2[] = {83, 99, 101, 110, 97, 114, 105, 111, 32, 105, 115, 32, 112, 114, 111, 116, 101, 99, 116, 101, 100, 0};
    if (setts.disabletips) {
        MessageBox(sheet, w1, w2, MB_ICONWARNING);
        return;
    }

	//init
	cpage = PropSheet_GetCurrentPageHwnd(sheet);

	//Save As: Ask for filename.
	if (as || *setts.ScenPath == '\0')
	{
		char dir[_MAX_PATH];
		strcpy(dir, setts.BasePath);
		strcat(dir, "Scenario");

		ofn.lStructSize = sizeof(OPENFILENAME);
		ofn.hwndOwner = sheet;
		ofn.lpstrFilter = extSave;
		ofn.lpstrCustomFilter = NULL;
		ofn.lpstrFile = setts.ScenPath;
		ofn.nMaxFile = _MAX_PATH;
		ofn.lpstrFileTitle = NULL;
		ofn.lpstrInitialDir = dir;
		ofn.lpstrTitle = NULL;
		ofn.Flags = OFN_NOREADONLYRETURN | OFN_OVERWRITEPROMPT;

	    startver = scen.game;

		if (scen.header.header_type == HT_AOE2SCENARIO) {
		    ofn.nFilterIndex =	6;
		    ofn.lpstrDefExt =	"aoe2scenario";
		} else {
		    switch (scen.game) {
		    case AOK:
		        ofn.nFilterIndex =	1;
		        ofn.lpstrDefExt =	"scn";
		        break;
		    case AOC:
		        ofn.nFilterIndex =	2;
		        ofn.lpstrDefExt =	"scx";
		        break;
		    case UP:
		        ofn.nFilterIndex =	3;
		        ofn.lpstrDefExt =	"scx";
		        break;
		    case AOHD:
		    case AOHD4:
		        ofn.nFilterIndex =	4;
		        ofn.lpstrDefExt =	"scx";
		        break;
		    case AOF:
		    case AOF4:
		        ofn.nFilterIndex =	5;
		        ofn.lpstrDefExt =	"scx2";
		        break;
		    case SWGB:
		        ofn.nFilterIndex =	7;
		        ofn.lpstrDefExt =	"scx";
		        break;
		    case SWGBCC:
		        ofn.nFilterIndex =	8;
		        ofn.lpstrDefExt =	"sc1";
		        break;
		    case AOHD6:
		        ofn.nFilterIndex =	9;
		        ofn.lpstrDefExt =	"scx";
		        break;
		    case AOF6:
		        ofn.nFilterIndex =	10;
		        ofn.lpstrDefExt =	"scx2";
		        break;
		    }
		}

		if (!GetSaveFileName(&ofn))
			return;

		switch (ofn.nFilterIndex) {
		case 1:
		    conv = AOK;
		    break;
		case 2:
		    conv = AOC;
		    break;
		case 3:
		    conv = UP;
		    break;
		case 4:
		    conv = AOHD4;
		    break;
		case 5:
		    conv = AOF4;
		    break;
		case 6:
	        scen.header.header_type = HT_AOE2SCENARIO;
		    conv = startver;
		    break;
		case 7:
		    conv = SWGB;
		    break;
		case 8:
		    conv = SWGBCC;
		    break;
		case 9:
		    conv = AOHD6;
		    break;
		case 10:
		    conv = AOF6;
		    break;
		}

		if (!*scen.origname)
			strcpy(scen.origname, setts.ScenPath + ofn.nFileOffset);

		/* Update window title since filename has probably changed */
		_snprintf(titleBuffer, sizeof(titleBuffer),
			"%s - %s", szTitle, setts.ScenPath + ofn.nFileOffset);
		SetWindowText(sheet, titleBuffer);
	} else {
	    conv = scen.game;
	}

    if (isHD(startver) && conv == UP) {
        if (setts.asktoconverteffects &&
            MessageBox(sheet, "Also convert HD effects to UserPatch?", "Convert", MB_YESNOCANCEL) == IDYES) {
            flags = (SaveFlags::Value)(flags | SaveFlags::CONVERT_EFFECTS);
        }
    }

    if (startver == UP && isHD(conv)) {
        if (setts.asktoconverteffects &&
            MessageBox(sheet, "Also convert UserPatch effects to HD?", "Convert", MB_YESNOCANCEL) == IDYES) {
            flags = (SaveFlags::Value)(flags | SaveFlags::CONVERT_EFFECTS);
        }
    }

	//update scenario data
	SendMessage(cpage, AOKTS_Saving, 0, 0);

	//perform before-saving operations
	previous = SetCursor(LoadCursor(NULL, IDC_WAIT));
	// Pretend we're "closing" the scenario because it may change during the
	// save.
	SendMessage(cpage, AOKTS_Closing, 0, 0);
	scen.clean_triggers();

	//save the scenario
	try
	{
 		error = scen.save(setts.ScenPath, setts.TempPath, write, conv, flags);
		SetCursor(previous);

	    struct RecentFile *file = NULL;	//the file info will be stored here one way or another
		struct RecentFile *r_parse;

		/* Now check if file is already on recent list. */
		r_parse = setts.recent_first;
		while (r_parse)
		{
			if (!strcmp(r_parse->path, setts.ScenPath))
			{
				file = r_parse;
				break;
			}
			r_parse = r_parse->next;
		}

        if (file) {
            file->game = (int)conv;
        } else {
		    file = setts.recent_getnext();
		    strcpy(file->path, setts.ScenPath);
		    strcpy(file->display, PathFindFileName(setts.ScenPath));
		    file->game = (int)conv;
	        setts.recent_push(file);
	    }
	    UpdateRecentMenu(propdata.menu);
	}
	catch (std::exception &ex)
	{
		// TODO: better atomic cursor handling?
		SetCursor(previous);
		MessageBox(sheet, ex.what(), "Scenario Save Error", MB_ICONWARNING);
	}

	//perform after-saving operations
	SendMessage(cpage, AOKTS_Loading, 0, 0);

	//report any errors
	if (error)
	{
		SetWindowText(propdata.statusbar, scen.msg);
		//MessageBox(sheet, scen.msg, "Save Error", MB_OK);
	}
}
コード例 #5
0
ファイル: main.c プロジェクト: theknurz/yamj-ro-suite
BOOL fillTVStruct (xmlNodePtr parentTag) {
	xmlNode *seekChild, *curNode, *airNode;
	char *tmpString;
	char *toFree;
	/* clear Structs */
	if (curTV->actors) free (curTV->actors);
	if (curTV->plot) free (curTV->plot);
	if (curTV->tagline) free (curTV->tagline);
	bzero (curTV, sizeof(struct ST_tv));

	if ( (seekChild = getChildNodeByName(parentTag, "title")) != NULL ) {
		if ( ( tmpString = encNodeGetContent(seekChild)) != NULL ) {
			strncat(curTV->seriesname, tmpString, 255);
			free (tmpString);
			printD ("Stored Title:%s\n", curTV->seriesname);
		}
	}
	else {
		printD("Something went wrong while reading title...\n");
		return (FALSE);
	}

	if ( (seekChild = getChildNodeByName(parentTag, "language")) != NULL ) {
		if ( ( tmpString = encNodeGetContent(seekChild)) != NULL ) {
			strncat(curTV->language, tmpString, 255);
			free (tmpString);
			printD ("Stored Language:%s\n", curTV->language);
		}
	}
	else {
		printD("Something went wrong while reading language...\n");
		return (FALSE);
	}

	if ( (seekChild = getChildNodeByName(parentTag, "container")) != NULL ) {
		if ( ( tmpString = encNodeGetContent(seekChild)) != NULL ) {
			strncat(curTV->mediatype, tmpString, 255);
			xmlFree (tmpString);
			printD ("Stored MediaType:%s\n", curTV->mediatype);
		}
	}
	else {
		printD("Something went wrong while reading container(mediatype)...\n");
		return (FALSE);
	}

	if ( (toFree = getIDs(parentTag)) != NULL ) {
		sprintf (curTV->imdblink, "http://www.imdb.com/title/%s\n", toFree);
		free (toFree);
	}
	else
		sprintf (curTV->imdblink, "http://www.imdb.com/find?s=all&q=%s", curMovie->moviename);
	printD ("Stored IMDBLink:%s\n", curTV->imdblink);

	if ( (seekChild = getChildNodeByName(parentTag, "videoOutput")) != NULL) {
		if ( (tmpString = (char*)xmlNodeGetContent (seekChild)) != NULL) {
			curMovie->isHD = isHD(tmpString);
			xmlFree ((xmlChar*)tmpString);
		}
	}
	else
		curMovie->isHD = FALSE;


	if ( (seekChild = getChildNodeByName(parentTag, "directors")) != NULL ) {
		if ( childTextToString(seekChild, curTV->directors, "director") == 0 )
			strcat (curTV->directors, "UNKNOWN");
		printD ("Stored Directors:%s\n", curTV->directors);
	}
	else {
		printD("Something went wrong while reading directors...\n");
	}

	if ( (seekChild = getChildNodeByName(parentTag, "writers")) != NULL ) {
		if ( childTextToString(seekChild, curTV->writers, "writer") == 0 )
			strcat (curTV->writers, "UNKNOWN");
		printD ("Stored Writers:%s\n", curTV->writers);
	}

	if ( (seekChild = getChildNodeByName(parentTag, "genres")) != NULL ) {
		if ( childTextToString(seekChild, curTV->genres, "genre") == 0 )
			strcat (curTV->genres, "UNKNOWN");
		printD ("Stored Genres:%s\n", curTV->genres);
	}

	if ( (seekChild = getChildNodeByName(parentTag, "cast")) != NULL ) {
		if ( childTextToString_m(seekChild, &curTV->actors, "actor") == 0 )
			curTV->actors = strdup ("UNKNOWN");
		printD ("Stored Actors:%s\n", curTV->actors);
	}
	else
		curTV->actors = strdup ("UNKNOWN");

	if ( (seekChild = getChildNodeByName(parentTag, "tagline")) != NULL ) {
		if ( ( tmpString = encNodeGetContent(seekChild)) != NULL ) {
			curTV->tagline=tmpString;
			printD ("Stored Outline:%s\n", curTV->tagline);
		}
	}

	if ( (seekChild = getChildNodeByName(parentTag, "plot")) != NULL ) {
		if ( ( tmpString = encNodeGetContent(seekChild)) != NULL ) {
			curTV->plot=tmpString;
			printD ("Stored Plot:%s\n", curTV->plot);
		}
	}

	if ( (seekChild = getChildNodeByName(parentTag, "releaseDate")) != NULL ) {
		if ( ( tmpString = encNodeGetContent(seekChild)) != NULL ) {
			strncat (curTV->year, tmpString, 63);
			xmlFree (tmpString);
			printD ("Stored Releasedate:%s\n", curTV->year);
		}
	}

	if ( (seekChild = getChildNodeByName(parentTag, "posterFile")) != NULL ) {
		if ( ( tmpString = encNodeGetContent(seekChild)) != NULL ) {
			strncat (curTV->imglink, tmpString, 255);
			free (tmpString);
			printD ("Stored Imagelink:%s\n", curTV->imglink);
		}
	}

	if ( (seekChild = getChildNodeByName(parentTag, "rating")) != NULL ) {
		if ( ( tmpString = (char*)xmlNodeGetContent(seekChild)) != NULL ) {
			if (atoi((char*)tmpString) < 0)
				curTV->rating=0;
			else
				curTV->rating=atoi((char*)tmpString);
			xmlFree (tmpString);
			printD ("Stored Rating:%i\n", curTV->rating);
		}
	}

	if ( (seekChild = getChildNodeByName(parentTag, "season")) != NULL ) {
		if ( ( tmpString = (char*)xmlNodeGetContent(seekChild)) != NULL ) {
			if (atoi((char*)tmpString) < 0)
				curTV->season=0;
			else
				curTV->season=atoi((char*)tmpString);
			xmlFree (tmpString);
			printD ("Stored Season:%i\n", curTV->season);
		}
	}

	if ( (seekChild = getChildNodeByName(parentTag, "files")) != NULL) {
		if (seekChild->children) {
			curNode = seekChild->children;
			while (curNode) {
				if (curNode->type == XML_ELEMENT_NODE) {
					if (strcasecmp((char*)curNode->name, "file") == 0) {
						if ( (airNode = getChildNodeByName(curNode, "fileTitle")) != NULL) {
							if ( (tmpString = (char*)xmlGetProp(airNode, (xmlChar*)"part")) != NULL ) {
								if (atoi((char*)tmpString) < 0 )
									curTV->episode=0;
								else
									curTV->episode=atoi((char*)tmpString);
								xmlFree (tmpString);
							}
							if ( (tmpString = encNodeGetContent(airNode)) != NULL ) {
								strncat (curTV->episodename, tmpString, 255);
								free(tmpString);
							}
						}
						if ( (airNode = getChildNodeByName(curNode, "fileLocation")) != NULL) {
							tmpString = (char*)xmlNodeGetContent(airNode);
							strncat (curTV->filename, tmpString ? tmpString : "*UNAVAILABLE*", 255);
							if (tmpString) free (tmpString);
						}
					}
					if (!writeToDB(TRUE))
						fprintf (stderr, "%s could not be stored in DB:%s\n", curTV->filename, mysql_error(mysql_conn));
					bzero(curTV->episodename, 255);
					bzero(curTV->filename, 255);
				}
				/* should all be filled by now, pump it in the DB */
				curNode=curNode->next;
			}
		}
	}

	return (TRUE);

}