Example #1
0
LadspaEffectDialog::LadspaEffectDialog(LadspaEffect *eff,
                                       wxWindow * parent,
                                       const LADSPA_Descriptor *data,
                                       float *inputControls,
                                       int sampleRate,
                                       double length)
   :wxDialog(parent, -1, LAT1CTOWX(data->Name),
             wxDefaultPosition, wxDefaultSize,
             wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER),
    effect(eff)
{
   mLength = length;
   numParams = 0;
   this->mData = data;
   this->inputControls = inputControls;
   this->sampleRate = sampleRate;
	#ifdef __WXMSW__
		// On Windows, for some reason, wxWindows calls OnTextCtrl during creation
		// of the text control, and LadspaEffectDialog::OnTextCtrl calls HandleText, 
		// which assumes all the fields have been initialized. 
		// This can give us a bad pointer crash, so manipulate inSlider to 
		// no-op HandleText during creation.
		inSlider = true;
	#else
		inSlider = false;
	#endif
   inText = false;

   toggles = new wxCheckBox*[mData->PortCount];
   sliders = new wxSlider*[mData->PortCount];
   fields = new wxTextCtrl*[mData->PortCount];
	labels = new wxStaticText*[mData->PortCount];
   ports = new unsigned long [mData->PortCount];

   unsigned long p;
   for(p=0; p<mData->PortCount; p++) {
      LADSPA_PortDescriptor d = mData->PortDescriptors[p];
      if (LADSPA_IS_PORT_CONTROL(d) &&
          LADSPA_IS_PORT_INPUT(d)) {
         ports[numParams] = p;
         numParams++;
      }
   }

   wxControl *item;

   wxBoxSizer *vSizer = new wxBoxSizer(wxVERTICAL);

   if (mData->Maker &&
       mData->Maker[0] && 
       LAT1CTOWX(mData->Maker) != wxString(_("None"))) {       
      item = new wxStaticText(this, 0,
                              wxString(_("Author: "))+LAT1CTOWX(mData->Maker));
      vSizer->Add(item, 0, wxALL, 5);
   }
   
   if (mData->Copyright &&
       mData->Copyright[0] && 
       LAT1CTOWX(mData->Copyright) != wxString(_("None"))) {
      
      item = new wxStaticText(this, 0,
                              LAT1CTOWX(mData->Copyright));
      vSizer->Add(item, 0, wxALL, 5);
   }

   wxScrolledWindow *w = new wxScrolledWindow(this,
                                              wxID_ANY,
                                              wxDefaultPosition,
                                              wxDefaultSize,
                                              wxVSCROLL | wxTAB_TRAVERSAL);

   // Try to give the window a sensible default/minimum size
   w->SetMinSize(wxSize(
      wxMax(600, parent->GetSize().GetWidth() * 2/3),
      parent->GetSize().GetHeight() / 2));
                                              
   w->SetScrollRate(0, 20);
   vSizer->Add(w, 1, wxEXPAND|wxALL, 5);

   // Preview, OK, & Cancel buttons
   vSizer->Add(CreateStdButtonSizer(this, ePreviewButton|eCancelButton|eOkButton), 0, wxEXPAND);

   SetSizer(vSizer);

   wxSizer *paramSizer =
      new wxStaticBoxSizer(wxVERTICAL, w, _("Effect Settings"));

   wxFlexGridSizer *gridSizer =
      new wxFlexGridSizer(5, 0, 0);
   gridSizer->AddGrowableCol(3);

   for (p = 0; p < numParams; p++) {
      item = new wxStaticText(w, 0, wxString(mData->PortNames[ports[p]], wxConvISO8859_1));
      gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);

      wxString fieldText;
      LADSPA_PortRangeHint hint = mData->PortRangeHints[ports[p]];

      if (LADSPA_IS_HINT_TOGGLED(hint.HintDescriptor)) {
         toggles[p] = new wxCheckBox(w, p, wxT(""));
         toggles[p]->SetValue(inputControls[ports[p]] > 0);
         gridSizer->Add(toggles[p], 0, wxALL, 5);
         ConnectFocus(toggles[p]);

         gridSizer->Add(1, 1, 0);
         gridSizer->Add(1, 1, 0);
         gridSizer->Add(1, 1, 0);
      }
      else {
         if (LADSPA_IS_HINT_INTEGER(hint.HintDescriptor))
            fieldText.Printf(wxT("%d"), (int)(inputControls[ports[p]] + 0.5));
         else
            fieldText = Internat::ToDisplayString(inputControls[ports[p]]);

         fields[p] = new wxTextCtrl(w, p, fieldText);
         gridSizer->Add(fields[p], 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
         ConnectFocus(fields[p]);

         wxString bound;
         double lower = 0.0;
         double upper = 0.0;
         bool haslo = false;
         bool hashi = false;
         bool forceint = false;

         if (LADSPA_IS_HINT_BOUNDED_BELOW(hint.HintDescriptor)) {
            lower = hint.LowerBound;
            haslo = true;
         }
         if (LADSPA_IS_HINT_BOUNDED_ABOVE(hint.HintDescriptor)) {
            upper = hint.UpperBound;
            hashi = true;
         }
         if (LADSPA_IS_HINT_SAMPLE_RATE(hint.HintDescriptor)) {
            lower *= sampleRate * 1000;
            upper *= sampleRate;
            forceint = true;
         }

         wxString str;
         if (haslo) {
            if (LADSPA_IS_HINT_INTEGER(hint.HintDescriptor) || forceint)
               str.Printf(wxT("%d"), (int)(lower + 0.5));
            else
               str = Internat::ToDisplayString(lower);
            item = new wxStaticText(w, 0, str);
            gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
         }
         else {
            gridSizer->Add(1, 1, 0);
         }

         sliders[p] =
             new wxSlider(w, p,
                          0, 0, 1000,
                          wxDefaultPosition,
                          wxSize(200, -1));
         gridSizer->Add(sliders[p], 0, wxALIGN_CENTER_VERTICAL | wxEXPAND | wxALL, 5);
         ConnectFocus(sliders[p]);

         if (hashi) {
            if (LADSPA_IS_HINT_INTEGER(hint.HintDescriptor) || forceint)
               str.Printf(wxT("%d"), (int)(upper + 0.5));
            else
               str = Internat::ToDisplayString(upper);
            item = new wxStaticText(w, 0, str);
            gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL, 5);
         }
         else {
            gridSizer->Add(1, 1, 0);
         }
      }
   }

   // Now add the length control
   if (effect->GetEffectFlags() & INSERT_EFFECT) {
      item = new wxStaticText(w, 0, _("Length (seconds)"));
      gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
      mSeconds = new wxTextCtrl(w, LADSPA_SECONDS_ID, Internat::ToDisplayString(length));
      gridSizer->Add(mSeconds, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
      gridSizer->Add(1, 1, 0);
      gridSizer->Add(1, 1, 0);
      gridSizer->Add(1, 1, 0);
      ConnectFocus(mSeconds);
   }

   // Set all of the sliders based on the value in the
   // text fields
	inSlider = false; // Now we're ready for HandleText to actually do something.
   HandleText();
   
   paramSizer->Add(gridSizer, 1, wxEXPAND | wxALL, 5);
   w->SetSizer(paramSizer);

   Layout();
   Fit();
   SetSizeHints(GetSize());

   eff->SetDialog(this);
}
Example #2
0
/* i18n-hint: WCAG2 is the 'Web Content Accessibility Guidelines (WCAG) 2.0', see http://www.w3.org/TR/WCAG20/ */
ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id,
                           const wxString & title,
                           const wxPoint & pos):
  wxDialog(parent, id, title, pos, wxDefaultSize,
     wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX )
{
   foregrounddB = 1234.0;
   backgrounddB = 1234.0;

   // NULL out the control members until the controls are created.
   mForegroundStartT = NULL;
   mForegroundEndT = NULL;
   mBackgroundStartT = NULL;
   mBackgroundEndT = NULL;
   wxTextValidator vld(wxFILTER_NUMERIC);
   wxString number;

   AudacityProject *p = GetActiveProject();
   mProjectRate = p->GetRate();

   ShuttleGui S(this, eIsCreating);
   
   S.SetBorder(5);
   S.StartHorizontalLay(wxCENTER, false);
   {
      S.AddTitle(_("Contrast Analyzer, for measuring rms volume differences between two selections of audio."));
   }
   S.EndHorizontalLay();
   S.StartStatic( _("Parameters") );
   {
      S.StartMultiColumn(5, wxEXPAND);
      {

         // Headings
         S.AddFixedText(wxT(""));   // spacer
         S.AddFixedText(_("Start"));
         S.AddFixedText(_("End"));
         S.AddFixedText(wxT(""));   // spacer
         S.AddFixedText(_("Volume    "));

         //Foreground
         S.AddFixedText(_("Foreground:"), false);
         if (mForegroundStartT == NULL)
         {
            mForegroundStartT = new
            TimeTextCtrl(this,
                         ID_FOREGROUNDSTART_T,
                         wxT(""),
                         0.0,
                         mProjectRate,
                         wxDefaultPosition,
                         wxDefaultSize,
                         true);
            mForegroundStartT->SetName(_("Foreground start time"));
            mForegroundStartT->SetFormatString(mForegroundStartT->GetBuiltinFormat(_("hh:mm:ss + hundredths")));
            mForegroundStartT->EnableMenu(false);
         }
         S.AddWindow(mForegroundStartT);

         if (mForegroundEndT == NULL)
         {
            mForegroundEndT = new
            TimeTextCtrl(this,
                         ID_FOREGROUNDEND_T,
                         wxT(""),
                         0.0,
                         mProjectRate,
                         wxDefaultPosition,
                         wxDefaultSize,
                         true);
            mForegroundEndT->SetName(_("Foreground end time"));
            mForegroundEndT->SetFormatString(mForegroundEndT->GetBuiltinFormat(_("hh:mm:ss + hundredths")));
            mForegroundEndT->EnableMenu(false);
         }
         S.AddWindow(mForegroundEndT);

         m_pButton_UseCurrentF = S.Id(ID_BUTTON_USECURRENTF).AddButton(_("Measure selection"));
         mForegroundRMSText=S.Id(ID_FOREGROUNDDB_TEXT).AddTextBox(wxT(""), wxT(""), 12);
         mForegroundRMSText->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(ContrastDialog::OnChar));

         //Background
         S.AddFixedText(_("Background:"));
         if (mBackgroundStartT == NULL)
         {
            mBackgroundStartT = new
            TimeTextCtrl(this,
                         ID_BACKGROUNDSTART_T,
                         wxT(""),
                         0.0,
                         mProjectRate,
                         wxDefaultPosition,
                         wxDefaultSize,
                         true);
            mBackgroundStartT->SetName(_("Background start time"));
            mBackgroundStartT->SetFormatString(mBackgroundStartT->GetBuiltinFormat(_("hh:mm:ss + hundredths")));
            mBackgroundStartT->EnableMenu(false);
         }
         S.AddWindow(mBackgroundStartT);

         if (mBackgroundEndT == NULL)
         {
            mBackgroundEndT = new
            TimeTextCtrl(this,
                         ID_BACKGROUNDEND_T,
                         wxT(""),
                         0.0,
                         mProjectRate,
                         wxDefaultPosition,
                         wxDefaultSize,
                         true);
            mBackgroundEndT->SetName(_("Background end time"));
            mBackgroundEndT->SetFormatString(mBackgroundEndT->GetBuiltinFormat(_("hh:mm:ss + hundredths")));
            mBackgroundEndT->EnableMenu(false);
         }
         S.AddWindow(mBackgroundEndT);

         m_pButton_UseCurrentB = S.Id(ID_BUTTON_USECURRENTB).AddButton(_("Measure selection"));
         mBackgroundRMSText = S.Id(ID_BACKGROUNDDB_TEXT).AddTextBox(wxT(""), wxT(""), 12);
         mBackgroundRMSText->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(ContrastDialog::OnChar));
      }
      S.EndMultiColumn();
   }
   S.EndStatic();

   //Result
   S.StartStatic( _("Result") );
   {
      S.StartMultiColumn(3, wxCENTER);
      {
         S.AddFixedText(_("Contrast Result:"));
         mPassFailText = S.Id(ID_RESULTS_TEXT).AddTextBox(wxT(""), wxT(""), 40);
         mPassFailText->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(ContrastDialog::OnChar));
         m_pButton_Reset = S.Id(ID_BUTTON_RESET).AddButton(_("Reset"));
         S.AddFixedText(_("Difference:"));
         mDiffText = S.Id(ID_RESULTSDB_TEXT).AddTextBox(wxT(""), wxT(""), 30);
         mDiffText->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(ContrastDialog::OnChar));
         m_pButton_Export = S.Id(ID_BUTTON_EXPORT).AddButton(_("Export"));
      }
      S.EndMultiColumn();
   }
   S.EndStatic();
   S.StartMultiColumn(3, wxEXPAND);
   {
      S.SetStretchyCol(1);
      m_pButton_GetURL = S.Id(ID_BUTTON_GETURL).AddButton(_("WCAG 2 Help"));
      S.AddFixedText(wxT(" "));   // spacer
      m_pButton_Close = S.Id(ID_BUTTON_CLOSE).AddButton(_("Close"));
   }
   S.EndMultiColumn();
   Layout();
   Fit();
   SetMinSize(GetSize());
   Center();
}
Example #3
0
// Define a constructor for my canvas
ConsoleCanvas::ConsoleCanvas(wxWindow *frame):
            wxWindow(frame, wxID_ANY,   wxPoint(20,20), wxSize(5,5),wxNO_BORDER/*wxSUNKEN_BORDER | wxCLIP_CHILDREN*/ )
{
      m_pParent = frame;

      pThisLegBox = new wxStaticBox(this, -1, _("This Leg"), wxPoint(1,1),
                                    wxSize(170,200), 0, _T("staticBox"));

      m_pitemStaticBoxSizerLeg = new wxStaticBoxSizer(pThisLegBox, wxVERTICAL);

 //     pSBoxRgn = new wxRegion(pThisLegBox->GetRect() );

      pThisLegFont = wxTheFontList->FindOrCreateFont(12, wxDEFAULT,wxNORMAL, wxBOLD, FALSE,
              wxString(_T("Eurostile Extended")));

      pThisLegBox->SetFont(*pThisLegFont);


      m_pLegRouteButton = new wxButton( this, ID_LEGROUTE, _("Leg/Route"), wxDefaultPosition, wxSize(-1, -1), 0 );
      m_pLegRouteButton->SetMinSize(wxSize(-1, 25));
      m_pitemStaticBoxSizerLeg->Add(m_pLegRouteButton, 0, wxALIGN_LEFT|wxALL|wxEXPAND, 2);


      pXTE = new AnnunText(this, -1,  _("Console Legend"), _("Console Value"));
      pXTE->SetALabel(_T("XTE"));
      m_pitemStaticBoxSizerLeg->Add(pXTE, 1, wxALIGN_LEFT|wxALL, 2);

      pBRG = new AnnunText(this, -1, _("Console Legend"), _("Console Value"));
      pBRG->SetALabel(_T("BRG"));
      m_pitemStaticBoxSizerLeg->Add(pBRG, 1, wxALIGN_LEFT|wxALL, 2);

      pVMG = new AnnunText(this, -1, _("Console Legend"), _("Console Value"));
      pVMG->SetALabel(_T("VMG"));
      m_pitemStaticBoxSizerLeg->Add(pVMG, 1, wxALIGN_LEFT|wxALL, 2);

      pRNG = new AnnunText(this, -1, _("Console Legend"), _("Console Value"));
      pRNG->SetALabel(_T("RNG"));
      m_pitemStaticBoxSizerLeg->Add(pRNG, 1, wxALIGN_LEFT|wxALL, 2);

      pTTG = new AnnunText(this, -1,  _("Console Legend"), _("Console Value"));
      pTTG->SetALabel(_T("TTG"));
      m_pitemStaticBoxSizerLeg->Add(pTTG, 1, wxALIGN_LEFT|wxALL, 2);


//    Create CDI Display Window


      pCDI = new CDI(this, -1, wxSIMPLE_BORDER, _T("CDI"));
      m_pitemStaticBoxSizerLeg->AddSpacer(10);
      m_pitemStaticBoxSizerLeg->Add(pCDI, 0, wxALIGN_LEFT|wxALL|wxEXPAND, 2);


      m_bShowRouteTotal = false;

      SetSizer( m_pitemStaticBoxSizerLeg );      // use the sizer for layout
      m_pitemStaticBoxSizerLeg->SetSizeHints(this);
      Layout();
      Fit();

      Hide();
}
Example #4
0
 static void Fit(DataVector *data,
                 Node *node,
                 size_t depth,
                 double *gain) { Fit(data, data->size(), node, depth, gain); }
Example #5
0
void findfunc()
{

  //dijet case
  // auto fmcppbjt = config.getfile_djt("mcppbfa");
  // auto nt = (TTree *)fmcppbjt->Get("nt");
  // seth(18,40,220);
  // auto hd = geth("hd");
  // auto hn = geth("hn");
  // nt->Project("hd","jtpt2","weight*(pthat>80 && jtpt1>100 && abs(refparton_flavorForB1)==5 && abs(refparton_flavorForB2)!=5 && dphi21>2.1)");
  // nt->Project("hn","jtpt2","weight*(pthat>80 && jtpt1>100 && abs(refparton_flavorForB1)==5 && abs(refparton_flavorForB2)!=5 && dphi21>2.1 && discr_csvV1_2>0.9)");
  // hn->Divide(hn,hd,1,1,"B")
  // hn->Fit(f)
  

  auto fpp = new TF1("fpp","expo",40,200);
  auto f1 = new TF1("fPb1","expo",40,200);
  auto f2 = new TF1("fPb2","expo",40,200);
  auto f3 = new TF1("fPb3","expo",40,200);
  seth(18,40,200);


  auto ntpp = (TTree *)config.getfile_inc("mcppqcd")->Get("nt");

  auto hd = geth("hd");
  auto hn = geth("hn",";p_{T} [GeV];mistag probability");
  ntpp->Project("hd","jtpt","weight*(pthat>50 && refpt>20 && abs(refparton_flavorForB)!=5)");
  ntpp->Project("hn","jtpt","weight*(pthat>50 && refpt>20 && abs(refparton_flavorForB)!=5 && discr_csvV1>0.9)");
  hn->Divide(hn,hd,1,1,"B");
  // hn->Scale(1/hn->Integral());
  hn->Fit(fpp);

  auto nt = (TTree *)config.getfile_inc("mcPbqcd")->Get("nt");

  auto hd1 = geth("hd1");
  auto hn1 = geth("hn1",";p_{T} [GeV];mistag probability");
  nt->Project("hd1","jtpt","weight*(pthat>50 && refpt>20 && bin < 20 && abs(refparton_flavorForB)!=5)");
  nt->Project("hn1","jtpt","weight*(pthat>50 && refpt>20 && bin < 20 && abs(refparton_flavorForB)!=5 && discr_csvV1>0.9)");
  hn1->Divide(hn1,hd1,1,1,"B");
  // hn1->Scale(1/hn1->Integral());
  hn1->Fit(f1);

  auto hd2 = geth("hd2");
  auto hn2 = geth("hn2",";p_{T} [GeV];mistag probability");
  nt->Project("hd2","jtpt","weight*(pthat>50 && refpt>20 && bin>=20 && bin<60 && abs(refparton_flavorForB)!=5)");
  nt->Project("hn2","jtpt","weight*(pthat>50 && refpt>20 && bin>=20 && bin<60 && abs(refparton_flavorForB)!=5 && discr_csvV1>0.9)");
  hn2->Divide(hn2,hd2,1,1,"B");
  // hn2->Scale(1/hn2->Integral());
  hn2->Fit(f2);

  auto hd3 = geth("hd3");
  auto hn3 = geth("hn3",";p_{T} [GeV];mistag probability");
  nt->Project("hd3","jtpt","weight*(pthat>50 && refpt>20 && bin>=60 && abs(refparton_flavorForB)!=5)");
  nt->Project("hn3","jtpt","weight*(pthat>50 && refpt>20 && bin>=60 && abs(refparton_flavorForB)!=5 && discr_csvV1>0.9)");
  hn3->Divide(hn3,hd3,1,1,"B");
  // hn3->Scale(1/hn3->Integral());
  hn3->Fit(f3);


  // because of backward imcompatibility with root version on polui

  cout<<"auto fpp = new TF1(\"fpp\",\"expo\","<<fpp->GetXmin()<<","<<fpp->GetXmax()<<");"<<endl;
  cout<<"auto fPb1 = new TF1(\"fPb1\",\"expo\","<<f1->GetXmin()<<","<<f1->GetXmax()<<");"<<endl;
  cout<<"auto fPb2 = new TF1(\"fPb2\",\"expo\","<<f2->GetXmin()<<","<<f2->GetXmax()<<");"<<endl;
  cout<<"auto fPb3 = new TF1(\"fPb3\",\"expo\","<<f3->GetXmin()<<","<<f3->GetXmax()<<");"<<endl;


  cout<<"fpp->SetParameters("<<fpp->GetParameter(0)<<","<<fpp->GetParameter(1)<<");"<<endl;
  cout<<"fPb1->SetParameters("<<f1->GetParameter(0)<<","<<f1->GetParameter(1)<<");"<<endl;
  cout<<"fPb2->SetParameters("<<f2->GetParameter(0)<<","<<f2->GetParameter(1)<<");"<<endl;
  cout<<"fPb3->SetParameters("<<f3->GetParameter(0)<<","<<f3->GetParameter(1)<<");"<<endl;

  // hn->SetMinimum(0);
  // hn1->SetMinimum(0);
  // hn2->SetMinimum(0);
  // hn3->SetMinimum(0);


  auto fout = new TFile("../correctionfiles/BXmistagfunc.root","recreate");
  fout->cd();
  fpp->Write();
  f1->Write();
  f2->Write();
  f3->Write();
  hn->Write();
  hn1->Write();
  hn2->Write();
  hn3->Write();



  auto c = getc();
  f1->SetLineColor(kRed);
  f2->SetLineColor(kGreen);
  f3->SetLineColor(kOrange);
  fpp->SetLineColor(kBlue);

  auto l = getLegend();
  l->AddEntry(fpp,"pp","L");
  l->AddEntry(f1,"bin<20","L");
  l->AddEntry(f2,"20<bin<60","L");
  l->AddEntry(f3,"bin>60","L");

  f1->GetXaxis()->SetTitle("p_{T} [GeV]");
  f1->GetYaxis()->SetTitle("mistag probability");


  f1->Draw();
  f2->Draw("same");
  f3->Draw("same");
  fpp->Draw("same");

  l->Draw();

  SavePlot(c,"func");

  float x = 0.55;
  float y = 0.75;

  auto t= new TLatex();

  auto cpp = getc();
  hn->Draw();
  fpp->Draw("same");
  t->DrawLatexNDC(x,y,"pp");
  SavePlot(cpp,"pp");


  auto c1 = getc();
  hn1->Draw();
  f1->Draw("same");
  t->DrawLatexNDC(x,y,"PbPb 0-10%");
  SavePlot(c1,"bin_0_20");

  auto c2 = getc();
  hn2->Draw();
  f2->Draw("same");
  t->DrawLatexNDC(x,y,"PbPb 10-30%");
  SavePlot(c2,"bin_20_60");

  auto c3 = getc();
  hn3->Draw();
  f3->Draw("same");
  t->DrawLatexNDC(x,y,"PbPb 30-100%");
  SavePlot(c3,"bin_60");


  fout->Close();

}
Example #6
0
void THSRooFit::FitMany(Int_t Nfits){
  //Do the fit many times with different initial paramters
  //Maybe new fit so construct PDF if not laready loaded
    if(!fWS->set("PDFs"))DefineSets();
    // if(!fModel)TotalPDF();
 
  //Store the likelihood value
  TVectorD loglh(Nfits);
  //Fit the model to data with all paramters free
  //first fit use initial paramter values
  if(!fModel) fModel=(RooAbsPdf*)&(fPDFs[0]);//Not ideal, will just take the fist PDF loaded by LoadSpecies unless TotalPDF has already been called.
  Fit();
  //plot result
  PlotDataModel();
  cout<<"Done fit "<<endl;
  cout<<"Result "<<fResult<<endl;
  if(fBinnedFit&&!TMath::IsNaN(fChi2)) loglh[0]=fChi2; //actually did chi2 fit
  else if(!(TMath::IsNaN(fResult->minNll())||fResult->minNll()<-0.999e+30))  loglh[0]=fResult->minNll();
  else loglh[0]=1E300;
  //((TCanvas*)fCanvases->Last())->SetTitle(Form("Fit %d LogL = %lf",0,fChi2));
  fWS->saveSnapshot(Form("ssFit%d",0),RooArgSet(fYields,fParameters),kTRUE);
  TObjArray* fitResults=new TObjArray(Nfits);
  fitResults->SetOwner(kTRUE);
  fitResults->AddLast((RooFitResult*)fResult->clone());
  for(Int_t ifit=1;ifit<Nfits;ifit++){
    Fit(kTRUE);
    //   fWS->saveSnapshot(Form("ssFit%d",ifit),*(fModel->getVariables()),kTRUE);
    fWS->saveSnapshot(Form("ssFit%d",ifit),RooArgSet(fYields,fParameters),kTRUE);
    //fWS->saveSnapshot(Form("YssFit%d",ifit),fYields,kTRUE);
  //plot result
    PlotDataModel();
    // ((TCanvas*)fCanvases->Last())->SetTitle(Form("Fit %d LogL = %lf",ifit,fChi2));
    fitResults->AddLast((RooFitResult*)fResult->clone());
    //Can only get chi2 after PlotDataModel
    if(fBinnedFit&&!TMath::IsNaN(fChi2)) loglh[ifit]=fChi2; //actually did chi2 fit
    else if((TMath::IsNaN(fResult->minNll())||fResult->minNll()!=-1e+30))loglh[ifit]=fResult->minNll();  //loglh[ifit]=fResult->minNll();
    else loglh[ifit]=1E300;
    // cout<<"MANY FITS "<<fResult->covQual()<<endl;
    // if(fResult->status()==0)loglh[ifit]=fResult->minNll();
    //else   loglh[ifit]=1E300;

  }
  cout<<"THSRooFit::RunWeightsMany  Likelihoods "<<endl;
  for(Int_t i=0;i<Nfits;i++){
    cout<<loglh[i]<<endl;
  }	
  //take best result for splot parameters
  Int_t best=TMath::LocMin(Nfits,loglh.GetMatrixArray());
  cout<<"THSRooFit::RunWeightsMany() Best likelihood was "<<loglh[best]<<" "<<best<<" so use those parameters"<<endl;
  fWS->loadSnapshot(Form("ssFit%d",best));
 
  fResult=dynamic_cast<RooFitResult*>(fitResults->RemoveAt(best));//keep for writing to file
  fResult->SetName(Form("Result",best));
  fResult->Print();

  for(Int_t iy=0;iy<fYields.getSize();iy++){
    cout<<((RooRealVar*)&fYields[iy])->GetName()<<" "<<((RooRealVar*)&fYields[iy])->getVal()<<endl;
    ((RooRealVar*)&fYields[iy])->setError(sqrt(((RooRealVar*)&fYields[iy])->getVal()));
  }

}
AddBotDialog::AddBotDialog(wxWindow* parent, IBattle& battle, bool singleplayer)
    : wxDialog(parent, wxID_ANY, _("Add bot"), wxDefaultPosition, wxDefaultSize, wxRESIZE_BORDER | wxDEFAULT_DIALOG_STYLE)
    , WindowAttributesPickle(_T("ADDBOTDIALOG"), this, wxSize(-1, 255))
    , m_battle(battle)
    , m_sp(singleplayer)
{
	//this->SetSizeHints( wxDefaultSize, wxDefaultSize );
	if (battle.GetNumBots() >= 2)
		SetTitle(_("Add bot: high nimber of bots can cause performance problems"));

	m_main_sizer = new wxBoxSizer(wxVERTICAL);

	wxBoxSizer* m_nick_sizer;
	m_nick_sizer = new wxBoxSizer(wxHORIZONTAL);

	m_nick_lbl = new wxStaticText(this, wxID_ANY, _("Nickname:"), wxDefaultPosition, wxDefaultSize, 0);
	m_nick_sizer->Add(m_nick_lbl, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5);

	int bot = 1;
	wxString botname = wxString::Format(_T("Bot%d"), bot);
	while (m_battle.UserExists(STD_STRING(botname))) {
		bot++;
		botname = wxString::Format(_T("Bot%d"), bot);
	}

	m_nick = new wxTextCtrl(this, wxID_ANY, botname, wxDefaultPosition, wxDefaultSize, 0);
	m_nick_sizer->Add(m_nick, 2, wxALL, 5);

	m_main_sizer->Add(m_nick_sizer, 0, wxEXPAND, 5);

	wxBoxSizer* m_ai_sizer;
	m_ai_sizer = new wxBoxSizer(wxHORIZONTAL);

	m_ai_lbl = new wxStaticText(this, wxID_ANY, _("AI:"), wxDefaultPosition, wxDefaultSize, 0);
	m_ai_sizer->Add(m_ai_lbl, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5);

	m_ai = new wxChoice(this, ADDBOT_AI);
	m_ai->SetToolTip(_("Choose the AI library to use with this bot."));

	m_ai_sizer->Add(m_ai, 2, wxALL, 5);

	m_main_sizer->Add(m_ai_sizer, 0, wxEXPAND, 5);

	m_ai_infos_lst = new wxListCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER | wxLC_REPORT | wxLC_SINGLE_SEL | wxLC_NO_HEADER);
	wxListItem col;
	col.SetText(_("property"));
	col.SetImage(-1);
	m_ai_infos_lst->InsertColumn(0, col);
	wxListItem col2;
	col2.SetText(_("value"));
	col2.SetImage(-1);
	m_ai_infos_lst->InsertColumn(1, col2);

	m_opts_list = new wxListCtrl(this, ADDBOT_OPTIONLIST, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER | wxLC_REPORT | wxLC_SINGLE_SEL | wxLC_NO_HEADER);
	wxListItem col3;
	col3.SetText(_("property"));
	col3.SetImage(-1);
	m_opts_list->InsertColumn(0, col3);
	wxListItem col4;
	col4.SetText(_("value"));
	col4.SetImage(-1);
	m_opts_list->InsertColumn(1, col4);

	m_info_sizer = new wxBoxSizer(wxVERTICAL);
	m_info_sizer->Add(m_ai_infos_lst, 1, wxALL | wxEXPAND);
	m_info_sizer->Add(m_opts_list, 1, wxALL | wxEXPAND);
	m_main_sizer->Add(m_info_sizer, 1, wxALL | wxEXPAND);


	m_buttons_sep = new wxStaticLine(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL);
	m_main_sizer->Add(m_buttons_sep, 0, wxALL | wxEXPAND);

	wxBoxSizer* m_buttons_sizer;
	m_buttons_sizer = new wxBoxSizer(wxHORIZONTAL);

	m_cancel_btn = new wxButton(this, ADDBOT_CANCEL, _("Cancel"), wxDefaultPosition, wxSize(-1, CONTROL_HEIGHT), 0);
	m_buttons_sizer->Add(m_cancel_btn, 0, wxALL);

	m_buttons_sizer->Add(0, 0, 1, wxEXPAND);

	m_add_btn = new wxButton(this, ADDBOT_ADD, _("Add Bot"), wxDefaultPosition, wxSize(-1, CONTROL_HEIGHT), 0);
	m_buttons_sizer->Add(m_add_btn, 0, wxALL);

	m_main_sizer->Add(m_buttons_sizer, 0, wxEXPAND);

	ReloadAIList();

	SetSizer(m_main_sizer);
	Fit();
	m_add_btn->SetFocus();
}
EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitle,
                                  const wxArrayString& aItemHeaders,
                                  const std::vector<wxArrayString>& aItemList,
                                  const wxString& aSelection,
                                  void( *aCallBackFunction )( wxString&, void* ),
                                  void* aCallBackFunctionData,
                                  bool aSortList ) :
    EDA_LIST_DIALOG_BASE( aParent, wxID_ANY, aTitle )
{
    m_sortList    = aSortList;
    m_cb_func     = aCallBackFunction;
    m_cb_data     = aCallBackFunctionData;
    m_itemsListCp = &aItemList;

    for( unsigned i = 0; i < aItemHeaders.Count(); i++ )
    {
        wxListItem column;

        column.SetId( i );
        column.SetText( aItemHeaders.Item( i ) );

        m_listBox->InsertColumn( i, column );
    }

    InsertItems( aItemList, 0 );

    if( m_cb_func == NULL )
    {
        m_messages->Show( false );
        m_staticTextMsg->Show( false );
    }

    for( unsigned col = 0; col < aItemHeaders.Count();  ++col )
    {
        m_listBox->SetColumnWidth( col, wxLIST_AUTOSIZE );

#if !wxCHECK_VERSION( 2, 9, 0 )
        // include the column header in the width decision, wx 2.8 forgets this:
        wxListItem  col_info;

        m_listBox->GetColumn( col, col_info );

        wxString    header  = col_info.GetText();
        int         headerz = GetTextSize( header, m_listBox ).x;

        // A reasonable column header has about 14 pixels of whitespace
        // in addition to the width of the text itself.
        headerz += 14;

        if( headerz > col_info.GetWidth() )
        {
            col_info.SetWidth( headerz );

            m_listBox->SetColumn( col, col_info );
        }
#endif
    }


#if !wxCHECK_VERSION( 2, 9, 0 )
    // wx 2.8.x has bug in wxListCtrl WRT honoring the omission of wxHSCROLL, at least
    // on gtk2.  Fix by setting minimum width so horizontal wxListCtrl scrolling is
    // not needed on 2.8.x because of minumum visible width setting:
    {
        int width = 0;

        for( unsigned col = 0;  col < aItemHeaders.Count();  ++col )
        {
            width += m_listBox->GetColumnWidth( col ) + 2;
        }

        wxSize sz = m_listBox->GetSize();

        sz.SetWidth( width );

        m_listBox->SetMinSize( sz );
    }
#endif

    Fit();
    Centre();

    if( !!aSelection )
    {
        for( unsigned row = 0; row < aItemList.size(); ++row )
        {
            if( aItemList[row][0] == aSelection )
            {
                m_listBox->SetItemState( row, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
                m_listBox->EnsureVisible( row );
                break;
            }
        }
    }

    // DIALOG_SHIM needs a unique hash_key because classname is not sufficient
    // because so many dialogs share this same class, with different numbers of
    // columns, different column names, and column widths.
    m_hash_key = TO_UTF8( aTitle );

    m_filterBox->SetFocus();
}
Example #9
0
AndroidExportDialog::AndroidExportDialog(wxWindow* parent)
    : AndroidExportDialogBase(parent) {
  Fit();
}
Example #10
0
void RadarPanel::ShowFrame(bool visible) {
  LOG_DIALOG(wxT("BR24radar_pi %s: set visible %d"), m_ri->m_name.c_str(), visible);

  wxAuiPaneInfo& pane = m_aui_mgr->GetPane(this);

  if (!m_pi->IsOpenGLEnabled() && m_ri->m_radar_canvas) {
    m_sizer->Detach(m_ri->m_radar_canvas);
    delete m_ri->m_radar_canvas;
    m_ri->m_radar_canvas = 0;
    m_text->SetLabel(_("OpenGL mode required"));
    m_sizer->Show(m_text);
    DimeWindow(this);
    Fit();
    Layout();
  }
  if (visible) {
    if (m_pi->IsOpenGLEnabled() && !m_ri->m_radar_canvas) {
      LOG_DIALOG(wxT("BR24radar_pi %s: creating OpenGL canvas"), m_ri->m_name.c_str());
      m_ri->m_radar_canvas = new RadarCanvas(m_pi, m_ri, this, GetSize());
      if (!m_ri->m_radar_canvas) {
        m_text->SetLabel(_("Unable to create OpenGL canvas"));
        m_sizer->Show(m_text);
      } else {
        m_sizer->Hide(m_text);
        m_sizer->Add(m_ri->m_radar_canvas, 0, wxEXPAND | wxALL, 0);

        Fit();
        Layout();
      }
    }
  }

  if (visible) {
    m_pi->m_settings.show_radar[m_ri->m_radar] = 1;
    LOG_DIALOG(wxT("BR24radar_pi: RadarPanel::ShowFrame: show_radar[%d]=%d"), m_ri->m_radar, 1);
  }

  // What should have been a simple 'pane.Show(visible)' has devolved into a terrible hack.
  // When the entire dock row disappears because we're removing the last pane from it then the
  // next time we restore the dock gets its original size again. This is not want customers want.
  // So we store the size of the dock just before hiding the pane. This is done via parsing of the
  // perspective string, as there is no other way to access the dock information through wxAUI.

  if (!visible) {
    m_dock_size = 0;
    if (pane.IsDocked()) {
      m_dock = wxString::Format(wxT("|dock_size(%d,%d,%d)="), pane.dock_direction, pane.dock_layer, pane.dock_row);
      wxString perspective = m_aui_mgr->SavePerspective();

      int p = perspective.Find(m_dock);
      if (p != wxNOT_FOUND) {
        perspective = perspective.Mid(p + m_dock.length());
        perspective = perspective.BeforeFirst(wxT('|'));
        m_dock_size = wxAtoi(perspective);
        LOG_DIALOG(wxT("BR24radar_pi: %s: replaced=%s, saved dock_size = %d"), m_ri->m_name.c_str(), perspective.c_str(),
                   m_dock_size);
      }
    }
  } else {
    pane.Position(m_ri->m_radar);
  }

  pane.Show(visible);
  m_aui_mgr->Update();  // causes recursive calls on OS X when not in OpenGL mode

  if (visible && (m_dock_size > 0)) {
    // Now the reverse: take the new perspective string and replace the dock size of the dock that our pane is in and
    // reset it to the width it was before the hide.
    wxString perspective = m_aui_mgr->SavePerspective();

    int p = perspective.Find(m_dock);
    if (p != wxNOT_FOUND) {
      wxString newPerspective = perspective.Left(p);
      newPerspective << m_dock;
      newPerspective << m_dock_size;
      perspective = perspective.Mid(p + m_dock.length());
      newPerspective << wxT("|");
      newPerspective << perspective.AfterFirst(wxT('|'));

      m_aui_mgr->LoadPerspective(newPerspective);
      LOG_DIALOG(wxT("BR24radar_pi: %s: new perspective %s"), m_ri->m_name.c_str(), newPerspective.c_str());
    }
  }
}
Example #11
0
//______________________________________________________________________________
void CBTime()
{
    // Main method.
    
    Char_t tmp[256];
    
    // load CaLib
    gSystem->Load("libCaLib.so");
    
    // general configuration
    const Char_t* data = "Data.CB.T0";
    const Char_t* hName = "CaLib_CB_Time_Neut";

    // configuration (December 2007)
    //const Char_t calibration[] = "LD2_Dec_07";
    //const Char_t filePat[] = "/usr/puma_scratch0/werthm/A2/Dec_07/AR/out/ARHistograms_CB_RUN.root";
    //const Char_t filePat[] = "/Users/fulgur/Desktop/calib/Dec_07/ARHistograms_CB_RUN.root";

    // configuration (February 2009)
    //const Char_t calibration[] = "LD2_Feb_09";
    //const Char_t filePat[] = "/usr/puma_scratch0/werthm/A2/Feb_09/AR/out/ARHistograms_CB_RUN.root";
    //const Char_t filePat[] = "/Users/fulgur/Desktop/calib/Feb_09/ARHistograms_CB_RUN.root";
    
    // configuration (May 2009)
    const Char_t calibration[] = "LD2_May_09";
    //const Char_t filePat[] = "/usr/puma_scratch0/werthm/A2/May_09/AR/out/ARHistograms_CB_RUN.root";
    const Char_t filePat[] = "/Users/fulgur/Desktop/calib/May_09/ARHistograms_CB_RUN.root";
    
    // get number of sets
    Int_t nSets = TCMySQLManager::GetManager()->GetNsets(data, calibration);

    if(nSets <= 0) {
        printf("No run sets found for calibration \"%s\"\n", calibration );
        return;
    }

    // create canvas
    Int_t n = TMath::Sqrt(nSets);
    TCanvas* cOverview = new TCanvas();
    cOverview->Divide(n, nSets / n + 1);
    
    // create arrays
    Double_t* pos = new Double_t[nSets+1];
    Double_t* fwhm = new Double_t[nSets+1];
    
    // total sum histogram
    TH1* hTot = 0;

    // loop over sets
    for (Int_t i = 0; i < nSets; i++)
    { 
        // create file manager
        TCFileManager m(data, calibration, 1, &i, filePat);
        
        // get histo
        TH2* h2 = (TH2*) m.GetHistogram(hName);
        
        // skip empty histo
        if (!h2) continue;

        // project histo
        sprintf(tmp, "Proj_%d", i);
        TH1* h = (TH1*) h2->ProjectionX(tmp);
        
        // add to total histogram
        if (!hTot) hTot = (TH1*) h->Clone();
        else hTot->Add(h);
 
        // fit histo
        cOverview->cd(i+1);
        Fit(h, &pos[i], &fwhm[i]);
    }
    
    // show total histogram
    TCanvas* cTot = new TCanvas();
    Fit(hTot, &pos[nSets], &fwhm[nSets]);

    // show results
    for (Int_t i = 0; i < nSets; i++)
        printf("Set %02d:   Pos: %5.2f ns   FWHM: %.2f ns\n", i, pos[i], fwhm[i]);
    printf("Total :   Pos: %5.2f ns   FWHM: %.2f ns\n", pos[nSets], fwhm[nSets]);
}
Example #12
0
int main(int Narg, char* pszArg[])
{

   double wtime = omp_get_wtime();

  if (Narg > 3) return 0;
  string title(pszArg[1]);
  string fileName = title+".inp";

  //read in input file to cound how many fitted parameters
  ifstream file(fileName.c_str());
  if (file.fail())
    {
      cout << "could not open file " << fileName << endl;
      abort();
    }
  char line[80];
  //skip two lines
  file.getline(line,80);
  file.getline(line,80);
  string variable;
  double parameter,varied,squared,scaling;
  int Ndim = 0;
  for (int i=0;i<fit::TotPara;i++)
    {
      file >> parameter >> varied >> squared>>scaling >> variable;
      if (varied) Ndim++;
    }  
  

  file.close();
  file.clear();




  cout<<"before fit"<<endl;
  fit Fit(&title,Ndim);
  cout<<"after fit"<<endl;

  Fit.React[0]->prepare();

  for (int i=0;i<Fit.Nreact;i++)
  {
     Fit.React[i]->OpenRootFile();
     cout << "PlotFit" << endl;
     Fit.React[i]->PlotFit();
     cout << "plotPot" << endl;
     Fit.React[i]->PlotPotentialEcm();

     //cout<<"plotDiff"<<endl;
     //double Elab = 26;
     //Fit.React[i]->Print_DiffXsection( Elab );
     cout<<"done with root"<<endl;



     /*
     //write  out transmission coefficients
     fileName = Fit.Rtitle[i]+".CN";
     file.open(fileName.c_str());
     file >> fileName;
     file >> fileName;
     Fit.React[i]->PrintTransCoef(fileName);
     file.close();
     file.clear();
     */

     Fit.React[i]->CloseRootFile();

  }


  /*
     for (int i=0;i<Fit.Nratio;i++)
     {
     Fit.Ratio[i]->OpenRootFile();
     cout << "PlotFit" << endl;
     Fit.Ratio[i]->PlotFit();
     Fit.Ratio[i]->CloseRootFile();

     }
     */ 
  cout<<"total time for entire chisq(hours) = "<<(omp_get_wtime()-wtime)/3600<<endl;
  
  return 0;
}
Example #13
0
void ExtImportPrefs::PopulateOrExchange(ShuttleGui & S)
{
   S.SetBorder(2);

   S.TieCheckBox(_("A&ttempt to use filter in OpenFile dialog first"),
         wxT("/ExtendedImport/OverrideExtendedImportByOpenFileDialogChoice"),
         true);
   S.StartStatic(_("Rules to choose import filters"), 1);
   {
      S.SetSizerProportion(1);
      S.StartHorizontalLay (wxEXPAND, 1);
      {
         bool fillRuleTable = false;
         if (RuleTable == NULL)
         {
            RuleTable = safenew Grid(S.GetParent(),EIPRuleTable);

            RuleTable->SetColLabelSize(RuleTable->GetDefaultRowSize());
#if EXTIMPORT_MIME_SUPPORT
            RuleTable->CreateGrid (0, 2, wxGrid::wxGridSelectRows);
#else
            RuleTable->CreateGrid (0, 1, wxGrid::wxGridSelectRows);
#endif
            RuleTable->DisableDragColMove ();
            RuleTable->DisableDragRowSize ();
            RuleTable->SetDefaultCellAlignment(wxALIGN_LEFT, wxALIGN_CENTER);
            RuleTable->SetColLabelValue (0, _("File extensions"));
#if EXTIMPORT_MIME_SUPPORT
            RuleTable->SetColLabelValue (1, _("Mime-types"));
#endif
            RuleTable->SetRowLabelSize (0);
            RuleTable->SetSelectionMode (wxGrid::wxGridSelectRows);
            RuleTable->AutoSizeColumns ();

            RuleTable->SetDropTarget (dragtarget1);
            RuleTable->EnableDragCell (true);
            fillRuleTable = true;
         }
         S.AddWindow(RuleTable, wxEXPAND | wxALL);

         PluginList = S.Id(EIPPluginList).AddListControl ();

         if (fillRuleTable)
         {
            PluginList->SetSingleStyle (wxLC_REPORT, true);
            PluginList->SetSingleStyle (wxLC_SINGLE_SEL, true);
            PluginList->InsertColumn (0, _("Importer order"));
            PluginList->SetDropTarget (dragtarget2);

            ExtImportItems *items = Importer::Get().GetImportItems();
            for (unsigned int i = 0; i < items->Count(); i++)
               AddItemToTable (i, &(*items)[i]);
            if (items->Count() > 0)
            {
               RuleTable->SelectRow(0);
               RuleTable->SetGridCursor(0,0);
            }
         }
      }
      S.EndHorizontalLay();
      S.StartHorizontalLay (wxSHRINK, 0);
      {
          MoveRuleUp = S.Id (EIPMoveRuleUp).AddButton (_("Move rule &up"));
          MoveRuleDown = S.Id (EIPMoveRuleDown).AddButton
                (_("Move rule &down"));
          MoveFilterUp = S.Id (EIPMoveFilterUp).AddButton
                (_("Move f&ilter up"));
          MoveFilterDown = S.Id (EIPMoveFilterDown).AddButton
                (_("Move &filter down"));
      }
      S.EndHorizontalLay();
      S.StartHorizontalLay (wxSHRINK, 0);
      {
          AddRule = S.Id (EIPAddRule).AddButton (_("&Add new rule"));
          DelRule = S.Id (EIPDelRule).AddButton (_("De&lete selected rule"));
      }
      S.EndHorizontalLay();
   }
   S.EndStatic();
   Layout();
   Fit();
   SetMinSize(GetSize());
}
Example #14
0
TimeTextCtrl::TimeTextCtrl(wxWindow *parent,
                           wxWindowID id,
                           wxString formatString,
                           double timeValue,
                           double sampleRate,
                           const wxPoint &pos,
                           const wxSize &size,
                           bool autoPos):
   wxControl(parent, id, pos, size, wxSUNKEN_BORDER | wxWANTS_CHARS),
   mTimeValue(timeValue),
   mSampleRate(sampleRate),
   mFormatString(formatString),
   mBackgroundBitmap(NULL),
   mDigitFont(NULL),
   mLabelFont(NULL),
   mFocusedDigit(0),
   mLastField(1),
   mAutoPos(autoPos)
{
   /* i18n-hint: Name of time display format that shows time in seconds */
   BuiltinFormatStrings[0].name = _("seconds");
   /* i18n-hint: Format string for displaying time in seconds. Change the comma
    * in the middle to the 1000s separator for your locale, and the 'seconds'
    * on the end to the word for seconds. Don't change the numbers. */
   BuiltinFormatStrings[0].formatStr = _("01000,01000 seconds");
   /* i18n-hint: Name of time display format that shows time in hours, minutes
    * and seconds */
   BuiltinFormatStrings[1].name = _("hh:mm:ss");
   /* i18n-hint: Format string for displaying time in hours, minutes and
    * seconds. Change the 'h' to the abbreviation for hours, 'm' to the
    * abbreviation for minutes and 's' to the abbreviation for seconds. Don't
    * change the numbers unless there aren't 60 seconds in a minute in your
    * locale */
   BuiltinFormatStrings[1].formatStr = _("0100 h 060 m 060 s");
   /* i18n-hint: Name of time display format that shows time in days, hours,
    * minutes and seconds */
   BuiltinFormatStrings[2].name = _("dd:hh:mm:ss");
   /* i18n-hint: Format string for displaying time in days, hours, minutes and
    * seconds. Change the 'days' to the word for days, 'h' to the abbreviation
    * for hours, 'm' to the abbreviation for minutes and 's' to the
    * abbreviation for seconds. Don't change the numbers unless there aren't
    * 24 hours in a day in your locale */
   BuiltinFormatStrings[2].formatStr = _("0100 days 024 h 060 m 060 s");
   /* i18n-hint: Name of time display format that shows time in hours,
    * minutes, seconds and hundredths of a second (1/100 second) */
   BuiltinFormatStrings[3].name = _("hh:mm:ss + hundredths");
   /* i18n-hint: Format string for displaying time in hours, minutes, seconds
    * and hundredths of a second. Change the 'h' to the abbreviation for hours,
    * 'm' to the abbreviation for minutes and 's' to the abbreviation for seconds (the
    * hundredths are shown as decimal seconds) . Don't change the numbers
    * unless there aren't 60 minutes in an hour in your locale */
   BuiltinFormatStrings[3].formatStr =_("0100 h 060 m 060.0100 s");
   /* i18n-hint: Name of time display format that shows time in hours,
    * minutes, seconds and milliseconds (1/1000 second) */
   BuiltinFormatStrings[4].name = _("hh:mm:ss + milliseconds");
   /* i18n-hint: Format string for displaying time in hours, minutes, seconds
    * and milliseconds. Change the 'h' to the abbreviation for hours, 'm' to the
    * abbreviation for minutes and 's' to the abbreviation for seconds (the
    * milliseconds are shown as decimal seconds) . Don't change the numbers
    * unless there aren't 60 minutes in an hour in your locale */
   BuiltinFormatStrings[4].formatStr =_("0100 h 060 m 060.01000 s");
   /* i18n-hint: Name of time display format that shows time in hours,
    * minutes, seconds and samples (at the current project sample rate) */
   BuiltinFormatStrings[5].name = _("hh:mm:ss + samples");
   /* i18n-hint: Format string for displaying time in hours, minutes, seconds
    * and samples. Change the 'h' to the abbreviation for hours, 'm' to the
    * abbreviation for minutes, 's' to the abbreviation for seconds and
    * translate samples . Don't change the numbers
    * unless there aren't 60 seconds in a minute in your locale */
   BuiltinFormatStrings[5].formatStr = _("0100 h 060 m 060 s+.# samples");
   /* i18n-hint: Name of time display format that shows time in samples (at the
    * current project sample rate) */
   BuiltinFormatStrings[6].name = _("samples");
   /* i18n-hint: Format string for displaying time in samples (lots of samples).
    * Change the ',' to the 1000s separator for your locale, and translate
    * samples. If 1000s aren't a base multiple for your number system, then you
    * can change the numbers to an appropriate one, and put a 0 on the front */
   BuiltinFormatStrings[6].formatStr = _("01000,01000,01000 samples|#");
   /* i18n-hint: Name of time display format that shows time in hours, minutes,
    * seconds and frames at 24 frames per second (commonly used for films) */
   BuiltinFormatStrings[7].name = _("hh:mm:ss + film frames (24 fps)");
   /* i18n-hint: Format string for displaying time in hours, minutes, seconds
    * and frames at 24 frames per second. Change the 'h' to the abbreviation
    * for hours, 'm' to the abbreviation for minutes, 's' to the abbreviation
    * for seconds and translate 'frames' . Don't change the numbers
    * unless there aren't 60 seconds in a minute in your locale */
   BuiltinFormatStrings[7].formatStr = _("0100 h 060 m 060 s+.24 frames");
   /* i18n-hint: Name of time display format that shows time in frames (lots of
    * frames) at 24 frames per second (commonly used for films) */
   BuiltinFormatStrings[8].name = _("film frames (24 fps)");
   /* i18n-hint: Format string for displaying time in frames at 24 frames per
    * second. Translate 'frames' and leave the rest alone */
   BuiltinFormatStrings[8].formatStr = _("01000,01000 frames|24");
   /* i18n-hint: Name of time display format that shows time in hours, minutes,
    * seconds and frames at NTSC TV drop-frame rate (used for American /
    * Japanese TV, and very odd) */
   BuiltinFormatStrings[9].name = _("hh:mm:ss + NTSC drop frames");
   /* i18n-hint: Format string for displaying time in hours, minutes, seconds
    * and frames with NTSC drop frames. Change the 'h' to the abbreviation
    * for hours, 'm' to the abbreviation for minutes, 's' to the abbreviation
    * for seconds and translate 'frames'. Leave the |N alone, it's important! */
   BuiltinFormatStrings[9].formatStr = _("0100 h 060 m 060 s+.30 frames|N");
   /* i18n-hint: Name of time display format that shows time in hours, minutes,
    * seconds and frames at NTSC TV non-drop-frame rate (used for American /
    * Japanese TV, and doesn't quite match wall time */
   BuiltinFormatStrings[10].name = _("hh:mm:ss + NTSC non-drop frames");
   /* i18n-hint: Format string for displaying time in hours, minutes, seconds
    * and frames with NTSC drop frames. Change the 'h' to the abbreviation
    * for hours, 'm' to the abbreviation for minutes, 's' to the abbreviation
    * for seconds and translate 'frames'. Leave the | .999000999 alone, 
    * the whole things really is slightly off-speed! */
   BuiltinFormatStrings[10].formatStr = _("0100 h 060 m 060 s+.030 frames| .999000999");
   /* i18n-hint: Name of time display format that shows time in frames at NTSC
    * TV frame rate (used for American / Japanese TV */
   BuiltinFormatStrings[11].name = _("NTSC frames");
   /* i18n-hint: Format string for displaying time in frames with NTSC frames.
    * Translate 'frames' and leave the rest alone. That really is the frame
    * rate! */
   BuiltinFormatStrings[11].formatStr = _("01000,01000 frames|29.97002997");
   /* i18n-hint: Name of time display format that shows time in hours, minutes,
    * seconds and frames at PAL TV frame rate (used for European TV) */
   BuiltinFormatStrings[12].name = _("hh:mm:ss + PAL frames (25 fps)");
   /* i18n-hint: Format string for displaying time in hours, minutes, seconds
    * and frames with PAL TV frames. Change the 'h' to the abbreviation
    * for hours, 'm' to the abbreviation for minutes, 's' to the abbreviation
    * for seconds and translate 'frames'. Nice simple time code! */
   BuiltinFormatStrings[12].formatStr = _("0100 h 060 m 060 s+.25 frames");
   /* i18n-hint: Name of time display format that shows time in frames at PAL
    * TV frame rate (used for European TV */
   BuiltinFormatStrings[13].name = _("PAL frames (25 fps)");
   /* i18n-hint: Format string for displaying time in frames with NTSC frames.
    * Translate 'frames' and leave the rest alone. */
   BuiltinFormatStrings[13].formatStr = _("01000,01000 frames|25");
   /* i18n-hint: Name of time display format that shows time in hours, minutes,
    * seconds and frames at CD Audio frame rate (75 frames per second) */
   BuiltinFormatStrings[14].name = _("hh:mm:ss + CDDA frames (75 fps)");
   /* i18n-hint: Format string for displaying time in hours, minutes, seconds
    * and frames with CD Audio frames. Change the 'h' to the abbreviation
    * for hours, 'm' to the abbreviation for minutes, 's' to the abbreviation
    * for seconds and translate 'frames'. */
   BuiltinFormatStrings[14].formatStr = _("0100 h 060 m 060 s+.75 frames");
   /* i18n-hint: Name of time display format that shows time in frames at CD
    * Audio frame rate (75 frames per second) */
   BuiltinFormatStrings[15].name = _("CDDA frames (75 fps)");
   /* i18n-hint: Format string for displaying time in frames with CD Audio
    * frames. Translate 'frames' and leave the rest alone */
   BuiltinFormatStrings[15].formatStr = _("01000,01000 frames|75");

   mDigitBoxW = 10;
   mDigitBoxH = 16;

   mMenuEnabled = true;
   mButtonWidth = 9;

   ParseFormatString();
   Layout();
   Fit();
   ValueToControls();
   //mchinen - aug 15 09 - this seems to put the mTimeValue back to zero, and do nothing else.
   //ControlsToValue(); 

#if wxUSE_ACCESSIBILITY
   SetLabel(wxT(""));
   SetName(wxT(""));
   SetAccessible(new TimeTextCtrlAx(this));
#endif
}
Example #15
0
void CImportDialog::Show()
{
	wxFileDialog dlg(m_parent, _("Select file to import settings from"), _T(""), 
					_T("FileZilla.xml"), _T("XML files (*.xml)|*.xml"), 
					wxFD_OPEN | wxFD_FILE_MUST_EXIST);
	dlg.CenterOnParent();

	if (dlg.ShowModal() != wxID_OK)
		return;

	wxFileName fn(dlg.GetPath());
	const wxString& path = fn.GetPath();
	const wxString& settings = wxGetApp().GetSettingsDir();
	if (path == settings)
	{
		wxMessageBox(_("You cannot import settings from FileZilla's own settings directory."), _("Error importing"), wxICON_ERROR, m_parent);
		return;
	}

	TiXmlDocument* xmlDocument = new TiXmlDocument();
	xmlDocument->SetCondenseWhiteSpace(false);

	if (!LoadXmlDocument(xmlDocument, dlg.GetPath()))
	{
		delete xmlDocument;
		wxMessageBox(_("Cannot load file, not a valid XML file."), _("Error importing"), wxICON_ERROR, m_parent);
		return;
	}

	TiXmlElement* fz3Root = xmlDocument->FirstChildElement("FileZilla3");
	TiXmlElement* fz2Root = xmlDocument->FirstChildElement("FileZilla");

	if (fz3Root)
	{
		bool settings = fz3Root->FirstChildElement("Settings") != 0;
		bool queue = fz3Root->FirstChildElement("Queue") != 0;
		bool sites = fz3Root->FirstChildElement("Servers") != 0;

		if (settings || queue || sites)
		{
			Load(m_parent, _T("ID_IMPORT"));
			if (!queue)
				XRCCTRL(*this, "ID_QUEUE", wxCheckBox)->Hide();
			if (!sites)
				XRCCTRL(*this, "ID_SITEMANAGER", wxCheckBox)->Hide();
			if (!settings)
				XRCCTRL(*this, "ID_SETTINGS", wxCheckBox)->Hide();
			Fit();

			if (ShowModal() != wxID_OK)
			{
				delete xmlDocument;
				return;
			}

			if (queue && XRCCTRL(*this, "ID_QUEUE", wxCheckBox)->IsChecked())
			{
				m_pQueueView->ImportQueue(fz3Root->FirstChildElement("Queue"), true);
			}

			if (sites && XRCCTRL(*this, "ID_SITEMANAGER", wxCheckBox)->IsChecked())
			{
				ImportSites(fz3Root->FirstChildElement("Servers"));
			}

			if (settings && XRCCTRL(*this, "ID_SETTINGS", wxCheckBox)->IsChecked())
			{
				COptions::Get()->Import(fz3Root->FirstChildElement("Settings"));
				wxMessageBox(_("The settings have been imported. You have to restart FileZilla for all settings to have effect."), _("Import successful"), wxOK, this);
			}
			
			wxMessageBox(_("The selected categories have been imported."), _("Import successful"), wxOK, this);

			delete xmlDocument;
			return;
		}
	}
	else if (fz2Root)
	{
		bool sites_fz2 = fz2Root->FirstChildElement("Sites") != 0;
		if (sites_fz2)
		{
			int res = wxMessageBox(_("The file you have selected contains site manager data from a previous version of FileZilla.\nDue to differences in the storage format, only host, port, username and password will be imported.\nContinue with the import?"),
				_("Import data from older version"), wxICON_QUESTION | wxYES_NO);
			
			if (res == wxYES)
				ImportLegacySites(fz2Root->FirstChildElement("Sites"));

			delete xmlDocument;
			return;
		}
	}

	delete xmlDocument;

	wxMessageBox(_("File does not contain any importable data."), _("Error importing"), wxICON_ERROR, m_parent);
}
Example #16
0
int main(int argc, char *argv[])
{
  if (argc < 2)
  {
    fprintf(stderr, "Usage:   %s [filename1] [filename2] ...\n\n", "");
    return 1;
  }

  // Create a DataStorage
  m_DataStorage = mitk::StandaloneDataStorage::New();

  //*************************************************************************
  // Part II: Create some data by reading files
  //*************************************************************************
  int i;
  for (i = 1; i < argc; ++i)
  {
    // For testing
    if (strcmp(argv[i], "-testing") == 0)
      continue;

    std::string filename = argv[i];
    try
    {
      // Read the file and add it as a data node to the data storage
      mitk::DataStorage::SetOfObjects::Pointer nodes = mitk::IOUtil::Load(filename, *m_DataStorage);

      for (mitk::DataStorage::SetOfObjects::Iterator nodeIter = nodes->Begin(), nodeIterEnd = nodes->End();
           nodeIter != nodeIterEnd;
           ++nodeIter)
      {
        mitk::DataNode::Pointer node = nodeIter->Value();
        mitk::Image::Pointer image = dynamic_cast<mitk::Image *>(node->GetData());
        if (image.IsNotNull())
        {
          // Set the property "volumerendering" to the Boolean value "true"
          node->SetProperty("volumerendering", mitk::BoolProperty::New(false));
          node->SetProperty("name", mitk::StringProperty::New("testimage"));
          node->SetProperty("layer", mitk::IntProperty::New(1));
        }
      }
    }
    catch (...)
    {
      std::cerr << "Could not open file " << filename << std::endl;
      exit(2);
    }
  }

  //*************************************************************************
  // Part V: Create window and pass the tree to it
  //*************************************************************************

  // Create renderwindows
  mitkWidget1 = mitk::RenderWindow::New();
  mitkWidget2 = mitk::RenderWindow::New();
  mitkWidget3 = mitk::RenderWindow::New();
  mitkWidget4 = mitk::RenderWindow::New();

  mitkWidget1->GetRenderer()->PrepareRender();
  mitkWidget2->GetRenderer()->PrepareRender();
  mitkWidget3->GetRenderer()->PrepareRender();

  // Tell the renderwindow which (part of) the datastorage to render
  mitkWidget1->GetRenderer()->SetDataStorage(m_DataStorage);
  mitkWidget2->GetRenderer()->SetDataStorage(m_DataStorage);
  mitkWidget3->GetRenderer()->SetDataStorage(m_DataStorage);
  mitkWidget4->GetRenderer()->SetDataStorage(m_DataStorage);

  // instantiate display interactor
  if (m_DisplayInteractor.IsNull())
  {
    m_DisplayInteractor = mitk::DisplayInteractor::New();
    m_DisplayInteractor->LoadStateMachine("DisplayInteraction.xml");
    m_DisplayInteractor->SetEventConfig("DisplayConfigMITK.xml");
    // Register as listener via micro services

    us::ModuleContext *context = us::GetModuleContext();
    context->RegisterService<mitk::InteractionEventObserver>(m_DisplayInteractor.GetPointer());
  }
  // Use it as a 2D View
  mitkWidget1->GetRenderer()->SetMapperID(mitk::BaseRenderer::Standard2D);
  mitkWidget2->GetRenderer()->SetMapperID(mitk::BaseRenderer::Standard2D);
  mitkWidget3->GetRenderer()->SetMapperID(mitk::BaseRenderer::Standard2D);
  mitkWidget4->GetRenderer()->SetMapperID(mitk::BaseRenderer::Standard3D);

  mitkWidget1->SetSize(400, 400);

  mitkWidget2->GetVtkRenderWindow()->SetPosition(mitkWidget1->GetVtkRenderWindow()->GetPosition()[0] + 420,
                                                 mitkWidget1->GetVtkRenderWindow()->GetPosition()[1]);
  mitkWidget2->SetSize(400, 400);

  mitkWidget3->GetVtkRenderWindow()->SetPosition(mitkWidget1->GetVtkRenderWindow()->GetPosition()[0],
                                                 mitkWidget1->GetVtkRenderWindow()->GetPosition()[1] + 450);
  mitkWidget3->SetSize(400, 400);

  mitkWidget4->GetVtkRenderWindow()->SetPosition(mitkWidget1->GetVtkRenderWindow()->GetPosition()[0] + 420,
                                                 mitkWidget1->GetVtkRenderWindow()->GetPosition()[1] + 450);
  mitkWidget4->SetSize(400, 400);

  InitializeWindows();

  AddDisplayPlaneSubTree();

  Fit();

  // Initialize the RenderWindows
  mitk::TimeGeometry::Pointer geo = m_DataStorage->ComputeBoundingGeometry3D(m_DataStorage->GetAll());
  mitk::RenderingManager::GetInstance()->InitializeViews(geo);

  m_DataStorage->Print(std::cout);
  mitk::RenderingManager::GetInstance()->RequestUpdateAll();

  // reinit the mitkVTKEventProvider;
  // this is only necessary once after calling
  // ForceImmediateUpdateAll() for the first time
  mitkWidget1->ReinitEventProvider();
  mitkWidget2->ReinitEventProvider();
  mitkWidget3->ReinitEventProvider();

  mitkWidget1->GetVtkRenderWindow()->Render();
  mitkWidget2->GetVtkRenderWindow()->Render();
  mitkWidget3->GetVtkRenderWindow()->Render();
  mitkWidget4->GetVtkRenderWindow()->Render();
  mitkWidget4->GetVtkRenderWindowInteractor()->Start();

  return 0;
}
Example #17
0
HistoryWindow::HistoryWindow(AudacityProject *parent, UndoManager *manager):
   wxDialog((wxWindow*)parent, wxID_ANY, wxString(_("Undo History")),
      wxDefaultPosition, wxDefaultSize,
      wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
{
   mManager = manager;
   mProject = parent;
   mSelected = 0;

   wxImageList *imageList = new wxImageList(9, 16);
   imageList->Add(wxIcon(empty_9x16_xpm));
   imageList->Add(wxIcon(arrow_xpm));

   //------------------------- Main section --------------------
   // Construct the GUI.
   ShuttleGui S(this, eIsCreating);

   S.SetBorder(5);
   S.StartVerticalLay(true);
   {
      S.StartStatic(_("Manage History"), 1);
      {
         mList = S.AddListControlReportMode();
         // Do this BEFORE inserting the columns.  On the Mac at least, the
         // columns are deleted and later InsertItem()s will cause Audacity to crash.
         mList->SetSingleStyle(wxLC_SINGLE_SEL);
         mList->InsertColumn(0, _("Action"), wxLIST_FORMAT_LEFT, 300);
         mList->InsertColumn(1, _("Size"), wxLIST_FORMAT_LEFT, 65);

         //Assign rather than set the image list, so that it is deleted later.
         mList->AssignImageList(imageList, wxIMAGE_LIST_SMALL);

         S.StartMultiColumn(3, wxCENTRE);
         {
            mAvail = S.Id(ID_AVAIL).AddTextBox(_("&Undo Levels Available"), wxT("0"), 10);
            mAvail->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(HistoryWindow::OnChar));
            S.AddVariableText(wxT(""))->Hide();
         }

         {
            S.AddPrompt(_("Levels To Discard"));
            mLevels = new wxSpinCtrl(this,
                                     ID_LEVELS,
                                     wxT("1"),
                                     wxDefaultPosition,
                                     wxDefaultSize,
                                     wxSP_ARROW_KEYS,
                                     1,
                                     mManager->GetCurrentState() - 1,
                                     1);
            S.AddWindow(mLevels);
            mDiscard = S.Id(ID_DISCARD).AddButton(_("&Discard"));
         }
         S.EndMultiColumn();
      }
      S.EndStatic();

      S.StartHorizontalLay(wxALIGN_BOTTOM | wxALIGN_RIGHT, false);
      {
         S.SetBorder(10);
         S.Id(wxID_OK).AddButton(_("&OK"))->SetDefault();
      }
      S.EndHorizontalLay();
   }
   S.EndVerticalLay();
   // ----------------------- End of main section --------------

   DoUpdate();
   mList->SetMinSize(mList->GetSize());
   Fit();
   SetMinSize(GetSize());
   mList->SetColumnWidth(0, mList->GetClientSize().x - mList->GetColumnWidth(1));
}
void TimerRecordDialog::PopulateOrExchange(ShuttleGui& S)
{
   S.SetBorder(5);
   S.StartVerticalLay(true);
   {
      wxString strFormat = wxT("099 h 060 m 060 s");
      S.StartStatic(_("Start Date and Time"), true);
      {
         m_pDatePickerCtrl_Start = 
            new wxDatePickerCtrl(this, // wxWindow *parent, 
                                 ID_DATEPICKER_START, // wxWindowID id, 
                                 m_DateTime_Start); // const wxDateTime& dt = wxDefaultDateTime, 
                                 // const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDP_DEFAULT | wxDP_SHOWCENTURY, const wxValidator& validator = wxDefaultValidator, const wxString& name = "datectrl")
         m_pDatePickerCtrl_Start->SetName(_("Start Date"));
         m_pDatePickerCtrl_Start->SetRange(wxDateTime::Today(), wxInvalidDateTime); // No backdating.
         S.AddWindow(m_pDatePickerCtrl_Start);

         m_pTimeTextCtrl_Start = new TimeTextCtrl(this, ID_TIMETEXT_START, strFormat);
         m_pTimeTextCtrl_Start->SetName(_("Start Time"));
         m_pTimeTextCtrl_Start->SetTimeValue(wxDateTime_to_AudacityTime(m_DateTime_Start));
         S.AddWindow(m_pTimeTextCtrl_Start);
         m_pTimeTextCtrl_Start->EnableMenu(false);
      }
      S.EndStatic();

      S.StartStatic(_("End Date and Time"), true);
      {
         m_pDatePickerCtrl_End = 
            new wxDatePickerCtrl(this, // wxWindow *parent, 
                                 ID_DATEPICKER_END, // wxWindowID id, 
                                 m_DateTime_End); // const wxDateTime& dt = wxDefaultDateTime, 
                                 // const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDP_DEFAULT | wxDP_SHOWCENTURY, const wxValidator& validator = wxDefaultValidator, const wxString& name = "datectrl")
         m_pDatePickerCtrl_End->SetRange(m_DateTime_Start, wxInvalidDateTime); // No backdating.
         m_pDatePickerCtrl_End->SetName(_("End Date"));
         S.AddWindow(m_pDatePickerCtrl_End);

         m_pTimeTextCtrl_End = new TimeTextCtrl(this, ID_TIMETEXT_END, strFormat);
         m_pTimeTextCtrl_End->SetName(_("End Time"));
         m_pTimeTextCtrl_End->SetTimeValue(wxDateTime_to_AudacityTime(m_DateTime_End));
         S.AddWindow(m_pTimeTextCtrl_End);
         m_pTimeTextCtrl_End->EnableMenu(false);
      }
      S.EndStatic();

      S.StartStatic(_("Duration"), true);
      {
         wxString strFormat1 = wxT("099 days 024 h 060 m 060 s");
         m_pTimeTextCtrl_Duration = new TimeTextCtrl(this, ID_TIMETEXT_DURATION, strFormat1);
         m_pTimeTextCtrl_Duration->SetName(_("Duration"));
         m_pTimeTextCtrl_Duration->SetTimeValue(
            Internat::CompatibleToDouble(m_TimeSpan_Duration.GetSeconds().ToString())); //v milliseconds?
         S.AddWindow(m_pTimeTextCtrl_Duration);
         m_pTimeTextCtrl_Duration->EnableMenu(false);
      }
      S.EndStatic();
   }
   S.EndVerticalLay();
   
   S.AddStandardButtons();

   Layout();
   Fit();
   SetMinSize(GetSize());
   Center();
}
Example #19
0
void PalettePanel::LoadCurrentContents() {
	for(ToolBarList::iterator iter = tool_bars.begin(); iter != tool_bars.end(); ++iter) {
		(*iter)->OnSwitchIn();
	}
	Fit();
}
Example #20
0
PrefsDialog::PrefsDialog
(wxWindow * parent, const wxString &titlePrefix, Factories &factories)
    :  wxDialogWrapper(parent, wxID_ANY, wxString(_("Audacity Preferences")),
                       wxDefaultPosition,
                       wxDefaultSize,
                       wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
    , mFactories(factories)
    , mTitlePrefix(titlePrefix)
{
    wxASSERT(factories.size() > 0);
    const bool uniquePage = (factories.size() == 1);

    ShuttleGui S(this, eIsCreating);

    S.StartVerticalLay(true);
    {
        wxASSERT(factories.size() > 0);
        if (!uniquePage) {
            mCategories = safenew wxTreebookExt(this, wxID_ANY, mTitlePrefix);
            S.StartHorizontalLay(wxALIGN_LEFT | wxEXPAND, true);
            {
                S.Prop(1);
                S.AddWindow(mCategories, wxEXPAND);

                {
                    typedef std::pair<int, int> IntPair;
                    std::vector<IntPair> stack;
                    int iPage = 0;
                    for (Factories::const_iterator it = factories.begin(), end = factories.end();
                            it != end; ++it, ++iPage)
                    {
                        const PrefsNode &node = *it;
                        PrefsPanelFactory &factory = *node.pFactory;
                        wxWindow *const w = factory.Create(mCategories);
                        if (stack.empty())
                            // Parameters are: AddPage(page, name, IsSelected, imageId).
                            mCategories->AddPage(w, w->GetName(), false, 0);
                        else {
                            IntPair &top = *stack.rbegin();
                            mCategories->InsertSubPage(top.first, w, w->GetName(), false, 0);
                            if (--top.second == 0) {
                                // Expand all nodes before the layout calculation
                                mCategories->ExpandNode(top.first, true);
                                stack.pop_back();
                            }
                        }
                        if (node.nChildren > 0)
                            stack.push_back(IntPair(iPage, node.nChildren));
                    }
                }
            }
            S.EndHorizontalLay();
        }
        else {
            // Unique page, don't show the factory
            const PrefsNode &node = factories[0];
            PrefsPanelFactory &factory = *node.pFactory;
            mUniquePage = factory.Create(this);
            S.AddWindow(mUniquePage, wxEXPAND);
        }
    }
    S.EndVerticalLay();

    S.AddStandardButtons(eOkButton | eCancelButton | eApplyButton);
    static_cast<wxButton*>(wxWindow::FindWindowById(wxID_OK, this))->SetDefault();

    if (mUniquePage && !mUniquePage->ShowsApplyButton()) {
        wxWindow *const applyButton =
            wxWindow::FindWindowById(wxID_APPLY, GetParent());
        applyButton->Show(false);
    }

#if defined(__WXGTK__)
    if (mCategories)
        mCategories->GetTreeCtrl()->EnsureVisible(mCategories->GetTreeCtrl()->GetRootItem());
#endif

//   mCategories->SetSizeHints(-1, -1, 790, 600);  // 790 = 800 - (border * 2)
    Layout();
    Fit();
    wxSize sz = GetSize();

    // Collapse nodes only after layout so the tree is wide enough
    if (mCategories)
    {
        int iPage = 0;
        for (Factories::const_iterator it = factories.begin(), end = factories.end();
                it != end; ++it, ++iPage)
            mCategories->ExpandNode(iPage, it->expanded);
    }

    // This ASSERT used to limit us to 800 x 600.
    // However, we think screens have got bigger now, and that was a bit too restrictive.
    // The impetus for increasing the limit (before we ASSERT) was that this ASSERT
    // was firing with wxWidgets 3.0, which has slightly different sizer behaviour.
    wxASSERT_MSG(sz.x <= 1000 && sz.y <= 750, wxT("Preferences dialog exceeds max size"));

    if (sz.x > 800) {
        sz.x = 800;
    }

    if (sz.y > 600) {
        sz.y = 600;
    }

    // Set the minimum height to be slightly bigger than default, as fix for bug 161.
    // The magic number 7 was determined by Ed's experimentation.
    // Frankly, this is a hack to work around a bug in wxTreebook, and
    // will have to be revisited if we add another category to mCategories.
    // JKC later added a category and 20 onto the 7.
    sz.y += 7 + 20;
    SetSize(sz);
    SetMinSize(sz);

    // Center after all that resizing, but make sure it doesn't end up
    // off-screen
    CentreOnParent();
}
Example #21
0
 void Fit(DataVector *data) { Fit(data, data->size()); }
Example #22
0
void CAccountInfoPage::OnPageChanged( wxWizardExEvent& event ) {
    if (event.GetDirection() == false) return;

    CWizardAttach*   pWA = ((CWizardAttach*)GetParent());
    CSkinAdvanced*   pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced();
    CSkinWizardATAM* pSkinWizardATAM = wxGetApp().GetSkinManager()->GetWizards()->GetWizardATAM();
    PROJECT_CONFIG&  pc = pWA->project_config;
    wxString         strBaseConfigLocation = wxString(wxT("/Wizards"));
    wxConfigBase*    pConfig = wxConfigBase::Get(FALSE);
 
    wxASSERT(pSkinAdvanced);
    wxASSERT(pSkinWizardATAM);
    wxASSERT(m_pTitleStaticCtrl);
    wxASSERT(m_pCookieDetectionFailedStaticCtrl);
    wxASSERT(m_pCookieDetectionFailedCtrl);
    wxASSERT(m_pAccountQuestionStaticCtrl);
    wxASSERT(m_pAccountInformationStaticCtrl);
    wxASSERT(m_pAccountCreateCtrl);
    wxASSERT(m_pAccountUseExistingCtrl);
    wxASSERT(m_pAccountEmailAddressStaticCtrl);
    wxASSERT(m_pAccountEmailAddressCtrl);
    wxASSERT(m_pAccountUsernameStaticCtrl);
    wxASSERT(m_pAccountUsernameCtrl);
    wxASSERT(m_pAccountPasswordStaticCtrl);
    wxASSERT(m_pAccountPasswordCtrl);
    wxASSERT(m_pAccountConfirmPasswordStaticCtrl);
    wxASSERT(m_pAccountConfirmPasswordCtrl);
    wxASSERT(m_pAccountPasswordRequirmentsStaticCtrl);
    wxASSERT(m_pAccountManagerLinkLabelStaticCtrl);
    wxASSERT(m_pAccountForgotPasswordCtrl);
    wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced));
    wxASSERT(wxDynamicCast(pSkinWizardATAM, CSkinWizardATAM));


    // We are entering this page, so reterieve the previously used email
    // address and/or username.
    pConfig->SetPath(strBaseConfigLocation);
    m_strAccountEmailAddress = pConfig->Read(wxT("DefaultEmailAddress"));
    m_strAccountUsername = pConfig->Read(wxT("DefaultUsername"));

    // Setup the desired controls and default values.
    static bool bRunOnce = true;
    if (bRunOnce) {
        bRunOnce = false;
        if (!IS_ACCOUNTMANAGERWIZARD()) {
            m_pAccountCreateCtrl->SetValue(true);
            m_pAccountUseExistingCtrl->SetValue(false);
        }
    }

    if (IS_ACCOUNTMANAGERWIZARD()) {
        if (!(pWA->m_bCookieRequired && !pWA->m_bCredentialsDetected)) {
            m_pCookieDetectionFailedStaticCtrl->Hide();
            m_pCookieDetectionFailedCtrl->Hide();
        } else {
            m_pCookieDetectionFailedStaticCtrl->Show();
            m_pCookieDetectionFailedCtrl->Show();
        }

        m_pAccountQuestionStaticCtrl->Hide();
        m_pAccountCreateCtrl->SetValue(false);
        m_pAccountCreateCtrl->Hide();
        m_pAccountUseExistingCtrl->SetValue(true);
        m_pAccountUseExistingCtrl->Hide();
        m_pAccountConfirmPasswordStaticCtrl->Hide();
        m_pAccountConfirmPasswordCtrl->Hide();
        m_pAccountPasswordRequirmentsStaticCtrl->Hide();

        if (pWA->m_bCookieRequired && !pWA->m_bCredentialsDetected) {
            m_pAccountManagerLinkLabelStaticCtrl->Hide();
            m_pAccountForgotPasswordCtrl->Hide();
        }
    } else {
        m_pCookieDetectionFailedStaticCtrl->Hide();
        m_pCookieDetectionFailedCtrl->Hide();
        if (pc.account_creation_disabled || pc.client_account_creation_disabled) {
            m_pAccountCreateCtrl->SetValue(false);
            m_pAccountCreateCtrl->Hide();
            m_pAccountUseExistingCtrl->SetValue(true);
            m_pAccountUseExistingCtrl->Hide();
        } else {
            m_pAccountCreateCtrl->Show();
            m_pAccountCreateCtrl->Enable();
            m_pAccountUseExistingCtrl->Show();
        }
        m_pAccountManagerLinkLabelStaticCtrl->Hide();
    }

    wxString str;
    wxString name = wxString(pc.name.c_str(), wxConvUTF8);
    str.Printf(_("Identify your account at %s"), name.c_str());
    m_pTitleStaticCtrl->SetLabel(str);

    if (!IS_ACCOUNTMANAGERWIZARD() && !IS_ACCOUNTMANAGERUPDATEWIZARD()) {
		if (pc.client_account_creation_disabled) {
			m_pAccountQuestionStaticCtrl->SetLabel(
				_("Please enter your account information\n(to create an account, visit the project's web site)")
			);
		} else if (pc.account_creation_disabled) {
			m_pAccountQuestionStaticCtrl->SetLabel(
				_("This project is not currently accepting new accounts.\nYou can add it only if you already have an account.")
			);
		} else {
			m_pAccountQuestionStaticCtrl->SetLabel(
				_("Are you already running this project?")
			);
		}
        m_pAccountCreateCtrl->SetLabel(
            _("&No, new user")
        );
        m_pAccountUseExistingCtrl->SetLabel(
            _("&Yes, existing user")
        );
    } else {
        if (pWA->m_bCookieRequired && !pWA->m_bCredentialsDetected) {
            m_pCookieDetectionFailedStaticCtrl->SetLabel(
                _("We were not able to set up your account information\nautomatically.\n\nPlease click on the 'Find login information' link\nbelow to find out what to put in the email address and\npassword fields.")
            );
            m_pCookieDetectionFailedCtrl->SetLabel(
                _("Find login information")
            );
            m_pCookieDetectionFailedCtrl->SetURL(
                pWA->m_strCookieFailureURL
            );
        }

        if (pSkinAdvanced->IsBranded() && 
            !pSkinWizardATAM->GetAccountInfoMessage().IsEmpty()) {
            m_pAccountInformationStaticCtrl->SetLabel(
                pSkinWizardATAM->GetAccountInfoMessage()
            );
        }
    }

    if (m_pAccountUseExistingCtrl->GetValue()) {
        m_pAccountConfirmPasswordStaticCtrl->Hide();
        m_pAccountConfirmPasswordCtrl->Hide();
        m_pAccountPasswordRequirmentsStaticCtrl->Hide();
        m_pAccountPasswordStaticCtrl->SetLabel(
            _("&Password:"******"Choose a &password:"******"C&onfirm password:"******"Are you already running %s?"),
            pWA->GetProjectName().c_str()
        );
        m_pAccountQuestionStaticCtrl->SetLabel(strQuestion);
    }

    if (pc.uses_username) {
        if (IS_ACCOUNTMANAGERWIZARD()) {
            if (pSkinAdvanced->IsBranded() && 
                !pSkinWizardATAM->GetAccountInfoMessage().IsEmpty()) {
                m_pAccountInformationStaticCtrl->SetLabel(
                    pSkinWizardATAM->GetAccountInfoMessage()
                );
            }
        }

        m_pAccountEmailAddressCtrl->SetValidator( 
            wxTextValidator(wxFILTER_NONE, &m_strAccountEmailAddress)
        );
        m_pAccountUsernameCtrl->SetValidator(
            wxTextValidator(wxFILTER_ASCII, &m_strAccountUsername)
        );

        m_pAccountEmailAddressStaticCtrl->Hide();
        m_pAccountEmailAddressCtrl->Hide();
        m_pAccountUsernameStaticCtrl->Show();
        m_pAccountUsernameCtrl->Show();

        m_pAccountUsernameStaticCtrl->SetLabel(
            _("&Username:"******"&Email address:")
        );
        m_pAccountEmailAddressCtrl->SetValue(m_strAccountEmailAddress);
    }

    if (pc.min_passwd_length) {
        wxString str2;
        str.Printf(_("minimum length %d"), pc.min_passwd_length);
        m_pAccountPasswordRequirmentsStaticCtrl->SetLabel( str2 );
    }


    if (!IS_ACCOUNTMANAGERWIZARD()) {
        m_pAccountForgotPasswordCtrl->SetLabel(
            _("Forgot your password?")
        );
        m_pAccountForgotPasswordCtrl->SetURL(
            wxString(pWA->m_ProjectInfoPage->GetProjectURL() + _T("get_passwd.php"))
        );
    } else {
        m_pAccountManagerLinkLabelStaticCtrl->SetLabel(
            _("If you have not yet registered with this account manager,\nplease do so before proceeding.  Click on the link below\nto register or to retrieve a forgotten password." )
        );
        m_pAccountForgotPasswordCtrl->SetLabel(
            _("Account manager web site")
        );
        m_pAccountForgotPasswordCtrl->SetURL(
            wxString(pWA->m_AccountManagerInfoPage->GetProjectURL())
        );
    }

    if (pc.uses_username) {
        m_pAccountUsernameCtrl->SetFocus();
    } else {
        m_pAccountEmailAddressCtrl->SetFocus();
    }

    Fit();
}
Example #23
0
void wxGenericPrintSetupDialog::Init(wxPrintData* data)
{
    if ( data )
        m_printData = *data;

    m_targetData = data;

    wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );

    // printer selection

    wxStaticBoxSizer *printer_sizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Printer") ), wxVERTICAL );
    main_sizer->Add( printer_sizer, 0, wxALL|wxGROW, 10 );

    m_printerListCtrl = new wxListCtrl( this, wxPRINTID_PRINTER,
        wxDefaultPosition, wxSize(wxDefaultCoord,100), wxLC_REPORT|wxLC_SINGLE_SEL|wxSUNKEN_BORDER );
    wxImageList *image_list = new wxImageList;
    image_list->Add( wxBitmap(check_xpm) );
    m_printerListCtrl->AssignImageList( image_list, wxIMAGE_LIST_SMALL );

    m_printerListCtrl->InsertColumn( 0, wxT(" "), wxLIST_FORMAT_LEFT, 20 );
    m_printerListCtrl->InsertColumn( 1, wxT("Printer"), wxLIST_FORMAT_LEFT, 150 );
    m_printerListCtrl->InsertColumn( 2, wxT("Device"), wxLIST_FORMAT_LEFT, 150 );
    m_printerListCtrl->InsertColumn( 3, wxT("Status"), wxLIST_FORMAT_LEFT, 80 );

    wxListItem item;
    item.SetMask( wxLIST_MASK_TEXT );
    item.SetColumn( 1 );
    item.SetText( _("Default printer") );
    item.SetId( m_printerListCtrl->InsertItem( item ) );

    if (data->GetPrinterName().empty())
    {
        wxListItem item2;
        item2.SetId( item.GetId() );
        item2.SetMask( wxLIST_MASK_IMAGE );
        item2.SetImage( 0 );
        m_printerListCtrl->SetItem( item2 );
        // also select item
        m_printerListCtrl->SetItemState( item.GetId(), wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
    }

    item.SetId( 1+ item.GetId() );

    wxArrayString errors;
    wxArrayString output;
    long res = wxExecute( wxT("lpstat -v"), output, errors, wxEXEC_NODISABLE );
    if (res >= 0 && errors.GetCount() == 0)
    {
        size_t i;
        for (i = 0; i < output.GetCount(); i++)
        {
            wxStringTokenizer tok( output[i], wxT(" ") );
            wxString tmp = tok.GetNextToken(); // "device"
            if (tmp != wxT("device"))
                break;  // the lpstat syntax must have changed.
            tmp = tok.GetNextToken();          // "for"
            if (tmp != wxT("for"))
                break;  // the lpstat syntax must have changed.
            tmp = tok.GetNextToken();          // "hp_deskjet930c:"
            if (tmp[tmp.length()-1] == wxT(':'))
                tmp.Remove(tmp.length()-1,1);
            wxString name = tmp;
            item.SetText( name );
            item.SetId( m_printerListCtrl->InsertItem( item ) );
            tmp = tok.GetNextToken();          // "parallel:/dev/lp0"
            item.SetColumn( 2 );
            item.SetText( tmp );
            m_printerListCtrl->SetItem( item );
            if (data->GetPrinterName() == name)
            {
                wxListItem item2;
                item2.SetId( item.GetId() );
                item2.SetMask( wxLIST_MASK_IMAGE );
                item2.SetImage( 0 );
                m_printerListCtrl->SetItem( item2 );
                // also select item
                m_printerListCtrl->SetItemState( item.GetId(), wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
            }

            wxString command = wxT("lpstat -p ");
            command += name;
            wxArrayString errors2;
            wxArrayString output2;
            res = wxExecute( command, output2, errors2, wxEXEC_NODISABLE );
            if (res >= 0 && errors2.GetCount() == 0 && output2.GetCount() > 0)
            {
                tmp = output2[0]; // "printer hp_deskjet930c is idle. enable since ..."
                int pos = tmp.Find( wxT('.') );
                if (pos != wxNOT_FOUND)
                    tmp.Remove( (size_t)pos, tmp.length()-(size_t)pos );
                wxStringTokenizer tok2( tmp, wxT(" ") );
                tmp = tok2.GetNextToken();  // "printer"
                tmp = tok2.GetNextToken();  // "hp_deskjet930c"
                tmp = wxEmptyString;
                while (tok2.HasMoreTokens())
                {
                    tmp += tok2.GetNextToken();
                    tmp += wxT(" ");
                }
                item.SetColumn( 3 );
                item.SetText( tmp );
                m_printerListCtrl->SetItem( item );
            }

            item.SetColumn( 1 );
            item.SetId( 1+ item.GetId() );
        }
    }


    printer_sizer->Add( m_printerListCtrl, 0, wxALL|wxGROW, 5 );

    wxBoxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );
    main_sizer->Add( item1, 0, wxALL, 5 );

    // printer options (on the left)

    wxBoxSizer *item2 = new wxBoxSizer( wxVERTICAL );

    wxStaticBox *item4 = new wxStaticBox( this, wxPRINTID_STATIC, _("Paper size") );
    wxStaticBoxSizer *item3 = new wxStaticBoxSizer( item4, wxVERTICAL );

    m_paperTypeChoice = CreatePaperTypeChoice();
    item3->Add( m_paperTypeChoice, 0, wxALIGN_CENTER|wxALL, 5 );

    item2->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 );

    wxString strs6[] =
    {
        _("Portrait"),
        _("Landscape")
    };
    m_orientationRadioBox= new wxRadioBox( this, wxPRINTID_ORIENTATION, _("Orientation"), wxDefaultPosition, wxDefaultSize, 2, strs6, 1, wxRA_SPECIFY_ROWS );
    item2->Add( m_orientationRadioBox, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );

    wxStaticBox *item8 = new wxStaticBox( this, wxID_ANY, _("Options") );
    wxStaticBoxSizer *item7 = new wxStaticBoxSizer( item8, wxHORIZONTAL );

    m_colourCheckBox = new wxCheckBox( this, wxPRINTID_PRINTCOLOUR, _("Print in colour") );
    item7->Add( m_colourCheckBox, 0, wxALIGN_CENTER|wxALL, 5 );

    item2->Add( item7, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );

    item1->Add( item2, 0, wxALIGN_CENTER_HORIZONTAL, 5 );

    // spooling options (on the right)

    wxStaticBox *item11 = new wxStaticBox( this, wxID_ANY, _("Print spooling") );
    wxStaticBoxSizer *item10 = new wxStaticBoxSizer( item11, wxVERTICAL );

    wxStaticText *item12 = new wxStaticText( this, wxID_ANY, _("Printer command:") );
    item10->Add( item12, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );

    wxBoxSizer *item13 = new wxBoxSizer( wxHORIZONTAL );

    item13->Add( 20, 20, 0, wxALIGN_CENTER|wxALL, 5 );

    m_printerCommandText = new wxTextCtrl( this, wxPRINTID_COMMAND, wxEmptyString, wxDefaultPosition, wxSize(160,wxDefaultCoord) );
    item13->Add( m_printerCommandText, 0, wxALIGN_CENTER|wxALL, 5 );

    item10->Add( item13, 0, wxALIGN_CENTER|wxALL, 0 );

    wxStaticText *item15 = new wxStaticText( this, wxID_ANY, _("Printer options:") );
    item10->Add( item15, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );

    wxBoxSizer *item16 = new wxBoxSizer( wxHORIZONTAL );

    item16->Add( 20, 20, 0, wxALIGN_CENTER|wxALL, 5 );

    m_printerOptionsText = new wxTextCtrl( this, wxPRINTID_OPTIONS, wxEmptyString, wxDefaultPosition, wxSize(160,wxDefaultCoord) );
    item16->Add( m_printerOptionsText, 0, wxALIGN_CENTER|wxALL, 5 );

    item10->Add( item16, 0, wxALIGN_CENTER|wxALL, 0 );

    item1->Add( item10, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );


#if wxUSE_STATLINE
    // static line
    main_sizer->Add( new wxStaticLine( this, wxID_ANY ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 );
#endif

    // buttons

    main_sizer->Add( CreateButtonSizer( wxOK|wxCANCEL), 0, wxEXPAND|wxALL, 10 );

    SetAutoLayout( true );
    SetSizer( main_sizer );

    main_sizer->Fit( this );
    Centre(wxBOTH);


    Fit();
    Centre(wxBOTH);

    InitDialog();
}
CDialogEnableMultiple::CDialogEnableMultiple(
    const vector<COARsample *> *pvpSamples,
    bool bAllowUserNameOverride,
    wxWindow *parent) : 
  wxDialog(
    parent,wxID_ANY,g_psDisable,
    wxDefaultPosition, wxDefaultSize,
    mainApp::DIALOG_STYLE),
    m_pReview(NULL),
    m_pCombo(NULL),
    m_nListSize((int) pvpSamples->size())
{
  vector<COARsample *>::const_iterator itr;
  size_t nSampleCount = pvpSamples->size();
  int n = 0;
  COARsample *pSample;

  m_vnEnabled.reserve(nSampleCount);
  m_vnDisabled.reserve(nSampleCount);
  m_vpSampleEnabled.reserve(nSampleCount);
  m_vpSampleDisabled.reserve(nSampleCount);
  for(itr = pvpSamples->begin();
    itr != pvpSamples->end();
    ++itr)
  {
    n++;
    pSample = *itr;
    if(!pSample->IsSampleType()) {}
    else if(pSample->IsEnabled())
    {
      m_vnEnabled.push_back(n);
      m_vpSampleEnabled.push_back(pSample);
    }
    else
    {
      m_vnDisabled.push_back(n);
      m_vpSampleDisabled.push_back(pSample);
    }
  }
  if(HasSamples())
  {
    wxBoxSizer *pSizer = new wxBoxSizer(wxVERTICAL);
    wxWindow *pWindowTop(NULL);
    int nSizeTOP = wxALIGN_LEFT | wxALL;
    bool bEnable = false;
    if(m_vpSampleEnabled.empty())
    {
      pWindowTop = new wxStaticText(this,wxID_ANY,g_psEnable);
      bEnable = true;
      SetTitle(g_psEnable);
    }
    else if(m_vpSampleDisabled.empty())
    {
      pWindowTop = new wxStaticText(this,wxID_ANY,g_psDisable);
    }
    else
    {
      const wxChar *pChoices[2] = {g_psDisable,g_psEnable};
      wxArrayString choices(2,pChoices);
      m_pCombo = new wxComboBox(this,wxID_ANY,"",
        wxDefaultPosition, wxDefaultSize, choices,wxCB_READONLY);
      pWindowTop = m_pCombo;
      m_pCombo->SetSelection(0);
      nSizeTOP = wxALL | wxEXPAND;
    }
    m_pListBox = new wxListBox(
      this,wxID_ANY,wxDefaultPosition, wxSize(-1,200),
      0,NULL, wxLB_EXTENDED | wxLB_NEEDED_SB);
    m_pReview = new CEnableDisableMultiple(this);
    m_pPanelUser = new CPanelUserID(
      this,wxID_ANY,wxID_ANY,m_pReview,
      UID_BTN_OK | UID_BTN_CANCEL | 
      UID_SPACER_BTN_RIGHT | UID_SEND_BTN_EVENTS,
      !bAllowUserNameOverride);
    m_pPanelUser->Enable(false);
    pSizer->Add(pWindowTop,0,nSizeTOP,ID_BORDER);
    pSizer->Add(m_pListBox,1,(wxALL ^ wxTOP) | wxEXPAND,ID_BORDER);
    pSizer->Add(m_pPanelUser,0,(wxALL ^ wxTOP) | wxEXPAND, ID_BORDER);
    SetSizer(pSizer);
    pSizer->Layout();
    _SetupList(bEnable);
    CentreOnParent();
#ifdef __WXMAC__
    Fit();
#endif
  }
}
Example #25
0
/* PreferencesDialog::PreferencesDialog
 * PreferencesDialog class constructor
 *******************************************************************/
PreferencesDialog::PreferencesDialog(wxWindow* parent) : SDialog(parent, "SLADE Preferences", "prefs")
{
	// Setup main sizer
	wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
	SetSizer(sizer);

	// Set icon
	wxIcon icon;
	icon.CopyFromBitmap(Icons::getIcon(Icons::GENERAL, "settings"));
	SetIcon(icon);

	// Create preferences TreeBook
	tree_prefs = new wxTreebook(this, -1, wxDefaultPosition, wxDefaultSize);

	// Setup preferences TreeBook
	PrefsPanelBase* panel;
	panel = new GeneralPrefsPanel(tree_prefs);		tree_prefs->AddPage(panel, "General", true); prefs_pages.push_back(panel);
	panel = new OpenGLPrefsPanel(tree_prefs);		tree_prefs->AddSubPage(panel, "OpenGL"); prefs_pages.push_back(panel);
	panel = new InterfacePrefsPanel(tree_prefs);	tree_prefs->AddPage(panel, "Interface"); prefs_pages.push_back(panel);
	panel = new ColourPrefsPanel(tree_prefs);		tree_prefs->AddSubPage(panel, "Colours & Theme"); prefs_pages.push_back(panel);
	panel = new InputPrefsPanel(tree_prefs);		tree_prefs->AddPage(panel, "Input"); prefs_pages.push_back(panel);
	panel = new EditingPrefsPanel(tree_prefs);		tree_prefs->AddPage(panel, "Editing"); prefs_pages.push_back(panel);
	tree_prefs->AddSubPage(setupBaseResourceArchivesPanel(), "Base Resource Archive");
	panel = new TextEditorPrefsPanel(tree_prefs);	tree_prefs->AddPage(panel, "Text Editor"); prefs_pages.push_back(panel);
	panel = new TextStylePrefsPanel(tree_prefs);	tree_prefs->AddSubPage(panel, "Fonts & Colours"); prefs_pages.push_back(panel);
	panel = new GraphicsPrefsPanel(tree_prefs);		tree_prefs->AddPage(panel, "Graphics"); prefs_pages.push_back(panel);
	panel = new PNGPrefsPanel(tree_prefs);			tree_prefs->AddSubPage(panel, "PNG"); prefs_pages.push_back(panel);
	panel = new ColorimetryPrefsPanel(tree_prefs);	tree_prefs->AddSubPage(panel, "Colorimetry"); prefs_pages.push_back(panel);
	panel = new HudOffsetsPrefsPanel(tree_prefs);	tree_prefs->AddSubPage(panel, "HUD Offsets View"); prefs_pages.push_back(panel);
	panel = new AudioPrefsPanel(tree_prefs);		tree_prefs->AddPage(panel, "Audio"); prefs_pages.push_back(panel);
	tree_prefs->AddPage(new wxPanel(tree_prefs, -1), "Scripting");
	panel = new ACSPrefsPanel(tree_prefs);			tree_prefs->AddSubPage(panel, "ACS"); prefs_pages.push_back(panel);
	panel = new MapEditorPrefsPanel(tree_prefs);	tree_prefs->AddPage(panel, "Map Editor"); prefs_pages.push_back(panel);
	panel = new MapDisplayPrefsPanel(tree_prefs);	tree_prefs->AddSubPage(panel, "Display"); prefs_pages.push_back(panel);
	panel = new Map3DPrefsPanel(tree_prefs);		tree_prefs->AddSubPage(panel, "3D Mode"); prefs_pages.push_back(panel);
	panel = new NodesPrefsPanel(tree_prefs);		tree_prefs->AddSubPage(panel, "Node Builders"); prefs_pages.push_back(panel);
	prefs_advanced = new AdvancedPrefsPanel(tree_prefs);
	tree_prefs->AddPage(prefs_advanced, "Advanced");

	// Expand all tree nodes (so it gets sized properly)
	for (unsigned page = 0; page < tree_prefs->GetPageCount(); page++)
		tree_prefs->ExpandNode(page);

	// Add preferences treebook
	sizer->Add(tree_prefs, 1, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 10);

	// Add buttons
	sizer->Add(CreateButtonSizer(wxOK|wxCANCEL|wxAPPLY), 0, wxEXPAND|wxALL, 10);

	// Bind events
	Bind(wxEVT_BUTTON, &PreferencesDialog::onButtonClicked, this);

	// Setup layout
	SetInitialSize(GetSize());
	Layout();
	Fit();
	SetMinSize(wxSize(800, 600));
	CenterOnParent();

	// Collapse all tree nodes
	for (unsigned page = 0; page < tree_prefs->GetPageCount(); page++)
		tree_prefs->CollapseNode(page);
}
Example #26
0
HistoryWindow::HistoryWindow(AudacityProject *parent, UndoManager *manager):
   wxDialogWrapper((wxWindow*)parent, wxID_ANY, wxString(_("History")),
      wxDefaultPosition, wxDefaultSize,
      wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
{
   SetName(GetTitle());

   mManager = manager;
   mProject = parent;
   mSelected = 0;
   mAudioIOBusy = false;

   auto imageList = std::make_unique<wxImageList>(9, 16);
   imageList->Add(wxIcon(empty9x16_xpm));
   imageList->Add(wxIcon(arrow_xpm));

   //------------------------- Main section --------------------
   // Construct the GUI.
   ShuttleGui S(this, eIsCreating);

   S.SetBorder(5);
   S.StartVerticalLay(true);
   {
      S.StartStatic(_("&Manage History"), 1);
      {
         mList = S.AddListControlReportMode();
         // Do this BEFORE inserting the columns.  On the Mac at least, the
         // columns are deleted and later InsertItem()s will cause Audacity to crash.
         mList->SetSingleStyle(wxLC_SINGLE_SEL);
         mList->InsertColumn(0, _("Action"), wxLIST_FORMAT_LEFT, 300);
         mList->InsertColumn(1, _("Size"), wxLIST_FORMAT_LEFT, 85);

         //Assign rather than set the image list, so that it is deleted later.
         // AssignImageList takes ownership
         mList->AssignImageList(imageList.release(), wxIMAGE_LIST_SMALL);

         S.StartMultiColumn(3, wxCENTRE);
         {
            // FIXME: Textbox labels have inconsistent capitalization
            mTotal = S.Id(ID_TOTAL).AddTextBox(_("&Total space used"), wxT("0"), 10);
            mTotal->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(HistoryWindow::OnChar));
            S.AddVariableText(wxT(""))->Hide();

            mAvail = S.Id(ID_AVAIL).AddTextBox(_("&Undo Levels Available"), wxT("0"), 10);
            mAvail->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(HistoryWindow::OnChar));
            S.AddVariableText(wxT(""))->Hide();

            S.AddPrompt(_("&Levels To Discard"));
            mLevels = safenew wxSpinCtrl(this,
                                     ID_LEVELS,
                                     wxT("1"),
                                     wxDefaultPosition,
                                     wxDefaultSize,
                                     wxSP_ARROW_KEYS,
                                     0,
                                     mManager->GetCurrentState() - 1,
                                     0);
            S.AddWindow(mLevels);
            /* i18n-hint: (verb)*/
            mDiscard = S.Id(ID_DISCARD).AddButton(_("&Discard"));

            mClipboard = S.AddTextBox(_("Clipboard space used"), wxT("0"), 10);
            mClipboard->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(HistoryWindow::OnChar));
            S.Id(ID_DISCARD_CLIPBOARD).AddButton(_("Discard"));
         }
         S.EndMultiColumn();
      }
      S.EndStatic();

      S.StartHorizontalLay(wxALIGN_RIGHT, false);
      {
         S.SetBorder(10);
         S.Id(wxID_OK).AddButton(_("&OK"))->SetDefault();
      }
      S.EndHorizontalLay();
   }
   S.EndVerticalLay();
   // ----------------------- End of main section --------------

   DoUpdate();
   mList->SetMinSize(mList->GetSize());
   Fit();
   SetMinSize(GetSize());
   mList->SetColumnWidth(0, mList->GetClientSize().x - mList->GetColumnWidth(1));
   mList->SetTextColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));

   wxTheApp->Connect(EVT_AUDIOIO_PLAYBACK,
                     wxCommandEventHandler(HistoryWindow::OnAudioIO),
                     NULL,
                     this);

   wxTheApp->Connect(EVT_AUDIOIO_CAPTURE,
                     wxCommandEventHandler(HistoryWindow::OnAudioIO),
                     NULL,
                     this);
}
Example #27
0
dlgAbout::dlgAbout(wxWindow* parent)
{
    if (!wxXmlResource::Get()->LoadObject(this, parent, _T("dlgAbout"), _T("wxScrollingDialog")))
    {
        cbMessageBox(_("There was an error loading the \"About\" dialog from XRC file."),
                     _("Information"), wxICON_EXCLAMATION);
        return;
    }

    const wxString description = _("Welcome to ") + appglobals::AppName + _T(" ") +
                                 appglobals::AppVersion + _T("!\n") + appglobals::AppName +
                                 _(" is a full-featured IDE (Integrated Development Environment) "
                                   "aiming to make the individual developer (and the development team) "
                                   "work in a nice programming environment offering everything he/they "
                                   "would ever need from a program of that kind.\n"
                                   "Its pluggable architecture allows you, the developer, to add "
                                   "any kind of functionality to the core program, through the use of "
                                   "plugins...\n");

    wxString file = ConfigManager::ReadDataPath() + _T("/images/splash_1312.png");
    wxImage im; im.LoadFile(file, wxBITMAP_TYPE_PNG); im.ConvertAlphaToMask();
    wxBitmap bmp(im);
    wxMemoryDC dc;
    dc.SelectObject(bmp);
    cbSplashScreen::DrawReleaseInfo(dc);

    wxStaticBitmap *bmpControl = XRCCTRL(*this, "lblTitle", wxStaticBitmap);
    bmpControl->SetSize(im.GetWidth(),im.GetHeight());
    bmpControl->SetBitmap(bmp);

    XRCCTRL(*this, "lblBuildTimestamp", wxStaticText)->SetLabel(wxString(_("Build: ")) + appglobals::AppBuildTimestamp);
    XRCCTRL(*this, "txtDescription",    wxTextCtrl)->SetValue(description);
    XRCCTRL(*this, "txtThanksTo",       wxTextCtrl)->SetValue(_(
        "Developers:\n"
        "--------------\n"
        "Yiannis Mandravellos: Developer - Project leader\n"
        "Thomas Denk         : Developer\n"
        "Lieven de C**k      : Developer\n"
        "\"tiwag\"             : Developer\n"
        "Martin Halle        : Developer\n"
        "Biplab Modak        : Developer\n"
        "Jens Lody           : Developer\n"
        "Yuchen Deng         : Developer\n"
        "Teodor Petrov       : Developer\n"
        "Daniel Anselmi      : Developer\n"
        "Yuanhui Zhang       : Developer\n"
        "Damien Moore        : Developer\n"
        "Micah Ng            : Developer\n"
        "Ricardo Garcia      : All-hands person\n"
        "Paul A. Jimenez     : Help and AStyle plugins\n"
        "Thomas Lorblanches  : CodeStat and Profiler plugins\n"
        "Bartlomiej Swiecki  : wxSmith RAD plugin\n"
        "Jerome Antoine      : ThreadSearch plugin\n"
        "Pecan Heber         : Keybinder, BrowseTracker, DragScroll\n"
        "                      CodeSnippets plugins\n"
        "Arto Jonsson        : CodeSnippets plugin (passed on to Pecan)\n"
        "Mario Cupelli       : User's manual\n"
        "Anders F Bjoerklund : wxMac compatibility\n"
        "\n"
        "Contributors (in no special order):\n"
        "-----------------------------------\n"
        "Daniel Orb          : RPM spec file and packages\n"
        "Mario Cupelli       : Compiler support for embedded systems\n"
        "byo,elvstone, me22  : Conversion to Unicode\n"
        "pasgui              : Providing Ubuntu nightly packages\n"
        "Hakki Dogusan       : DigitalMars compiler support\n"
        "ybx                 : OpenWatcom compiler support\n"
        "Tim Baker           : Patches for the direct-compile-mode\n"
        "                      dependencies generation system\n"
        "David Perfors       : Unicode tester and future documentation writer\n"
        "Sylvain Prat        : Initial MSVC workspace and project importers\n"
        "Chris Raschko       : Design of the 3D logo for Code::Blocks\n"
        "J.A. Ortega         : 3D Icon based on the above\n"
        "\n"
        "All contributors that provided patches.\n"
        "The wxWidgets project (http://www.wxwidgets.org).\n"
        "wxScintilla (http://sourceforge.net/projects/wxscintilla).\n"
        "TinyXML parser (http://www.grinninglizard.com/tinyxml).\n"
        "Squirrel scripting language (http://www.squirrel-lang.org).\n"
        "The GNU Software Foundation (http://www.gnu.org).\n"
        "Last, but not least, the open-source community."));
    XRCCTRL(*this, "txtLicense", wxTextCtrl)->SetValue(LICENSE_GPL);

    XRCCTRL(*this, "lblName",    wxStaticText)->SetLabel(appglobals::AppName);
    XRCCTRL(*this, "lblVersion", wxStaticText)->SetLabel(appglobals::AppActualVersionVerb);
    XRCCTRL(*this, "lblSDK",     wxStaticText)->SetLabel(appglobals::AppSDKVersion);
    XRCCTRL(*this, "lblAuthor",  wxStaticText)->SetLabel(_("The Code::Blocks Team"));
    XRCCTRL(*this, "lblEmail",   wxStaticText)->SetLabel(appglobals::AppContactEmail);
    XRCCTRL(*this, "lblWebsite", wxStaticText)->SetLabel(appglobals::AppUrl);

#ifdef __WXMAC__
    // Courier 8 point is not readable on Mac OS X, increase font size:
    wxFont font1 = XRCCTRL(*this, "txtThanksTo", wxTextCtrl)->GetFont();
    font1.SetPointSize(10);
    XRCCTRL(*this, "txtThanksTo", wxTextCtrl)->SetFont(font1);

    wxFont font2 = XRCCTRL(*this, "txtLicense", wxTextCtrl)->GetFont();
    font2.SetPointSize(10);
    XRCCTRL(*this, "txtLicense", wxTextCtrl)->SetFont(font2);
#endif
    Fit();
    CentreOnParent();
}
Example #28
0
void NoiseDialog::OnTimeCtrlUpdate(wxCommandEvent & event) {
   Fit();
}
Example #29
0
//______________________________________________________________________________
void PIDEnergy()
{
    // Main method.
    
    Char_t tmp[256];
    
    // load CaLib
    gSystem->Load("libCaLib.so");
    
    // general configuration
    Bool_t watch = kTRUE;
    const Char_t* data = "Data.PID.E1";
    const Char_t* hName = "CaLib_PID_dE_E_013";
    Double_t yMin = 0;
    Double_t yMax = 2000;
    gMin = 500;
    gMax = 1100;

    // configuration (December 2007)
    //const Char_t calibration[] = "LD2_Dec_07";
    //const Char_t* fLoc = "/usr/puma_scratch0/werthm/A2/Dec_07/AR/out/droop";

    // configuration (February 2009)
    //const Char_t calibration[] = "LD2_Feb_09";
    //const Char_t* fLoc = "/usr/puma_scratch0/werthm/A2/Feb_09/AR/out/droop";
    
    // configuration (May 2009)
    const Char_t calibration[] = "LD2_May_09";
    const Char_t* fLoc = "/usr/puma_scratch0/werthm/A2/May_09/AR/out/droop";

    // create histogram
    gHOverview = new TH1F("Overview", "Overview", 40000, 0, 40000);
    TCanvas* cOverview = new TCanvas();
    gHOverview->GetYaxis()->SetRangeUser(yMin, yMax);
    gHOverview->Draw("E1");
    
    // create line
    gLine = new TLine();
    gLine->SetLineColor(kBlue);
    gLine->SetLineWidth(2);

    // init fitting function
    gFitFunc = 0;
    
    // create fitting canvas
    gCFit = new TCanvas();
    
    // get number of sets
    Int_t nSets = TCMySQLManager::GetManager()->GetNsets(data, calibration);
    
    // total number of runs
    Int_t nTotRuns = 0;

    // first and last runs
    Int_t first_run, last_run;

    // loop over sets
    for (Int_t i = 0; i < nSets; i++)
    {
        // get runs of set
        Int_t nRuns;
        Int_t* runs = TCMySQLManager::GetManager()->GetRunsOfSet(data, calibration, i, &nRuns);
    
        // loop over runs
        for (Int_t j = 0; j < nRuns; j++)
        {
            // save first and last runs
            if (i == 0 && j == 0) first_run = runs[j];
            if (i == nSets-1 && j == nRuns-1) last_run = runs[j];

            // clean-up
            if (gH) delete gH;
            if (gH3) delete gH3;
            if (gFile) delete gFile;
            gH = 0;
            gH3 = 0;
            gFile = 0;

            // load ROOT file
            sprintf(tmp, "%s/ARHistograms_CB_%d.root", fLoc, runs[j]);
            gFile = new TFile(tmp);

            // check file
            if (!gFile) continue;
            if (gFile->IsZombie()) continue;

            // load histogram
            gH3 = (TH3*) gFile->Get(hName);
            if (!gH3) continue;
            if (!gH3->GetEntries()) continue;
            if (gH3->GetEntries() < 5000) continue;

            // project histogram
            gH3->GetXaxis()->SetRangeUser(40, 60);
            sprintf(tmp, "Proj_%d_y", runs[j]);
            gH = (TH1D*) gH3->Project3D(tmp);
            gH->Rebin(3);

            // fit the histogram
            Fit(runs[j]);
            
            // update canvases and sleep
            if (watch)
            {
                cOverview->Update();
                gCFit->Update();
                //gSystem->Sleep(10);
            }
     
            // count run
            nTotRuns++;
        }

        // clean-up
        delete runs;

        // draw runset markers
        cOverview->cd();
        
        // get first run of set
        Int_t frun = TCMySQLManager::GetManager()->GetFirstRunOfSet(data, calibration, i);

        // draw line
        TLine* aLine = new TLine(frun, yMin, frun, yMax);
        aLine->SetLineColor(kBlue);
        aLine->SetLineWidth(2);
        aLine->Draw("same");
    }
    
    // adjust axis
    gHOverview->GetXaxis()->SetRangeUser(first_run-10, last_run+10);

    TFile* fout = new TFile("runset_overview.root", "recreate");
    cOverview->Write();
    delete fout;

    printf("%d runs analyzed.\n", nTotRuns);

    gSystem->Exit(0);
}
Example #30
0
ErrorDialog::ErrorDialog(
   wxWindow *parent,
   const wxString & dlogTitle,
   const wxString & message,
   const wxString & helpURL,
   const bool Close, const bool modal):
   wxDialog(parent, (wxWindowID)-1, dlogTitle)
{
   SetName(GetTitle());

   long buttonMask;

   // only add the help button if we have a URL
   buttonMask = (helpURL == wxT("")) ? eOkButton : (eHelpButton | eOkButton);
   dhelpURL = helpURL;
   dClose = Close;
   dModal = modal;

   ShuttleGui S(this, eIsCreating);

   S.StartVerticalLay();
   {
      S.SetBorder( 20 );
      S.AddFixedText( message );
      S.SetBorder( 2 );
      S.AddStandardButtons( buttonMask );
   }
   S.EndVerticalLay();

   Layout();
   Fit();
   SetMinSize(GetSize());
   Center();

#if 0
   // Original non ShuttleGui based code.
   // Layout did not look good on Windows.
   wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
   wxBoxSizer *vSizer = new wxBoxSizer(wxVERTICAL);

   wxBoxSizer *hSizer = new wxBoxSizer(wxHORIZONTAL);

   wxStaticText *statText = new wxStaticText(this, -1, message);
   mainSizer->Add(statText, 0, wxALIGN_LEFT|wxALL, 5);

   wxButton *help = new wxButton(this, wxID_HELP, _("Help"));
   hSizer->Add(help, 0, wxALIGN_LEFT|wxALL, 5);

   wxButton *ok = new wxButton(this, wxID_OK, _("OK"));
   ok->SetDefault();
   ok->SetFocus();
   hSizer->Add(ok, 0, wxALIGN_RIGHT|wxALL, 5);

   vSizer->Add(hSizer, 0, wxALIGN_CENTER|wxALL, 5);

   mainSizer->Add(vSizer, 0, wxALL, 15 );

   SetAutoLayout(true);
   SetSizer(mainSizer);
   mainSizer->Fit(this);
   mainSizer->SetSizeHints(this);
#endif
}