Beispiel #1
0
void wxGridCellChoiceEditor::BeginEdit(int row, int col, wxGrid* grid)
{
    wxASSERT_MSG(m_control,
                 wxT("The wxGridCellEditor must be created first!"));

    wxGridCellEditorEvtHandler* evtHandler = NULL;
    if (m_control)
        evtHandler = wxDynamicCast(m_control->GetEventHandler(), wxGridCellEditorEvtHandler);

    // Don't immediately end if we get a kill focus event within BeginEdit
    if (evtHandler)
        evtHandler->SetInSetFocus(true);

    m_value = grid->GetTable()->GetValue(row, col);

    Reset(); // this updates combo box to correspond to m_value

    Combo()->SetFocus();

    if (evtHandler)
    {
        // When dropping down the menu, a kill focus event
        // happens after this point, so we can't reset the flag yet.
#if !defined(__WXGTK20__)
        evtHandler->SetInSetFocus(false);
#endif
    }
}
Beispiel #2
0
void wxGridCellChoiceEditor::Reset()
{
    if (m_allowOthers)
    {
        Combo()->SetValue(m_value);
        Combo()->SetInsertionPointEnd();
    }
    else // the combobox is read-only
    {
        // find the right position, or default to the first if not found
        int pos = Combo()->FindString(m_value);
        if (pos == wxNOT_FOUND)
            pos = 0;
        Combo()->SetSelection(pos);
    }
}
Beispiel #3
0
   void SetSize(const wxRect& rectOrig) override
   {
      wxRect rect(rectOrig);
      wxRect r = Combo()->GetRect();

      // Center the combo box in or over the cell
      rect.y -= (r.GetHeight() - rect.GetHeight()) / 2;
      rect.height = r.GetHeight();

      wxGridCellChoiceEditor::SetSize(rect);
   }
Beispiel #4
0
void init(){
  grabber.init(pa("-i"));

  bool c_arg = pa("-c");

  gui << Draw().handle("draw").label("input image")
      << Image().handle("cropped").label("cropped")
      << ( VBox().maxSize(c_arg ? 0 : 12,99).minSize(c_arg ? 0 : 12,1)
           << Button("save as ..").handle("saveAs")
           << Button("overwrite input").handle("overwrite")
           << Combo("0,90,180,270").handle("rot").label("rotation")
           << CheckBox("rectangular",!pa("-r")).handle("rect")
           << Button("Batch crop...").handle("batch")
           << ( HBox().label("rectification size")
                << Spinner(1,4096,640).handle("s1")
                << Label(":")
                << Spinner(1,4096,480).handle("s2")
                )
           << (HBox() 
               << Fps().handle("fps")
               << CamCfg()
               )
           )
      << Show();


  if(!c_arg){
    gui["batch"].registerCallback(batch_crop);
  }
  const ImgBase *image = grabber.grab();
  if(!c_arg){
    mouse_1 = new Mouse1(image->getSize());
    gui["draw"].install(mouse_1);
  }
  mouse_2 = new Mouse2(image->getSize());
  gui["draw"].install(mouse_2);
  
  DrawHandle draw = gui["draw"];
  draw->setImageInfoIndicatorEnabled(false);
  
  if(!c_arg){
    gui["rect"].registerCallback(rectangular_changed);
    rectangular_changed();
    if(*pa("-i",0) != "file" || FileList(*pa("-i",1)).size() != 1){
      gui["overwrite"].disable();
    }else{
      gui["overwrite"].registerCallback(overwrite);
    }
    gui["saveAs"].registerCallback(save_as);
  }

}
Beispiel #5
0
bool wxGridCellEnumEditor::EndEdit(int row, int col, wxGrid* grid)
{
    int pos = Combo()->GetSelection();
    bool changed = (pos != m_startint);
    if (changed)
    {
        if (grid->GetTable()->CanSetValueAs(row, col, wxGRID_VALUE_NUMBER))
            grid->GetTable()->SetValueAsLong(row, col, pos);
        else
            grid->GetTable()->SetValue(row, col,wxString::Format(wxT("%i"),pos));
    }

    return changed;
}
Beispiel #6
0
   // Fix for Bug 1389
   // July 2016: ANSWER-ME: Does this need reporting upstream to wxWidgets?
   virtual void StartingKey(wxKeyEvent& event) override
   {
       // Lifted from wxGridCellTextEditor and adapted to combo.

       // [Below is comment from wxWidgets code]
       // Since this is now happening in the EVT_CHAR event EmulateKeyPress is no
       // longer an appropriate way to get the character into the text control.
       // Do it ourselves instead.  We know that if we get this far that we have
       // a valid character, so not a whole lot of testing needs to be done.

       //The only difference to wxGridCellTextEditor.
       //wxTextCtrl* tc = (wxTextCtrl *)m_control;
       wxComboBox * tc = Combo();
       int ch;

       bool isPrintable;

   #if wxUSE_UNICODE
       ch = event.GetUnicodeKey();
       if ( ch != WXK_NONE )
           isPrintable = true;
       else
   #endif // wxUSE_UNICODE
       {
           ch = event.GetKeyCode();
           isPrintable = ch >= WXK_SPACE && ch < WXK_START;
       }

       switch (ch)
       {
           case WXK_DELETE:
               // Delete the initial character when starting to edit with DELETE.
               tc->Remove(0, 1);
               break;

           case WXK_BACK:
               // Delete the last character when starting to edit with BACKSPACE.
               {
                   const long pos = tc->GetLastPosition();
                   tc->Remove(pos - 1, pos);
               }
               break;

           default:
               if ( isPrintable )
                   tc->WriteText(static_cast<wxChar>(ch));
               break;
       }
   }
Beispiel #7
0
void wxGridCellChoiceEditor::BeginEdit(int row, int col, wxGrid* grid)
{
    wxASSERT_MSG(m_control,
                 wxT("The wxGridCellEditor must be created first!"));

    wxGridCellEditorEvtHandler* evtHandler = NULL;
    if (m_control)
        evtHandler = wxDynamicCast(m_control->GetEventHandler(), wxGridCellEditorEvtHandler);

    // Don't immediately end if we get a kill focus event within BeginEdit
    if (evtHandler)
        evtHandler->SetInSetFocus(true);

    m_value = grid->GetTable()->GetValue(row, col);

    Reset(); // this updates combo box to correspond to m_value

    Combo()->SetFocus();

#ifdef __WXOSX_COCOA__
    // This is a work around for the combobox being simply dismissed when a
    // choice is made in it under OS X. The bug is almost certainly due to a
    // problem in focus events generation logic but it's not obvious to fix and
    // for now this at least allows to use wxGrid.
    Combo()->Popup();
#endif

    if (evtHandler)
    {
        // When dropping down the menu, a kill focus event
        // happens after this point, so we can't reset the flag yet.
#if !defined(__WXGTK20__)
        evtHandler->SetInSetFocus(false);
#endif
    }
}
bool wxFastComboEditor::EndEdit(int row, int col,
                                wxGrid* grid)
{
    wxString value = Combo()->GetValue();
    bool changed = value != grid->GetCellValue(row, col);

    if ( changed )
        grid->SetCellValue(row, col, value);

    /*	m_startValue = wxEmptyString;
    	if (m_allowOthers)
    		Combo()->SetValue(m_startValue);
    	else
    		Combo()->SetSelection(0);
    */
    return changed;
}
Beispiel #9
0
bool wxGridCellEnumEditor::EndEdit(int WXUNUSED(row),
                                   int WXUNUSED(col),
                                   const wxGrid* WXUNUSED(grid),
                                   const wxString& WXUNUSED(oldval),
                                   wxString *newval)
{
    long idx = Combo()->GetSelection();
    if ( idx == m_index )
        return false;

    m_index = idx;

    if ( newval )
        newval->Printf("%ld", m_index);

    return true;
}
Beispiel #10
0
bool wxGridCellChoiceEditor::EndEdit(int WXUNUSED(row),
                                     int WXUNUSED(col),
                                     const wxGrid* WXUNUSED(grid),
                                     const wxString& WXUNUSED(oldval),
                                     wxString *newval)
{
    const wxString value = Combo()->GetValue();
    if ( value == m_value )
        return false;

    m_value = value;

    if ( newval )
        *newval = value;

    return true;
}
Beispiel #11
0
void init(){
  int masksize = 10;
  int thresh = 2;
  float gamma = 0;
  if(pa("-config")){
    ConfigFile f(*pa("-config"));
    masksize = f["config.masksize"];
    thresh = f["config.threshold"];
    gamma = f["config.gammaslope"];
  }

  gui << Draw().minSize(16,12).handle("orig").label("original image")
      << Image().minSize(16,12).handle("prev").label("preview image")
      << ( VBox().label("controls")
           << Slider(2,200,masksize).label("mask size").out("masksize").minSize(15,2).handle("a")
           << FSlider(-30,40,thresh).label("threshold").out("threshold").minSize(15,2).handle("b")
           << FSlider(0,15,gamma).label("gamma slope").out("gamma").minSize(15,2).handle("c")
           << Button("next image").handle("next")
           << Button("stopped","running").out("loop").handle("d")
           << Button("no clip","clip to roi").out("clipToROI").handle("e")
           << Button("save params").handle("save")
           << Combo("region mean,tiledNN,tiledLIN").handle("algorithm").label("algorithm")
           << ( HBox()
                << Label("..ms").handle("time").label("apply time").minSize(2,3)
                << Fps(10).handle("fps").minSize(4,3).label("fps")
                )
           )
      << Show();
  
  grabber.init(pa("-i"));
  if(grabber.getType() != "file"){
    grabber.useDesired<Size>(pa("-s"));
    if(!pa("-color")){
      grabber.useDesired(formatGray);
    }else{
      grabber.useDesired(formatRGB);
    }
    grabber.useDesired(depth8u);
  }
  
  gui.registerCallback(step,"a,b,c,d,e,next,algorithm");
  gui["orig"].install(new MouseHandler(mouse));
  
  step();
}
Beispiel #12
0
void CGameDlg::DrawTipLine(Vertex asvPath[MAX_SAVED_VERTEX_NUM],int nVexnum)
{
	
	CClientDC dc(this);
	CPen penLine(PS_SOLID,2,RGB(0,255,0));
	CPen* pOldPen = dc.SelectObject(&penLine);
	
	for(int i = 0 ; i<nVexnum-1; i++)
	{
		dc.MoveTo(m_ptGameTop.x + asvPath[i].col*m_sizeElem.cx + m_sizeElem.cx/2,
		m_ptGameTop.y+asvPath[i].row*m_sizeElem.cy+m_sizeElem.cy/2);
	dc.LineTo(m_ptGameTop.x + asvPath[i+1].col*m_sizeElem.cx+m_sizeElem.cx/2,
		m_ptGameTop.y+asvPath[i+1].row*m_sizeElem.cy+m_sizeElem.cy/2);
	}
	Combo();
	dc.SelectObject(pOldPen);

}
Beispiel #13
0
void Hotkey::BuildHotkey(std::string const& context, json::Object const& hotkeys) {
	for (auto const& command : hotkeys) {
		const json::Array& command_hotkeys = command.second;

		for (auto const& hotkey : command_hotkeys) {
			std::vector<std::string> keys;

			try {
				const json::Array& arr_mod = hotkey["modifiers"];
				keys.reserve(arr_mod.size() + 1);
				copy(arr_mod.begin(), arr_mod.end(), back_inserter(keys));
				keys.push_back(hotkey["key"]);
			}
			catch (json::Exception const& e) {
				LOG_E("agi/hotkey/load") << "Failed loading hotkey for command '" << command.first << "': " << e.what();
			}

			ComboInsert(Combo(context, command.first, keys));
		}
	}
}
Beispiel #14
0
// return the value in the text control
wxString wxGridCellChoiceEditor::GetValue() const
{
  return Combo()->GetValue();
}
Beispiel #15
0
void Scene::setbg_3(){
    QString load;
    if(difficulty==4)
        load=":/pics/pics/bg_oni.png";
    else if(difficulty==3)
        load=":/pics/pics/bg_hard.png";
    else if(difficulty==2)
        load=":/pics/pics/bg_normal.png";
    else
        load=":/pics/pics/bg_easy.png";
    QImage bg;
    bg.load(load);
    bg = bg.scaled(770,400);
    this->setBackgroundBrush(bg);
    text1->setText(title[s]);
    text1->setPos(488,9);
    addItem(text1);
    Map.setSongPlay(title[s]);
    track = new QMediaPlayer(this);
    track->setMedia(QUrl::fromLocalFile(QDir::toNativeSeparators(Map.trackPath)));
    VOL=(Map.map["SONGVOL"]-Map.map["SEVOL"])>0?(Map.map["SONGVOL"]-Map.map["SEVOL"]+50):70;
    track->setVolume(VOL);
    BPM=Map.map["BPM"];
    Map.getMap(title[s],Map.star[difficulty-1]);
    Map.convert(setRandom);
    if(setRandom==true){
        QPixmap ran;
        ran.load(":/pics/pics/optionicon_random.png");
        randomTag = new QGraphicsPixmapItem;
        randomTag->setPos(199,83);
        randomTag->setPixmap(ran);
        addItem(randomTag);
    }
    if(setAuto==true){
        QPixmap au;
        au.load(":/pics/pics/optionicon_auto.png");
        autoTag = new QGraphicsPixmapItem;
        autoTag->setPos(394,72);
        autoTag->setPixmap(au);
        addItem(autoTag);
    }
    if(set30secMode==true){
        QPixmap ctd;
        ctd.load(":/pics/pics/optionicon_demo.png");
        countdownTag = new QGraphicsPixmapItem;
        countdownTag->setPos(294,72);
        countdownTag->setPixmap(ctd);
        addItem(countdownTag);
        countdown = new QTimer(this);
        QObject::connect(countdown , SIGNAL(timeout()) , this , SLOT(secondsLeft()));
    }
    songMap=Map.songMap;
    foreach (QString i, songMap) {
        qDebug()<<i<<endl;
    }

    RD = new QTimer(this);
    LD = new QTimer(this);
    RK = new QTimer(this);
    LK = new QTimer(this);
    rdp = new QGraphicsPixmapItem;ldp = new QGraphicsPixmapItem;
    rkp = new QGraphicsPixmapItem;lkp = new QGraphicsPixmapItem;
    QPixmap res;
    res.load(":/pics/pics/rd.png");
    rdp->setPixmap(res);rdp->setPos(147,123);
    res.load(":/pics/pics/ld.png");
    ldp->setPixmap(res);ldp->setPos(106,123);
    res.load(":/pics/pics/rk.png");
    rkp->setPixmap(res);rkp->setPos(147,124);
    res.load(":/pics/pics/lk.png");
    lkp->setPixmap(res);lkp->setPos(105,124);
    for(int i=0;i<4;i++){
        add[i]=false;
    }
    QObject::connect(this , SIGNAL(PlayRdong()) , this , SLOT(playRdong()));
    QObject::connect(this , SIGNAL(PlayLdong()) , this , SLOT(playLdong()));
    QObject::connect(this , SIGNAL(PlayRka()) , this , SLOT(playRka()));
    QObject::connect(this , SIGNAL(PlayLka()) , this , SLOT(playLka()));
    QObject::connect(RD , SIGNAL(timeout()) , this , SLOT(playRdong()));
    QObject::connect(LD , SIGNAL(timeout()) , this , SLOT(playLdong()));
    QObject::connect(RK , SIGNAL(timeout()) , this , SLOT(playRka()));
    QObject::connect(LK , SIGNAL(timeout()) , this , SLOT(playLka()));    

    AniTimer1 = new QTimer(this);
    QObject::connect(AniTimer1 , SIGNAL(timeout()) , this , SLOT(moveJudgement()));
    QObject::connect(AniTimer1 , SIGNAL(timeout()) , this , SLOT(FlySoul()));
    QObject::connect(AniTimer1 , SIGNAL(timeout()) , this , SLOT(MidSoul()));
    QObject::connect(AniTimer1 , SIGNAL(timeout()) , this , SLOT(WalkSoul()));

    QObject::connect(this , SIGNAL(Great()) , this , SLOT(GenGreat()));
    QObject::connect(this , SIGNAL(Good()) , this , SLOT(GenGood()));
    QObject::connect(this , SIGNAL(Miss()) , this , SLOT(GenMiss()));
    QObject::connect(this , SIGNAL(Combo()) , this , SLOT(ShowCombo()));
    QObject::connect(this , SIGNAL(Score()) , this , SLOT(ShowScore()));
    QObject::connect(this , SIGNAL(Jump()) , this , SLOT(donJump()));
    QObject::connect(this , SIGNAL(SoulF()) , this , SLOT(GenFlySoul()));
    QObject::connect(this , SIGNAL(SoulM()) , this , SLOT(GenMidSoul()));
    QObject::connect(this , SIGNAL(SoulW()) , this , SLOT(GenWalkSoul()));

    ex1.load(":/pics/pics/explosion_s4.png");
    AniTimer2 = new QTimer(this);
    QObject::connect(AniTimer2 , SIGNAL(timeout()) , this , SLOT(RemoveExplode()));
    QObject::connect(this , SIGNAL(Explode()) , this , SLOT(GenExplode()));

    AniTimer3 = new QTimer(this);
    QObject::connect(AniTimer3 , SIGNAL(timeout()) , this , SLOT(Jumper()));
    jumper = new QGraphicsPixmapItem;
    jumper->setPos(0,0);
    addItem(jumper);

    AniTimer4 = new QTimer(this);
    QObject::connect(AniTimer4 , SIGNAL(timeout()) , this , SLOT(Dance()));
    loadDancerPic();
    createDanceItem();

    great=0;good=0;miss=0;
    combo=0;maxcombo=0;soul=0,score=0;
    secLeft=30;jumpPicNum=1;
    msec=60000/BPM/4+2;
    test=60000/BPM/16;
    waitfor=109*test/2+Map.map["OFFSET"]*1000;
    for(int i=0;i<10;i++){
        numberPic[i].load(":/pics/pics/number_"+QString::number(i)+".png");
    }
    for(int i=0;i<10;i++){
        ctdnumberPic[i].load(":/pics/pics/number_"+QString::number(i)+".png");
    }
    for(int i=0;i<10;i++){
        scorenumberPic[i].load(":/pics/pics/scorenumber_"+QString::number(i)+".png");
    }
    for(int i=50;i<1000;i+=100){
        QSound *so;
        QString c;
        c=QString::number(i);
        so = new QSound(":/sound/sound/voice_"+c+"combo.wav");
        comTrack.push_back(so);
        if(i==50)i+=50;
    }
    for(int i=0;i<3;i++){
        jumpPic[i].load(":/pics/pics/playerchar_normal"+QString::number(i+1)+".png");
        jumpPic[i] = jumpPic[i].scaled(jumpPic[i].width()*1.48,jumpPic[i].height()*1.48);
    }
    //Etimer = new QElapsedTimer;
    //Etimer->start();

    timer = new QTimer(this);
    QObject::connect(timer , SIGNAL(timeout()) , this , SLOT(stopWait()));
    timer1 = new QTimer(this);
    timer2 = new QTimer(this);
    timer3 = new QTimer(this);
    cout<<"msec: "<<msec<<endl;
    cout<<"waitfor: "<<waitfor<<endl;
    QObject::connect(timer2 , SIGNAL(timeout()) , this , SLOT(Generate()));
    if(setAuto==false)
        QObject::connect(timer1 , SIGNAL(timeout()) , this , SLOT(Move()));
    else
        QObject::connect(timer1 , SIGNAL(timeout()) , this , SLOT(Auto()));

    QObject::connect(timer3 , SIGNAL(timeout()) , this , SLOT(startWave()));
    if(waitfor<0){
        track->play();
        timer->start(-waitfor);
        waitfor=0;
    }
    else
        timer->start(0);
}
void wxFastComboEditor::Reset()
{
    Combo()->SetValue(m_startValue);
    Combo()->SetInsertionPointEnd();
}
wxString wxFastComboEditor::GetValue() const
{
    return Combo()->GetValue();
}
Beispiel #18
0
   int PRSolution3::RAIM2Compute(const CommonTime& Tr,
                               vector<SatID>& Satellite,
                               const vector<double>& Pseudorange,
                               const XvtStore<SatID>& Eph,
                               TropModel *pTropModel)
      throw(Exception)
   {
      try
      {
         int iret,N,Nreject,MinSV;
         size_t i, j;
         vector<bool> UseSat, UseSave;
         vector<int> GoodIndexes;
         // Use these to save the 'best' solution within the loop.
         int BestNIter=0;
         double BestRMS=0.0, BestSL=0.0, BestConv=0.0;
         Vector<double> BestSol(3,0.0);
         vector<bool> BestUse;
         BestRMS = -1.0;      // this marks the 'Best' set as unused.
	 Matrix<double> BestCovariance;

         // ----------------------------------------------------------------
         // initialize

         Valid = false;

         bool hasGlonass = false;
         bool hasOther = false;
         Vector<int> satSystems(Satellite.size());
         //Check if we have a mixed system
         for ( i = 0; i < Satellite.size(); ++i)
         {
            satSystems[i] = ((Satellite[i].system == SatID::systemGlonass) ? (1) : (0) );

            if (satSystems[i] == 1) hasGlonass = true;
            else hasOther = true;
         }

         // Save the input solution
         // (for use in rejection when ResidualCriterion is false).
         if (!hasGlonass && Solution.size() != 4)
         {
            Solution.resize(4);
         }
         else if (hasGlonass && hasOther && Solution.size() != 5)
         {
            Solution.resize(5);
         }
         Solution = 0.0;

         // ----------------------------------------------------------------
         // fill the SVP matrix, and use it for every solution
         // NB this routine can set Satellite[.]=negative when no ephemeris

         i = PrepareAutonomousSolution(Tr, Satellite, Pseudorange, Eph, SVP,
             Debug?pDebugStream:0);
         if(Debug && pDebugStream) {
            *pDebugStream << "In RAIMCompute after PAS(): Satellites:";
            for(j=0; j<Satellite.size(); j++) {
               RinexSatID rs(::abs(Satellite[j].id), Satellite[j].system);
               *pDebugStream << " " << (Satellite[j].id < 0 ? "-":"") << rs;
            }
            *pDebugStream << endl;
            *pDebugStream << " SVP matrix("
               << SVP.rows() << "," << SVP.cols() << ")" << endl;
            *pDebugStream << fixed << setw(16) << setprecision(3) << SVP << endl;
         }
         if (i) return i;  // return is 0 (ok) or -4 (no ephemeris)
         
         // count how many good satellites we have
         // Initialize UseSat based on Satellite, and build GoodIndexes.
         // UseSat is used to mark good sats (true) and those to ignore (false).
         // UseSave saves the original so it can be reused for each solution.
         // Let GoodIndexes be all the indexes of Satellites that are good:
         // UseSat[GoodIndexes[.]] == true by definition

         for (N=0,i=0; i<Satellite.size(); i++)
         {
            if (Satellite[i].id > 0)
            {
               N++;
               UseSat.push_back(true);
               GoodIndexes.push_back(i);
            }
            else
            {
               UseSat.push_back(false);
            }
         }
         UseSave = UseSat;
         
         // don't even try if there are not 4 good satellites

         if (!hasGlonass && N < 4)
            return -3;
         else if (hasGlonass && hasOther && N < 5)
            return -3;

         // minimum number of sats needed for algorithm
         MinSV = 5;   // this would be RAIM
         // ( not really RAIM || not RAIM at all - just one solution)
         if (!ResidualCriterion || NSatsReject==0)
            MinSV=4;
         
         // how many satellites can RAIM reject, if we have to?
         // default is -1, meaning as many as possible
         Nreject = NSatsReject;
         if (Nreject == -1 || Nreject > N-MinSV)
            Nreject=N-MinSV;
            
         // ----------------------------------------------------------------
         // now compute the solution, first with all the data. If this fails,
         // reject 1 satellite at a time and try again, then 2, etc.
         
         // Slopes for each satellite are computed (cf. the RAIM algorithm)
         Vector<double> Slopes(Pseudorange.size());
         
         // Residuals stores the post-fit data residuals.
         Vector<double> Residuals(Satellite.size(),0.0);
         
         
         // compute all the Combinations of N satellites taken 4 at a time
         Combinations Combo(N,N-4);
         
         // compute a solution for each combination of marked satellites
         do{
            // Mark the satellites for this combination
            UseSat = UseSave;
            for (i = 0; i < GoodIndexes.size(); i++)
            {
               if (Combo.isSelected(i))
                  UseSat[i]=false;
            }
            // ----------------------------------------------------------------
            // Compute a solution given the data; ignore ranges for marked
            // satellites. Fill Vector 'Slopes' with slopes for each unmarked
            // satellite.
            // Return 0  ok
            //       -1  failed to converge
            //       -2  singular problem
            //       -3  not enough good data
            NIterations = MaxNIterations;             // pass limits in
            Convergence = ConvergenceLimit;
            iret = AutonomousPRSolution(Tr, UseSat, SVP, pTropModel, Algebraic,
               NIterations, Convergence, Solution, Covariance, Residuals, Slopes,
               pDebugStream, ((hasGlonass && hasOther)?(&satSystems):(NULL)) );
            
            // ----------------------------------------------------------------
            // Compute RMS residual...
               // and in the usual case
               RMSResidual = RMS(Residuals);
            // ... and find the maximum slope
            MaxSlope = 0.0;
            if (iret == 0)
            {
               for (i=0; i<UseSat.size(); i++)
               {
                  if (UseSat[i] && Slopes(i)>MaxSlope)
                     MaxSlope=Slopes[i];
               }
            }
            // ----------------------------------------------------------------
            // print solution with diagnostic information
            if (Debug && pDebugStream)
            {
               GPSWeekSecond weeksec(Tr);
               *pDebugStream << "RPS " << setw(2) << "4" 
                  << " " << setw(4) << weeksec.week
                  << " " << fixed << setw(10) << setprecision(3) << weeksec.sow
                  << " " << setw(2) << N-4 << setprecision(6)
                  << " " << setw(16) << Solution(0)
                  << " " << setw(16) << Solution(1)
                  << " " << setw(16) << Solution(2)
                  << " " << setw(14) << Solution(3);
               if (hasGlonass && hasOther)
                  *pDebugStream << " " << setw(16) << Solution(4);
               *pDebugStream << " " << setw(12) << RMSResidual
                  << " " << fixed << setw(5) << setprecision(1) << MaxSlope
                  << " " << NIterations
                  << " " << scientific << setw(8) << setprecision(2)<< Convergence;
                  // print the SatID for good sats
               for (i=0; i<UseSat.size(); i++)
               {
                  if (UseSat[i])
                     *pDebugStream << " " << setw(3)<< Satellite[i].id;
                  else
                     *pDebugStream << " " << setw(3) << -::abs(Satellite[i].id);
               }
                  // also print the return value
               *pDebugStream << " (" << iret << ")" << endl;
            }// end debug print
            
            // ----------------------------------------------------------------
            // deal with the results of AutonomousPRSolution()
            if (iret)
            {     // failure for this combination
               RMSResidual = 0.0;
               Solution = 0.0;
            }
            else
            {  // success
                  // save 'best' solution for later
               if (BestRMS < 0.0 || RMSResidual < BestRMS)
               {
                  BestRMS = RMSResidual;
                  BestSol = Solution;
                  BestUse = UseSat;
                  BestSL = MaxSlope;
                  BestConv = Convergence;
                  BestNIter = NIterations;
               }
	       // assign to the combo
	       ComboSolution.push_back(Solution);
	       ComboSolSat.push_back(UseSat);

                  // quit immediately?
               if ((ReturnAtOnce) && RMSResidual < RMSLimit)
                  break;
            }
            
            // get the next Combinations and repeat
         } while(Combo.Next() != -1);
         /*
         // end of the stage
         if (BestRMS > 0.0 && BestRMS < RMSLimit)
         {     // success
            iret=0;
         }
	 */
         
         // ----------------------------------------------------------------
         // copy out the best solution and return
         Convergence = BestConv;
         NIterations = BestNIter;
         RMSResidual = BestRMS;
         Solution = BestSol;
         MaxSlope = BestSL;
	 Covariance =BestCovariance;
         for (Nsvs=0,i=0; i<BestUse.size(); i++)
         {
            if (!BestUse[i])
               Satellite[i].id = -::abs(Satellite[i].id);
            else
               Nsvs++;
         }

         // FIXME should this be removed? I don't even know what slope is.
         if (iret==0 && BestSL > SlopeLimit)
            iret=1;
         if (iret==0 && BestSL > SlopeLimit/2.0 && Nsvs == 5)
            iret=1;
         if (iret>=0 && BestRMS >= RMSLimit)
            iret=2;
            
         if (iret==0)
            Valid=true;

         
         return iret;
      }
      catch(Exception& e)
      {
         GPSTK_RETHROW(e);
      }
   }  // end PRSolution2::RAIMCompute()
void startGame() 
{
	g_game->resetLevel( g_levelNdx );	
	g_state = STATE_PLAYING;

	if (musicOn) {
		//Mix_HaltMusic();
		Mix_PlayMusic( music_ingame, -1 );	
	}


#if 0
	// add some combos.. TODO.. make dependant on level
	Combo c;


// debugging combos
	c = Combo( 10 );
	c.addGroup( PUMPKIN, 3 );
	c.m_name = "Three Pumpkins";
	c.m_desc = "Three matching items";
	g_game->addCombo( c );

	c = Combo( 20 );
	c.addGroup( PUMPKIN, 4 );
	c.m_name = "Four Pumpkins";
	c.m_desc = "Four matching items";
	g_game->addCombo( c );

	c = Combo( 30 );
	c.addGroup( PUMPKIN, 2 );
	c.addGroup( SKULL, 2 );
	c.addGroup( FISH_HEAD, 1 );
	c.m_name = "Mixed Bag";	
	g_game->addCombo( c );

	c = Combo( 40 );
	c.addGroup( PUMPKIN, 1 );
	c.addGroup( PUMPKIN+1, 1 );
	c.addGroup( PUMPKIN+2, 1 );
	c.addGroup( PUMPKIN+3, 1 );
	c.addGroup( SKULL, 1 );
	c.m_name = "One of each";	
	g_game->addCombo( c );

	// real combos
	c = Combo( 10 );
	c.addGroup( ANY_ITEM, 3 );
	c.m_name = "Three of a kind";
	c.m_desc = "Three matching items";
	g_game->addCombo( c );


	c = Combo( 20 );
	c.addGroup( ANY_ITEM, 4 );
	c.m_name = "Four of a kind";
	c.m_desc = "Four matching items";
	g_game->addCombo( c );

	c = Combo( 60 );
	c.addGroup( ANY_ITEM, 5 );
	c.m_name = "Jumbo Pie";
	c.m_desc = "Five matching items";
	g_game->addCombo( c );

	c = Combo( 30 );
	c.addGroup( ANY_ITEM, 3 );
	c.addGroup( ANY_ITEM, 2 );
	c.m_name = "Full House";
	c.m_desc = "A pair and three matching items";
	g_game->addCombo( c );
	
	c = Combo( 15 );
	c.addGroup( ANY_PUMPKIN, 2 );
	c.addGroup( SKULL, 1 );
	c.m_name = "Pumpkin Surprise";
	c.m_desc = "Pair of Pumpkins and a Skull";
	g_game->addCombo( c );

	c = Combo( 15 );
	c.addGroup( ANY_PUMPKIN, 2 );
	c.addGroup( ANY_PUMPKIN, 2 );	
	c.m_name = "Pumpkin Medly";
	c.m_desc = "Two pairs of pumpkins";
	g_game->addCombo( c );

	c = Combo( 50 );
	c.addGroup( PUMPKIN, 1 );
	c.addGroup( PUMPKIN_ORANGE, 1 );
	c.addGroup( PUMPKIN_YELLOW, 1 );
	c.addGroup( PUMPKIN_RED, 1 );
	c.m_name = "Pumpkin Supreme";
	c.m_desc = "One of each pumpkin";
	g_game->addCombo( c );

	c = Combo( 75 );
	c.addGroup( ANY_PUMPKIN, 4 );
	c.addGroup( FISH_HEAD, 1 );
	c.m_name = "Stargazy Pie";
	c.m_desc = "Four Pumpkins and a Fishhead";
	g_game->addCombo( c );
#endif

}
void GameState::loadLevels( const std::string &filename )
{
	FILE *fp = fopen( filename.c_str(), "rt" );

	if (!fp) {
		printf ("Can't open level file %s!! This is bad...\n", 
				filename.c_str() );
		return;
	}

	Combo c;
	char line[1000], cmd[100];
	while (!feof(fp)) {
		fgets( line, 1000, fp );

		// skip comments and blank lines
		if ((line[0]=='\n') || (line[0]=='#')) continue;
		sscanf( line, "%s", cmd );

		// remove newlines
		if (line[strlen(line)-1] == '\n') {
			line[strlen(line)-1]=0;
		}

		if (!strcmp(cmd, "combo")) {
			char cname[100], secret[10], comboData[20];
			int cval;
			c = Combo();

			sscanf( line, "%*s %s %d %s %s", cname, &cval, secret, comboData );
			c.m_desc = cname;
			c.m_value = cval;
			if (!strcmp(secret, "yes")) {
				c.m_secret = true;
			} else {
				c.m_secret = false;
			}

			for (char *ch = comboData; *ch; ch +=2 ) {
				int type,  num;
				switch (*ch) {
				case 'A': type = ANY_ITEM; break;
				case 'P': type = ANY_PUMPKIN; break;
				case 'a': type = PUMPKIN; break;
				case 'b': type = PUMPKIN_ORANGE; break;	
				case 'c': type = PUMPKIN_YELLOW; break;	
				case 'd': type = PUMPKIN_RED; break;
				case 'S': type = SKULL; break;
				case 'F': type = FISH_HEAD; break;
				case 'B': type = BLACKBIRD; break;
				default:
					printf( "Unknown combo code %c. Using 'P' instead.\n", *ch );
					break;
				}

				num = ((*(ch+1)) - '1') + 1;

				c.addGroup( type, num );

				//printf("Adding combogroup %s %d - %d %d\n", c.m_desc.c_str(), 
				//		c.m_value, type, num );
			}

			c.m_name = std::string( strchr( line, ':' )+1 );

			m_allCombos.push_back( c );

		} else if (!strcmp(cmd, "level")) {
			Level l;
			char group[100], combos[2000];
			int rate;
			sscanf( line, "%*s %s %d %s", group, &rate, combos );

			l = Level();
			l.m_group = group;
			l.m_prodrate = rate;
			
			// read the title
			fgets( line, 1000, fp );
			if (line[strlen(line)-1] == '\n') {
				line[strlen(line)-1]=0;
			}
			l.m_title = line;
			
			// read the description
			while (!feof(fp)) {
				fgets( line, 1000, fp );
				if (line[0]=='\n') break;
				l.m_desc.append(  line );
			}

			// add the combos
			char *tok = strtok( combos, "," );
			while( tok ) {
				for (int i = 0; i < m_allCombos.size(); i++) {
					if (!strcmp( m_allCombos[i].m_desc.c_str(), tok)) {
						l.m_combos.push_back( m_allCombos[i] );
						break;
					}
				}
				tok = strtok( NULL, "," );
			}

			// yay
			m_levels.push_back( l );			
		}
	}	
}
Beispiel #21
0
bool GameLogic_match::matchColors(int pos,bool ishelp){
    m_match_ignore_pos.clear();
    m_match_clear_pos.clear();
    m_match_new_gem_type.clear();
    int color = m_gems[pos]->getColor();
    
    matchColor(pos);
    
    bool hasBombs = false;
    
    if (m_match_clear_pos.size()>0) {
        if (!ishelp) {
            Combo();
        }
        hasBombs = true;
    }
    
    if (m_match_new_gem_type.size()>1) {
        vector<NewSpcialGemInfos*>::iterator it;
        for ( it= m_match_new_gem_type.begin();it<m_match_new_gem_type.end();it++) {
            NewSpcialGemInfos* infos = *it;
            if (infos->gem_area_count==0) {
                m_match_new_gem_type.erase(it);
                it--;
            }
        }
    }
    
    for (unsigned int i=0; i<m_match_clear_pos.size();i++) {
        if (ishelp) {
            m_gems[m_match_clear_pos[i]]->showHelpAnim();
        }else{
            Bomb(m_match_clear_pos[i]);
        }
    }
    //        if (m_match_clear_pos.size()>0) {
    //            CCLOG("clear_count %ld",m_match_clear_pos.size());
    //        }
    //
    //        for (int i=0; i<m_match_new_gem_type.size(); i++) {
    //            cout<<"gem_v_count "<<m_match_new_gem_type[i]->gem_v_count
    //            <<" gem_h_count "<<m_match_new_gem_type[i]->gem_h_count
    //            <<" gem_area_count "<<m_match_new_gem_type[i]->gem_area_count
    //            <<" gem_magic_count "<<m_match_new_gem_type[i]->gem_magic_count
    //            <<" pos "<<m_match_new_gem_type[i]->pos;
    //        }
    
    // return hasBombs;
    
    if (ishelp) {
        return hasBombs;
    }
    
    for (unsigned int i=0; i< m_match_new_gem_type.size(); i++) {
        NewSpcialGemInfos* infos = m_match_new_gem_type[i];
        if (!m_gems[infos->pos]->isEmpty()) {
            continue;
        }
        
        if (!m_blocks[infos->pos]->canInsertGem()) {
            continue;
        }
        for (int j=0; j<infos->gem_area_count; j++) {
            int _p;
            if (m_gems[infos->pos]->isEmpty()) {
                _p = infos->pos;
            }else{
                _p = getEmptyPosRound(infos->pos);
            }
            if (_p!=-1) {
                m_gems[_p]->create(GEM_AREA*10+color);
                showSeaHurt(200, _p);
                if (G::g_game_mode == GAMEMODE_SEA) {
                    G::G_Add_Achievement_Complete(35);
                }
                achieve_count->combine_count++;
            }
        }
        for (int j=0; j<infos->gem_magic_count; j++) {
            int _p;
            if (m_gems[infos->pos]->isEmpty()) {
                _p = infos->pos;
            }else{
                _p = getEmptyPosRound(infos->pos);
            }
            if (_p!=-1) {
                m_gems[_p]->create(GEM_MAGIC*10+GEM_COLOR_NOCOLOR);
                G::G_Add_Achievement_Complete(8);
                achieve_count->create_magic_count++;
                achieve_count->combine_count++;
                showSeaHurt(200, _p);
                if (G::g_game_mode == GAMEMODE_SEA) {
                    G::G_Add_Achievement_Complete(35);
                }
            }
        }
        for (int j=0; j<infos->gem_h_count; j++) {
            int _p;
            if (m_gems[infos->pos]->isEmpty()) {
                _p = infos->pos;
            }else{
                _p = getEmptyPosRound(infos->pos);
            }
            if (_p!=-1) {
                m_gems[_p]->create(GEM_H*10+color);
                showSeaHurt(200, _p);
                if (G::g_game_mode == GAMEMODE_SEA) {
                    G::G_Add_Achievement_Complete(35);
                }
                achieve_count->combine_count++;
            }
        }
        for (int j=0; j<infos->gem_v_count; j++) {
            int _p;
            if (m_gems[infos->pos]->isEmpty()) {
                _p = infos->pos;
            }else{
                _p = getEmptyPosRound(infos->pos);
            }
            if (_p!=-1) {
                m_gems[_p]->create(GEM_V*10+color);
                showSeaHurt(200, _p);
                if (G::g_game_mode == GAMEMODE_SEA) {
                    G::G_Add_Achievement_Complete(35);
                }
                achieve_count->combine_count++;
            }
        }
    }
    
    m_match_ignore_pos.clear();
    m_match_clear_pos.clear();
    m_match_new_gem_type.clear();
    
    return hasBombs;
}
Beispiel #22
0
void CGameDlg::OnLButtonUp(UINT nFlags, CPoint point)
{
	if(point.y<m_ptGameTop.y || point.x<m_ptGameTop.x || !m_bPlaying || m_bPause)
	{
		CDialogEx::OnLButtonUp(nFlags, point);
	}
	else{
	if(!m_GameC.IsWin())
	{
	int nRow = (point.y-m_ptGameTop.y)/m_sizeElem.cy;
	int nCol = (point.x-m_ptGameTop.x)/m_sizeElem.cx;
	
	if( m_GameC.GetElement(nRow,nCol)!=BLANK && nRow < SetRow && nCol < SetCol)
	{
		if(m_bFirstPoint) //the First Point
		{
			m_bFirstPoint = false;
			DrawTipFrame(nRow,nCol);
			m_GameC.SetFirstPoint(nRow,nCol);
			if(!mute)
			m_nSound.Select();
		}
		else              //the Second Point
		{
			m_bFirstPoint = true;
			DrawTipFrame(nRow,nCol);
			m_GameC.SetSecPoint(nRow,nCol);
			Vertex avPath[MAX_SAVED_VERTEX_NUM];
			if(!mute)
			m_nSound.Select();
			if(m_GameC.Link(avPath,vex))
			{
				DrawTipLine(avPath,vex);
				if(!mute)
				m_nSound.Erase();
				Score+=10;

				ShowScore();
				if(!m_combo)
				{
					m_combo_check1 = m_GameProgress.GetPos();
					m_combo = true;
				}
				else if(m_combo)
				{
					m_combo_check2 = m_GameProgress.GetPos();
					m_combo = false;
				}
				int firsttime,lasttime;
				(m_combo_check1 > m_combo_check2)?  (firsttime = m_combo_check1, lasttime = m_combo_check2) : (firsttime = m_combo_check2, lasttime = m_combo_check1);
				if(firsttime - lasttime < 3)
				{
					Output_combo = true;
					TotalCombo += 1;
					ComboScore += 5;
					Score +=ComboScore;
					ShowScore();	
				}
				else
				{
					ComboScore = 0;	
				}
							
			}
		
		UpdateMap();
		if(Output_combo)
		{
			Combo();
			Output_combo = false;
		}
		Sleep(200);
		InvalidateRect(m_rtGameRect,FALSE);
		
		}
	}
	}
	else
	{
		if(!mute){
		m_nSound.Stop();
		m_nSound.Win();
		}
		m_bPlaying = false;
		int Lefttime = m_GameProgress.GetPos() ;
		TimeBonus =  (double)Score*((double)Lefttime/300);
		CGameResult result;
		result.TotalScore = Score+TimeBonus;
		result.TotalCombo = TotalCombo;
		result.TimeBonus = TimeBonus;
		result.DoModal();


	}
	}
	
}
Beispiel #23
0
void init(){

  //  scene.getLight(0).setOn(false);
  scene.getLight(0).setDiffuse(GeomColor(255,255,255,50));

  SceneLight &l = scene.getLight(1);
  static Camera cam(Vec(0,0,600,1),
                    Vec(0,0,-1,1),
                    Vec(0,-1,0,1));
  cam.setResolution(Size(1024,1024));
  scene.setGravity(Vec(0,0,-1000));

  l.setShadowCam(new Camera(cam));
  l.setShadowEnabled(true);
  l.setAnchorToWorld();
  l.setPosition(Vec(0,0,600,1));
  l.setOn(true);
  l.setSpecularEnabled(true);
  l.setDiffuseEnabled(true);
  l.setSpecular(GeomColor(0,100,255,255));
  l.setDiffuse(GeomColor(255,100,0,30));

  scene.setPropertyValue("shadows.use improved shading",true);
  scene.setPropertyValue("shadows.resolution",2048);
  scene.setPropertyValue("shadows.bias",10);


  //static const int W=20,H=13,DIM=W*H;
  static const int W=pa("-paper-dim",0), H=pa("-paper-dim",1);
  static Img8u frontFace = load<icl8u>(*pa("-ff"));
  static Img8u backFace = load<icl8u>(*pa("-bf"));

  const Size s(210,297);
  const Vec corners[4] = {
    Vec(-s.width/2, -s.height/2, 150,1),
    Vec(s.width/2, -s.height/2, 150,1),
    Vec(s.width/2, s.height/2, 150,1),
    Vec(-s.width/2, s.height/2, 150,1),
  };

  paper = new ManipulatablePaper(&scene,&scene,W,H,corners,true,&frontFace,&backFace);
  //scene.removeObject(paper);
  //paper->addShadow(-74.5);


  if(pa("-o")){
    std::vector<Camera> cams;
    for(int i=0;i<3;++i){
      cams.push_back(Camera(*pa("-c",i)));
    }
    capturer = new SceneMultiCamCapturer(scene, cams);
    //    Scene::enableSharedOffscreenRendering();
    scene.setDrawCamerasEnabled(false);
  }

  gui << Draw3D(Size::VGA).minSize(32,24).handle("draw")
      << (VBox().maxSize(12,100).minSize(12,1)
          << ( HBox()
               << Fps(10).handle("fps")
               << Button("add clutter").handle("add")
               )
          << ( HBox()
               << Button("stopped","running",true).out("run")
               << Button("paper ...").handle("props")
               )
          << ( HBox()
               << CheckBox("show cubes").out("showCubes")
               << CheckBox("show texture",false).out("showTexture")
               << CheckBox("show links",false).out("showLinks")
             )
          << FSlider(0,1,0.5).out("vertexMoveFactor").label("manual force")
          << FSlider(1,100,10).out("attractorStreangth").label("attractor force")
          << FSlider(0.0001,0.9999,0.9).handle("globalStiffness").label("global paper stiffness")
          << ( HBox()
               << Button("reset paper").handle("resetPaper")
               << Combo("1,5,10,25,!200,300,500").handle("maxFPS").label("max FPS")
               )
          << FSlider(0.1,20,2).handle("cm").label("collision margin")

          << ( HBox()
               << Button("memorize").handle("mem")
               << CheckBox("soften with mouse",true).handle("soften")
               << Button("test").handle("pct")
             )
          )

      << Show();

  propGUI << Prop("paper").minSize(16,1).maxSize(16,100) << Create();

  gui["pct"].registerCallback(paper_coords_test);
  gui["props"].registerCallback(utils::function((GUI&)propGUI,&GUI::switchVisibility));
  gui["resetPaper"].registerCallback(reset_paper);
  gui["globalStiffness"].registerCallback(change_global_stiffness);

  scene.PhysicsWorld::addObject(&ground);
  scene.Scene::addObject(&groundVis);

  DrawHandle3D draw = gui["draw"];
  draw->install(paper->createMouseHandler(0));
  draw->install(&foldLine);
  draw->link(scene.getGLCallback(0));

  foldLine.cb = utils::function(fold_line_cb);



}