コード例 #1
0
ファイル: startshape.cpp プロジェクト: 13221325403/openbr
static Shape AlignMeanShapeToBothEyesNoMouth(
    const DetPar& detpar,                      // in
    const Shape&  meanshape)                   // in
{
    if (trace_g)
        lprintf("AlignToBothEyesNoMouth           ");

    CV_Assert(NSIZE(meanshape) > 0 && PointUsed(meanshape, 0));
    CV_Assert(Valid(detpar.lex));
    CV_Assert(Valid(detpar.rex));

    Shape meanline(2, 2), detline(2, 2);       // line from eye to eye

    meanline(0, IX) = meanshape(L_LPupil, IX); // left eye
    meanline(0, IY) = meanshape(L_LPupil, IY);
    meanline(1, IX) = meanshape(L_RPupil, IX); // right eye
    meanline(1, IY) = meanshape(L_RPupil, IY);

    detline(0, IX) = detpar.lex;               // left eye
    detline(0, IY) = detpar.ley;
    detline(1, IX) = detpar.rex;               // right eye
    detline(1, IY) = detpar.rey;

    return AlignShape(meanshape, AlignmentMat(meanline, detline));
}
コード例 #2
0
static void TraceEyesMouth(
    Image&  face_roi,           // out: ROI around face, possibly rotated upright
    DetPar& detpar_roi)         // out: detpar wrt to face_roi
{
#if TRACE_IMAGES // will be 0 unless debugging (defined in stasm.h)

    CImage cimg; cvtColor(face_roi, cimg, CV_GRAY2BGR); // color image
    rectangle(cimg,
              cv::Point(cvRound(detpar_roi.x - .5 * detpar_roi.width),
                        cvRound(detpar_roi.y - .5 * detpar_roi.height)),
              cv::Point(cvRound(detpar_roi.x + .5 * detpar_roi.width),
                        cvRound(detpar_roi.y + .5 * detpar_roi.height)),
              ToCvColor(C_BLUE), 3);
    if (Valid(detpar_roi.lex))
        cv::circle(cimg,
                   cv::Point(cvRound(detpar_roi.lex), cvRound(detpar_roi.ley)),
                   MAX(2, face_roi.cols / 40),
                   cv::Scalar(0, 0, 255), 2);
    if (Valid(detpar_roi.rex))
        cv::circle(cimg,
                   cv::Point(cvRound(detpar_roi.rex), cvRound(detpar_roi.rey)),
                   MAX(2, face_roi.cols / 40),
                   cv::Scalar(0, 0, 255), 2);
    if (Valid(detpar_roi.mouthx))
        cv::circle(cimg,
                   cv::Point(cvRound(detpar_roi.mouthx), cvRound(detpar_roi.mouthy)),
                   MAX(2, face_roi.cols / 40),
                   cv::Scalar(0, 0, 255), 2);
    char s[SLEN]; sprintf(s, "%s_25_eyemouth.bmp", Base(imgpath_g));
    lprintf("%s\n", s);
    if (!cv::imwrite(s, cimg))
        Err("Cannot write %s", s);

#endif
}
コード例 #3
0
ファイル: startshape.cpp プロジェクト: 13221325403/openbr
static Shape AlignMeanShapeToRightEyeAndMouth(
    const DetPar& detpar,                             // in
    const Shape&  meanshape)                          // in
{
    if (trace_g)
        lprintf("AlignToRightEyeAndMouth          ");

    CV_Assert(NSIZE(meanshape) > 0 && PointUsed(meanshape, 0));
    CV_Assert(!Valid(detpar.lex));   // left eye invalid? (else why are we here?)
    CV_Assert(Valid(detpar.rex));    // right eye valid?
    CV_Assert(Valid(detpar.mouthx)); // mouth valid?

    const double x_meanmouth =
       (meanshape(L_CTopOfTopLip, IX) + meanshape(L_CBotOfBotLip, IX)) / 2;

    const double y_meanmouth =
       (meanshape(L_CTopOfTopLip, IY) + meanshape(L_CBotOfBotLip, IY)) / 2;

    Shape meanline(2, 2), detline(2, 2);              // line from eye to mouth

    meanline(0, IX) = meanshape(L_RPupil, IX);        // right eye
    meanline(0, IY) = meanshape(L_RPupil, IY);
    meanline(1, IX) = x_meanmouth;                    // mouth
    meanline(1, IY) = y_meanmouth;

    detline(0, IX) = detpar.rex;                      // right eye
    detline(0, IY) = detpar.rey;
    detline(1, IX) = detpar.mouthx;                   // mouth
    detline(1, IY) = detpar.mouthy;

    return AlignShape(meanshape, AlignmentMat(meanline, detline));
}
コード例 #4
0
static Shape EstartEyes(
    const DetPar& detpar_roi,      // in: detpar wrt the ROI
    const Image&  face_roi,        // in
    const Shape&  meanshape)       // in
{
    Shape startshape;
    Shape meanshape1(meanshape);
    if (Valid(detpar_roi.lex) && Valid(detpar_roi.rex)) // both eyes available?
    {
        FlipIfLeftFacing(meanshape1, detpar_roi.eyaw, face_roi.cols);
        // TODO Tune the following code, what approach is best?
        if (detpar_roi.eyaw == EYAW00)
            startshape = AlignMeanShapeToBothEyesEstMouth(detpar_roi, meanshape1);
        else
            startshape = AlignMeanShapeToBothEyesNoMouth(detpar_roi, meanshape1);
        FlipIfLeftFacing(startshape, detpar_roi.eyaw, face_roi.cols);
    }
    else // at least one eye is missing, use the face det rectangle
    {
        startshape =
            AlignMeanShapeToFaceDet(detpar_roi, meanshape1,
                                        FACERECT_SCALE_WHEN_NO_EYES, face_roi);
    }
    return startshape;
}
コード例 #5
0
ファイル: startshape.cpp プロジェクト: 13221325403/openbr
static Shape AlignMeanShapeToBothEyesEstMouth(
    const DetPar& detpar,                      // in
    const Shape&  meanshape)                   // in
{
    // .48 was tested to give slightly better worse case results than .50
    static double EYEMOUTH_TO_FACERECT_RATIO = .48;

    if (trace_g)
        lprintf("AlignToBothEyesNoMouth(EstMouth) ");

    CV_Assert(NSIZE(meanshape) > 0 && PointUsed(meanshape, 0));
    CV_Assert(Valid(detpar.lex));
    CV_Assert(Valid(detpar.rex));

    // estimate the mouth's position

    double x_eyemid = 0;
    switch (detpar.eyaw)
    {
        case EYAW00:                                 //  mid point
            x_eyemid = .50 * detpar.lex + .50 * detpar.rex;
            break;
        // TODO The constants below have not been empirically optimized.
        case EYAW_45:                                // closer to left eye
            x_eyemid = .30 * detpar.lex + .70 * detpar.rex;
            break;
        case EYAW_22:                                // closer to left eye
            x_eyemid = .30 * detpar.lex + .70 * detpar.rex;
            break;
        case EYAW22:                                 // closer to right eye
            x_eyemid = .30 * detpar.lex + .70 * detpar.rex;
            break;
        case EYAW45:                                 // closer to right eye
            x_eyemid = .30 * detpar.lex + .70 * detpar.rex;
            break;
        default:
            Err("AlignMeanShapeToBothEyesEstMouth: Invalid eyaw %d", detpar.eyaw);
            break;
    }
    const double y_eyemid = (detpar.ley + detpar.rey) / 2;

    Shape mean_tri(3, 2), det_tri(3, 2);             // triangle of eyes and mouth

    mean_tri(0, IX) = meanshape(L_LPupil, IX);       // left eye
    mean_tri(0, IY) = meanshape(L_LPupil, IY);
    mean_tri(1, IX) = meanshape(L_RPupil, IX);       // right eye
    mean_tri(1, IY) = meanshape(L_RPupil, IY);
    mean_tri(2, IX) = meanshape(L_CBotOfBotLip, IX); // mouth
    mean_tri(2, IY) = meanshape(L_CBotOfBotLip, IY);

    det_tri(0, IX) = detpar.lex;                     // left eye
    det_tri(0, IY) = detpar.ley;
    det_tri(1, IX) = detpar.rex;                     // right eye
    det_tri(1, IY) = detpar.rey;
    det_tri(2, IX) = x_eyemid;                       // mouth
    det_tri(2, IY) = y_eyemid + EYEMOUTH_TO_FACERECT_RATIO * detpar.width;

    return AlignShape(meanshape, AlignmentMat(mean_tri, det_tri));
}
コード例 #6
0
ファイル: PPENEQNS.CPP プロジェクト: ChrisMoreton/Test3
flag PE_VolFlow::ValidateData(ValidateDataBlk & VDB)
  {
  if (Valid(OpVol))
    OpNVol=dNAN;
  else if (!Valid(OpNVol))
    OpNVol=10.0;
  return True;
  }
コード例 #7
0
ファイル: MTRLOGIC.CPP プロジェクト: ChrisMoreton/Test3
void PL_SoftStSp::EvalCtrlActions(FlwNode* pFNode)
  {
  DoRunning();

  double dReqdSpd, dDiffSpd;

  switch (iFwdRev)
    {
    case PLSS_FwdOnly:
      m_dSpeedReqd=Range(0.0, m_dSpeedReqd, 1.0);
      dReqdSpd=m_dSpeedReqd;
      if (Valid(m_dManualSpeed))
        m_dManualSpeed=Range(0.0, m_dManualSpeed, 1.0);
      break;
    case PLSS_FwdRevLogic:
      m_dSpeedReqd=Range(0.0, m_dSpeedReqd, 1.0);
      dReqdSpd=m_dSpeedReqd*(bRunRev ? -1 : 1);
      if (Valid(m_dManualSpeed))
        m_dManualSpeed=Range(0.0, m_dManualSpeed, 1.0);
      break;
    case PLSS_FwdRevRegulation:
      m_dSpeedReqd=Range(-1.0, m_dSpeedReqd, 1.0);
      dReqdSpd=m_dSpeedReqd;
      if (Valid(m_dManualSpeed))
        m_dManualSpeed=Range(-1.0, m_dManualSpeed, 1.0);
      break;
    }
  // Decide the required position
  if (!bRunning)
    dReqdSpd=0.0;
      
  // the difference
  dDiffSpd = dReqdSpd-m_dSpeed;
  // limit the diff by the stroketime
  if (fabs(m_dSpeed+dDiffSpd*0.01)>fabs(m_dSpeed))
    dDiffSpd = Sign(dDiffSpd)*Min(fabs(dDiffSpd), ICGetTimeInc()/GTZ(dStartTime));
  else
    dDiffSpd = -Sign(dDiffSpd)*Max(-fabs(dDiffSpd),-ICGetTimeInc()/GTZ(dStopTime));

  // apply it;
  m_dSpeed+=dDiffSpd;

  m_dSpeed=Range(-1.0, m_dSpeed, 1.0);
  if (!bRunning)
    m_dMapSpeed=0.0;
  else 
    {
    if (Valid(m_dManualSpeed))
      m_dMapSpeed=m_dManualSpeed;
    else
      m_dMapSpeed=m_dSpeed;
    m_dMapSpeed=dMapLo+m_dMapSpeed*(dMapHi-dMapLo);
    }
  
  };
コード例 #8
0
ファイル: startshape.cpp プロジェクト: 13221325403/openbr
static double EstRotFromEyeAngle( // estimate face rotation from intereye angle
    const DetPar& detpar)         // in: detpar wrt the ROI
{
    double rot = 0;

    if (Valid(detpar.lex) && Valid(detpar.rey)) // both eyes detected?
        rot = RadsToDegrees(-atan2(detpar.rey - detpar.ley,
                                   detpar.rex - detpar.lex));

    return rot;
}
コード例 #9
0
double EyeAngle(          // eye angle in degrees, INVALID if eye angle not available
    const DetPar& detpar) // in: detpar wrt the ROI
{
    double angle = 0;
    if (Valid(detpar.lex) && Valid(detpar.rey)) // both eyes detected?
    {
        angle = RadsToDegrees(
                    -atan2(detpar.rey - detpar.ley,
                           detpar.rex - detpar.lex));
    }
    return angle;
}
コード例 #10
0
void BoxWorldState::Update(void) {
	if(gameController->GetInput() == "B" || gameController->GetInput() == "b") {
		Valid();
        GoToMenu();
    }
	else if(gameController->GetInput() == "H" || gameController->GetInput() == "h") {
		Valid();
        GoToHighScore();
    }
	else
		NotValid();
}
コード例 #11
0
int isOlder(char *dob1, char *dob2)
{
	int day1 = 0, day2 = 0, mnth1 = 0, mnth2 = 0, yr1 = 0, yr2 = 0;
	int i;
	for (i = 0; i < 2; i++)
	{
		if (dob1[i]<48 || dob1[i]>57 || dob2[i]<48 || dob2[i]>57)
			return -1;
		day1 = (day1 * 10) + (dob1[i] - '0');
		day2 = (day2 * 10) + (dob2[i] - '0');
	}
	for (i = 3; i < 5; i++)
	{
		if (dob1[i]<48 || dob1[i]>57 || dob2[i]<48 || dob2[i]>57)
			return -1;
		mnth1 = (mnth1 * 10) + (dob1[i] - '0');
		mnth2 = (mnth2 * 10) + (dob2[i] - '0');
	}
	for (i = 6; i < 10; i++)
	{
		if (dob1[i]<48 || dob1[i]>57 || dob2[i]<48 || dob2[i]>57)
			return -1;
		yr1 = (yr1 * 10) + (dob1[i] - '0');
		yr2 = (yr2 * 10) + (dob2[i] - '0');
	}
	if (Valid(day1, mnth1, yr1) && Valid(day2, mnth2, yr2))
	{
		if (yr1 < yr2)
			return 1;
		else if (yr2 < yr1)
			return 2;
		else
		{
			if (mnth1 < mnth2)
				return 1;
			else if (mnth2 < mnth1)
				return 2;
			else
			{
				if (day1 < day2)
					return 1;
				else if (day2 < day1)
					return 2;
				else
					return 0;
			}
		}
	}
	else
		return -1;


}
コード例 #12
0
ファイル: startshape.cpp プロジェクト: 13221325403/openbr
static Shape StartShapeFromDetPar(
    const DetPar& detpar_roi,      // in: detpar wrt the ROI
    const Image&  face_roi,        // in
    const Shape&  meanshape,       // in
    ESTART        estart)          // in: use mouth etc. to posn start shape?
{
    CV_Assert(estart == ESTART_RECT_ONLY ||
              estart == ESTART_EYES ||
              estart == ESTART_EYE_AND_MOUTH);

    Shape startshape;
    Shape meanshape1(meanshape);

    if (estart == ESTART_EYE_AND_MOUTH &&             // use both eyes and mouth?
        Valid(detpar_roi.mouthx) &&
        Valid(detpar_roi.lex) &&
        Valid(detpar_roi.rex))
    {
        FlipIfLeftFacing(meanshape1, detpar_roi.eyaw, face_roi.cols);
        startshape = AlignMeanShapeToBothEyesAndMouth(detpar_roi, meanshape1);
        FlipIfLeftFacing(startshape, detpar_roi.eyaw, face_roi.cols);
    }
    else if (Valid(detpar_roi.lex) &&                 // use both eyes?
             Valid(detpar_roi.rex))
    {
        FlipIfLeftFacing(meanshape1, detpar_roi.eyaw, face_roi.cols);
        // TODO Tune the following code, what approach is best?
        if (detpar_roi.eyaw == EYAW00)
            startshape = AlignMeanShapeToBothEyesEstMouth(detpar_roi, meanshape1);
        else
            startshape = AlignMeanShapeToBothEyesNoMouth(detpar_roi, meanshape1);
        FlipIfLeftFacing(startshape, detpar_roi.eyaw, face_roi.cols);
    }
    else if (estart == ESTART_EYE_AND_MOUTH &&        // use left eye and mouth?
             Valid(detpar_roi.mouthx) &&
             Valid(detpar_roi.lex))
    {
        FlipIfLeftFacing(meanshape1, detpar_roi.eyaw, face_roi.cols);
        startshape = AlignMeanShapeToLeftEyeAndMouth(detpar_roi, meanshape1);
        FlipIfLeftFacing(startshape, detpar_roi.eyaw, face_roi.cols);
    }
    else if (estart == ESTART_EYE_AND_MOUTH &&        // use right eye and mouth?
             Valid(detpar_roi.mouthx) &&
             Valid(detpar_roi.rex))
    {
        FlipIfLeftFacing(meanshape1, detpar_roi.eyaw, face_roi.cols);
        startshape = AlignMeanShapeToRightEyeAndMouth(detpar_roi, meanshape1);
        FlipIfLeftFacing(startshape, detpar_roi.eyaw, face_roi.cols);
    }
    else // last resort: use the face det rectangle (can't use facial features)
    {
        startshape =
            AlignMeanShapeToFaceDetRect(detpar_roi, meanshape1,
                                        FACERECT_SCALE_WHEN_NO_EYES, face_roi);
    }
    return JitterPointsAt00(startshape);
}
コード例 #13
0
uint64_t pawnAtk(int sq, int color)
{
	uint64_t ret = 0;
	int x = GetX(sq);
	int y = GetY(sq);
	
	if (color == 0)
	{
		if (Valid(x+1) && Valid(y+1))
		{
			ret |= Bit(Sq(x+1, y+1));
		}
		
		if (Valid(x-1) && Valid(y+1))
		{
			ret |= Bit(Sq(x-1, y+1));
		}
	}
	else
	{
		if (Valid(x+1) && Valid(y-1))
		{
			ret |= Bit(Sq(x+1, y-1));
		}
		
		if (Valid(x-1) && Valid(y-1))
		{
			ret |= Bit(Sq(x-1, y-1));
		}
	}
	
	return ret;
}
コード例 #14
0
ファイル: PPENEQNS.CPP プロジェクト: ChrisMoreton/Test3
flag PE_VolFlow::EvaluateFlwEqn(eScdFlwEqnTasks Task, CSpPropInfo *pProps, CFlwBlkBase & FE, bool On, double Regulation, CFBPhysData *pPhD0, CFBPhysData *pPhD1)
  {
  double dPq1, dPq2;
  if (Valid(OpVol))
    {
    double Rho=Max(0.1, FE.MeanRho(pProps));
    double K=fabs(OpDP)/Pow(fabs(OpVol), PwrLaw);
    double Vol1 = FE.SetQvMeasRange(Rho, 1.0);
    double dQm  = FE.DQmMeas(1.001);
    double Vol2 = FE.QvMeas(1.001);

    dPq1 = -FE.QmSign()*K*Pow(Vol1,PwrLaw);
    dPq2 = -FE.QmSign()*K*Pow(Vol2,PwrLaw);
    FE.SetDPq(dPq1, (dPq2 - dPq1)/dQm);
    }
  else
    {
    double NRho=Max(0.1, FE.MeanRho(pProps)*Norm_P/GTZ(FE.MeanPress())*FE.MeanTemp(pProps)/Norm_T);
    double K=fabs(OpDP)/Pow(fabs(OpNVol), PwrLaw);
    double NVol1 = FE.SetQvMeasRange(NRho, 1.0);
    double dQm  = FE.DQmMeas(1.001);
    double NVol2 = FE.QvMeas(1.001);

    dPq1 = -FE.QmSign()*K*Pow(NVol1,PwrLaw);
    dPq2 = -FE.QmSign()*K*Pow(NVol2,PwrLaw);
    FE.SetDPq(dPq1, (dPq2 - dPq1)/dQm);
    }

  m_dDP=fabs(dPq1);
  FE.SetFunctOfPress();

  return True;
  };
コード例 #15
0
ファイル: login.c プロジェクト: benedicktj/mYnexia
int string_check(const char *p,int len) {
	char buf[255];
	memset(buf,0,255);
	memcpy(buf,p,len);
	//printf("string_check: %s\n",buf);
	return Valid(buf,mask2);
}
コード例 #16
0
ファイル: task6.c プロジェクト: psc0606/embedded
void Trial(int i,int n)
{
	int k,m,j;
	if(i==n)
	{
		printf("八皇后\n");
		for(k=0;k<n;k++)
		{
			for(m=0;m<n;m++)
			{
				printf("%4d",a[k][m]);
			}
			printf("\n");
		}
		w++;
		//exit(0);
	}
	else
	{
		for(j=0;j<n;j++)
		{
			a[i][j]=1;
			if(Valid(i,j))
			{
				//printf("i=%d,j=%d\n",i,j);
				//printf("\n");
				Trial(i+1,n);
			}
			a[i][j]=0;
		}
	}
}
コード例 #17
0
void ETextureThumbnail::Save(int age, LPCSTR path)
{
	if (!Valid()) 	return;

    CMemoryWriter F;
	F.open_chunk	(THM_CHUNK_VERSION);
	F.w_u16			(THM_TEXTURE_VERSION);
	F.close_chunk	();

/*
	F.w_chunk		(THM_CHUNK_DATA | CFS_CompressMark,m_Pixels.begin(),m_Pixels.size()*sizeof(u32));
*/        

    F.open_chunk	(THM_CHUNK_TYPE);
    F.w_u32			(m_Type);
	F.close_chunk	();

	m_TexParams.Save(F);

    string_path		fn;
    if (path)
        FS.update_path(fn, path, m_Name.c_str());
    else
    	FS.update_path(fn, _game_textures_, m_Name.c_str());

    if (F.save_to(fn))
    {
	    FS.set_file_age	(fn,age?age:m_Age);
    }else{
        Log			("!Can't save thumbnail:",fn);
    }
}
コード例 #18
0
    void help(string s, int level, int index, vector<string>& r, vector<string> temp)
    {
        
        if(level == 4 && index == s.length()) {
            string line = temp[0];
            for(int i = 1;i < 4;i++)
            {
                line += '.';
                line += temp[i];
            }
            r.push_back(line);
        } else if(level == 4 && index < s.length()) {
            return;
        }
        
        for(int i = 0;i < 3;i++)
        {
            if(index + i + 1 > s.length())
                return;
            string tmp = s.substr(index,i+1);

            if( Valid(tmp) ){
                temp.push_back(tmp);
                help(s, level+1, index+i+1, r, temp);
                temp.pop_back();
            }
        }
    }
コード例 #19
0
ファイル: NyxTime_Impl.cpp プロジェクト: cobreti/Nyx
	bool CTime::operator > (const CTime& time) const
	{
		if ( !Valid() || !time.Valid() )
			throw Nyx::CTimeException();

		return m_Time > time.m_Time;
	}
コード例 #20
0
ファイル: SR_CTRL.CPP プロジェクト: abcweizhuo/Test3
void CEC_FinalConc::BuildDataDefn(DataDefnBlk & DDB)
  {
  Strng T;
  T.Set("Final Conc %s", m_Spc.m_Name());

  DDB.Text  (T());
  DDEF_Flags VFlags=DDB.GetVisibility();
  DDB.String("ExtentType",        "",        DC_,     "",      xid_RCTExtentType,          &Eq, SetOnChange|isParm, DDBExtentTypes);
  DDB.SetVisibility(VFlags);

  if (m_Spc.m_ReactTerm>=0 || m_Spc.m_ProdTerm>=0)
    {
    CCnvIndex dc;
    pchar pCnvTxt;
    SDB.AddSpCnv(DC_Conc, SDB[m_Spc.m_SpcId].SymOrTag(), "g/L", dc, pCnvTxt);
    Strng S,C("Rct"),R("Reqd");
    if (Valid(m_dRqdTemp))
      S.Set("@%.2f", K2C(m_dRqdTemp));
    else
      S="@FinalT";
    C+=S;
    R+=S;
    m_ddRqdConc.BuildDataDefn(DDB, "Conc_Rqd", "", dc, pCnvTxt, xid_RCTExtent, &Eq, C(), R());
    DDB.Double("Conc_MeasTemp",    "",          DC_T,     "C",  xid_RCTFinalConcT,  &Eq, isResult|noFile|noSnap|InitHidden);
    DDB.Double("Conc_EOStep",      "Conc_Act",  DC_,      "",   &m_dKEOStep,             &Eq, isResult);
    DDB.TagComment(S());
    DDB.Double("Conc_Final",       "",          DC_,      "",   &m_dKFinal,              &Eq, isResult|NAN_OK);
    DDB.TagComment(S());
    DDB.Double("ExtentError",      "",          DC_Frac,  "%",  xid_ExtentError, &Eq, isResult|noFile|noSnap|NAN_OK);
    }
  };
コード例 #21
0
ファイル: DeleteIns.cpp プロジェクト: hnordquist/MIC
void CDeleteIns::OnOK() 
{
	CValidate Valid(this);

    if (g_bHideWindows)
		ShowWindow(SW_HIDE);

	if (Valid.DoModal() == IDOK) 
	{
		//get the selection -- parent will do the 
		//instrument delete for us 
		int temp;
		if ((temp = m_DeleteList.GetCurSel()) != LB_ERR)
			m_dSelect = m_DeleteList.GetItemData(temp);

		BSTR bstr;
		g_pIISO[m_dSelect]->get_Name(&bstr);
		UINT count = 1 + SysStringLen(bstr);

		char *name = (char *)CoTaskMemAlloc((ULONG)count);
		Convert_BSTR_to_Character_String(bstr,name,count);

		AfxGetMainWnd()->PostMessage(IDC_DELETE_INST, NULL,(WPARAM)name);

		CDialog::OnOK();
	}
	//show this window again
	ShowWindow(SW_SHOW);
}
コード例 #22
0
ファイル: PoolString.cpp プロジェクト: AlphaPixel/3DNature
char *PoolString::Set(const char *Source)
{
if(Valid())
	{
	if(strlen(Source) < ROUNDUP(strlen(StrData), POOLSTRING_ROUNDUP))
		{
		strcpy(StrData, Source);
		return(StrData);
		} // if allocated is long enough for new data
	else
		{
		FreeStrMem(StrData);
		} // not enough room, free before re-allocating
	} // if

if(StrData = GetStrMem((int)strlen(Source)))
	{
	strcpy(StrData, Source);
	return(StrData);
	} // if allocated OK
else
	{
	StrData = &NullChar;
	return(NULL);
	} // failure
} // PoolString::Set
コード例 #23
0
ファイル: Mill1.cpp プロジェクト: ChrisMoreton/Test3
void Mill1::EvalPowerRequired()
  {
  m_Pwr.Zero();
  double ShftPwr=Power;//FB.ShaftPower();
  if (Valid(ShftPwr))
    m_Pwr.SetPower(ShftPwr);
  }
コード例 #24
0
ファイル: NyxTime_Impl.cpp プロジェクト: cobreti/Nyx
	bool CTime::operator != (const CTime& time) const
	{
		if ( !Valid() || !time.Valid() )
			throw Nyx::CTimeException();

		return (m_Time != time.m_Time);
	}
コード例 #25
0
ファイル: btconfig.cpp プロジェクト: timpalpant/dtorrent
template<> bool Config<const char *>::Set(const char *newval)
{ 
  if( m_current == newval )
    return true;
  if( m_current && newval && 0==strcmp(newval, m_current) )
    return true;

  if( !Locked() && Valid(newval) ){
    size_t len;
    char *tmp;
    if( m_current ){
      delete []m_current;
      m_current = (const char *)0;
    }
    if( newval ){
      len = strlen(newval);
      if( MaxLen() && len > MaxLen() ) len = MaxLen();
      if( !(tmp = new char[len + 1]) ) return false;
      strncpy(tmp, newval, len);
      tmp[len] = '\0';
      m_current = tmp;
    }
    Handler();
    if(*cfg_verbose)
      CONSOLE.Debug("Config: %s = \"%s\"", Tag(), m_current ? m_current : "");
    return true;
  }
  return false;
}
コード例 #26
0
void BufferCircle::SetBufferReady(int pos, bool state)
{
	if(!Valid(pos))
		return;

	BufferReady[pos] = state;
}
コード例 #27
0
bool MyUPnP::GetDescription()
{
	if(!Valid())return false;
	CString post, host, addr;
	int port = 0;
	addr = NGetAddressFromUrl(m_description, post, host, port);
	if(addr.IsEmpty())return false;
	CString request = CString(_T("GET ")) + post + _T(" HTTP/1.1\r\nHOST: ") + host + _T("\r\nACCEPT-LANGUAGE: en\r\n\r\n");
	CString response;
	if (!SOAP_action(addr, (uint16)port, request, response)) return false;
	CString result;
	if (!parseHTTPResponse(response, result)) return false;

	m_friendlyname = getProperty(result, _T("friendlyName"));
	m_modelname = getProperty(result, _T("modelName"));
	m_baseurl = getProperty(result, _T("URLBase"));
	if(m_baseurl.IsEmpty())m_baseurl = CString(_T("http://")) + host + _T("/");
	if(m_baseurl[m_baseurl.GetLength() - 1]!='/')m_baseurl += _T("/");
	
	CString serviceType = _T("<serviceType>") + m_name + _T("</serviceType>");
	int pos = result.Find(serviceType);
	if (pos >= 0) {
		result.Delete(0, pos + serviceType.GetLength());
		pos = result.Find(_T("</service>"));
		if (pos >= 0) {
			result = result.Mid(0, pos);
			m_controlurl = getProperty(result, _T("controlURL"));
			if (!m_controlurl.IsEmpty() && m_controlurl[0] == '/') {
				m_controlurl = m_baseurl + m_controlurl.Mid(1);
			}
		}
	}

	return isComplete();
}
コード例 #28
0
void BufferCircle::SetBufferSize(int pos, int size)
{
	if(!Valid(pos))
		return;

	BufferSize[pos] = size;
}
コード例 #29
0
ファイル: Setupper.cpp プロジェクト: 2asoft/ConEmu
	// UTF-8 is expected here
	void Write(LPCSTR asText)
	{
		if (!Valid() || !asText || !*asText)
			return;
		DWORD nLen = lstrlenA(asText);
		WriteFile(mh_File, asText, nLen, &nLen, NULL);
	};
コード例 #30
0
ファイル: MenuWindow.cpp プロジェクト: SummerSnail2014/haiku
void MenuWindow::UpdateStatus(const char* str1, const char* str2)
{
	uint32 lenTotal = 0, len1 = 0, len2 = 0;
	
	if (str1)
		len1 = strlen(str1);
	if (str2)
		len2 = strlen(str2);
	
	lenTotal = len1 + len2;	
	char* updateText = new char[lenTotal+1];
	updateText[0] = '\0'; // in case str1 and str2 are both NULL

	if (str1)
		strcpy(updateText, str1);
	if (str2)
		strcpy(updateText + len1, str2);
	
	if (Lock() && Valid()) {
		m_pStatusView->SetText(updateText);
		Unlock();
	}
	
	delete [] updateText;
}