int CVirtualINS::Move() { if( m_bEnd ) return 0; double prevx = m_X; double prevy = m_Y; m_X += m_SpdX; m_Y += m_SpdY; if( m_SpdX && ( prevx - m_End.x ) * ( m_X - m_End.x ) <= 0 || m_SpdY && ( prevy - m_End.y ) * ( m_Y - m_End.y ) <= 0) { if( !m_CurPos ) { m_bEnd = 1; return 1; } PATH* p =(PATH*) m_Path->GetNext( m_CurPos ); CPoint pt = SetGrid( p->start.x , p->start.y ); m_X = pt.x; m_Y = pt.y; m_Start = pt; m_End = SetGrid( p->end.x , p->end.y ); double w = m_End.x - m_Start.x; double h = m_End.y - m_Start.y; double l = sqrt((double)(w*w +h*h)); m_SpdX = m_Speed * w / l; m_SpdY = m_Speed * h / l; } return 0; }
// Reads the points from a file and produces a simple graph. int macro2(){ auto c=new TCanvas();c->SetGrid(); TGraphErrors graph_expected("./macro2_input_expected.txt", "%lg %lg %lg"); graph_expected.SetTitle( "Measurement XYZ and Expectation;" "lenght [cm];" "Arb.Units"); graph_expected.SetFillColor(kYellow); graph_expected.DrawClone("E3AL"); // E3 draws the band TGraphErrors graph("./macro2_input.txt","%lg %lg %lg"); graph.SetMarkerStyle(kCircle); graph.SetFillColor(0); graph.DrawClone("PESame"); // Draw the Legend TLegend leg(.1,.7,.3,.9,"Lab. Lesson 2"); leg.SetFillColor(0); leg.AddEntry(&graph_expected,"Expected Points"); leg.AddEntry(&graph,"Measured Points"); leg.DrawClone("Same"); graph.Print(); return 0; }
// 初始化控件 BOOL CStoreDlg::InitCtrl(void) { //同步数据库存 CStoreQuantityMethod StoreQuantity;//库存盘点统计方法 theApp.GetCurCashier()->DoStoreQuantity(StoreQuantity); if (StoreQuantity.GetStatusCode() == 0) { // 2011/04/27-gxx: 注释掉此行代码://清空所有交易保留的数量 //CIBADAL::GetInstance()->ZeroAllCommodityRemainQuantity(); for (UINT i = 0; i < StoreQuantity.GetRecordCount(); i++) {//更新库存记录(商品编号+ 库存数量) CIBADAL::GetInstance()->UpdateCommodityRemainQuantity(StoreQuantity.GetCommodityCode(i), StoreQuantity.GetRemainQuantity(i)); } } else { ShowToolTip(StoreQuantity.GetStatusMessage(), TRUE); } int index = m_cboSortType.SetCurSel(0); if (!SetGrid(index)) { return FALSE; } return TRUE; }
// Initailizes RDGA stub GaRDGAStub::GaRDGAStub(int populationID, int statisticsID, const Chromosome::GaInitializatorSetup& initializator, const Population::GaPopulationFitnessOperationSetup& fitnessOperation, const Fitness::GaFitnessComparatorSetup& comparator, const Population::GaPopulationParams& populationParameters, const Population::SelectionOperations::GaDuplicatesSelectionParams& selectionParameters, const Chromosome::GaMatingSetup& mating, const Population::CouplingOperations::GaCellularCouplingParams& couplingParameters, const Multiobjective::RDGA::GaRDGAParams& rdgaParameters, const Multiobjective::GaFitnessAdaptiveGrid& grid) : GaBasicStub(populationID, statisticsID) { // stores operations and their parameters SetPopulationParameters( populationParameters ); SetInitializator( initializator ); SetFitnessOperation( fitnessOperation ); SetFitnessComparator( comparator ); SetMating( mating ); SetSelectionParameters( selectionParameters ); SetCouplingParameters( couplingParameters ); SetRDGAParameters( rdgaParameters ); SetGrid( grid ); Clear(); }
void ModelStateDialog::SelectStateModel(const std::string &name) { StateTypeChoice->Enable(); wxString type = stateData[name]["Type"]; if (type == "") { type = "SingleNode"; stateData[name]["Type"] = type; } if (type == "SingleNode") { StateTypeChoice->ChangeSelection(SINGLE_NODE_STATE); std::map<std::string, std::string> &info = stateData[name]; CustomColorSingleNode->SetValue(SetGrid(SingleNodeGrid, info)); } else if (type == "NodeRange") { StateTypeChoice->ChangeSelection(NODE_RANGE_STATE); std::map<std::string, std::string> &info = stateData[name]; CustomColorNodeRanges->SetValue(SetGrid(NodeRangeGrid, info)); } }
void CVirtualINS::Init(CPtrList *path , double spd ) { m_Path = path; m_Speed = spd; m_CurPos = path->GetHeadPosition(); PATH* p =(PATH*) path->GetNext( m_CurPos ); CPoint pt = SetGrid( p->start.x , p->start.y ); m_X = pt.x; m_Y = pt.y; m_Start = pt; m_End = SetGrid( p->end.x , p->end.y ); double w = m_End.x - m_Start.x; double h = m_End.y - m_Start.y; double l = sqrt((double)(w*w +h*h)); m_SpdX = spd * w / l; m_SpdY = spd * h / l; m_bEnd = 0; }
IsGrid(const IsGrid& rhs) : level(rhs.Level()), global(rhs.Global()), local(rhs.Local()), extent(rhs.Extent()), iterators(rhs.Iterators()) { InitIsGrid(); SetGrid(rhs); }
void GRIHist1DGridWidget::AddHist(GRIHistogrammer *h) { // add histogram to list if it is not already there if (!HistIsPresent(h)) { // make a histogram widget GRIHist1DWidget *histWidg = new GRIHist1DWidget(0,h); hist_widget_.append(histWidg); } // Make sure the arrangwment is updated SetGrid(); }
Grid(const Grid& rhs) : index_translations(rhs.Indexing()), level(rhs.Level()), global(rhs.Global()), local(rhs.Local()), extent(rhs.Extent()), iterators(rhs.Iterators()), father(rhs.Father()) { InitGrid(); SetGrid(rhs); }
DesignerWindow::DesignerWindow( wxWindow *parent, int id, const wxPoint& pos, const wxSize &size, long style, const wxString & /*name*/ ) : wxInnerFrame(parent, id, pos, size, style) { ShowTitleBar(false); SetGrid( 10, 10 ); m_selSizer = NULL; m_selItem = NULL; m_actPanel = NULL; SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) ); GetFrameContentPanel()->PushEventHandler(new HighlightPaintHandler(GetFrameContentPanel())); }
void CGridCellBase::operator=(const CGridCellBase& cell) { SetGrid(cell.GetGrid()); // do first in case of dependencies SetText(cell.GetText()); SetImage(cell.GetImage()); SetData(cell.GetData()); SetState(cell.GetState()); SetFormat(cell.GetFormat()); SetTextClr(cell.GetTextClr()); SetBackClr(cell.GetBackClr()); SetFont(cell.IsDefaultFont()? NULL : cell.GetFont()); SetMargin(cell.GetMargin()); }
void IconPanel::ApplySkin() { LoadImage(FilePaths::GetSkinDirectory() + _T("/BarInnerPanel.png")); SetGrid(Styles::InnerPanel.ScaleGrid); browseButton_->LoadImage(FilePaths::GetSkinDirectory() + _T("/BrowseArrowButton")); browseButton_->FitToImage(); for (int i = 0; i < folderItemRenderers_.size(); i++) { FolderItemRenderer* renderer = folderItemRenderers_.at(i); renderer->ApplySkin(); } InvalidateLayout(); }
void NPC::MoveTo(float mtx, float mty, float mtz, float mth, bool saveguardspot) { // makes mob walk to specified location if (IsNPC() && GetGrid() != 0) { // he is on a grid if (GetGrid() < 0) { // currently stopped by a quest command SetGrid( 0 - GetGrid()); // get him moving again mlog(AI__WAYPOINTS, "MoveTo during quest wandering. Canceling quest wandering and going back to grid %d when MoveTo is done.", GetGrid()); } AIwalking_timer->Disable(); // disable timer in case he is paused at a wp if (cur_wp>=0) { // we've not already done a MoveTo() save_wp=cur_wp; // save the current waypoint cur_wp=-1; // flag this move as quest controlled } mlog(AI__WAYPOINTS, "MoveTo (%.3f, %.3f, %.3f), pausing regular grid wandering. Grid %d, save_wp %d", mtx, mty, mtz, -GetGrid(), save_wp); } else { // not on a grid roamer=true; save_wp=0; cur_wp=-2; // flag as quest controlled w/no grid mlog(AI__WAYPOINTS, "MoveTo (%.3f, %.3f, %.3f) without a grid.", mtx, mty, mtz); } if (saveguardspot) { guard_x = mtx; guard_y = mty; guard_z = mtz; guard_heading = mth; if(guard_heading == 0) guard_heading = 0.0001; //hack to make IsGuarding simpler if(guard_heading == -1) guard_heading = this->CalculateHeadingToTarget(mtx, mty); mlog(AI__WAYPOINTS, "Setting guard position to (%.3f, %.3f, %.3f)", guard_x, guard_y, guard_z); } cur_wp_x = mtx; cur_wp_y = mty; cur_wp_z = mtz; cur_wp_pause = 0; cur_wp_heading = mth; pLastFightingDelayMoving = 0; if(AIwalking_timer->Enabled()) AIwalking_timer->Start(100); }
GBR_SCREEN::GBR_SCREEN( const wxSize& aPageSizeIU ) : BASE_SCREEN( SCREEN_T ) { for( unsigned i = 0; i < DIM( gbrZoomList ); ++i ) m_ZoomList.push_back( gbrZoomList[i] ); for( unsigned i = 0; i < DIM( gbrGridList ); ++i ) AddGrid( gbrGridList[i] ); // Set the working grid size to a reasonable value (in 1/10000 inch) SetGrid( DMIL_GRID( 500 ) ); m_Active_Layer = B_Cu; // default active layer = bottom layer SetZoom( ZOOM_FACTOR( 350 ) ); // a default value for zoom InitDataPoints( aPageSizeIU ); }
void NPC::ResumeWandering() { // causes wandering to continue - overrides waypoint pause timer and PauseWandering() if(!IsNPC()) return; if (GetGrid() != 0) { if (GetGrid() < 0) { // we were paused by a quest AIwalking_timer->Disable(); SetGrid( 0 - GetGrid()); if (cur_wp==-1) { // got here by a MoveTo() cur_wp=save_wp; UpdateWaypoint(cur_wp); // have him head to last destination from here } Log.Out(Logs::Detail, Logs::Pathing, "Resume Wandering requested. Grid %d, wp %d", GetGrid(), cur_wp); } else if (AIwalking_timer->Enabled()) { // we are at a waypoint paused normally Log.Out(Logs::Detail, Logs::Pathing, "Resume Wandering on timed pause. Grid %d, wp %d", GetGrid(), cur_wp); AIwalking_timer->Trigger(); // disable timer to end pause now } else { Log.Out(Logs::General, Logs::Error, "NPC not paused - can't resume wandering: %lu", (unsigned long)GetNPCTypeID()); return; } if (m_CurrentWayPoint.x == GetX() && m_CurrentWayPoint.y == GetY()) { // are we we at a waypoint? if so, trigger event and start to next char temp[100]; itoa(cur_wp,temp,10); //do this before updating to next waypoint CalculateNewWaypoint(); SetAppearance(eaStanding, false); parse->EventNPC(EVENT_WAYPOINT_DEPART, this, nullptr, temp, 0); } // if not currently at a waypoint, we continue on to the one we were headed to before the stop } else { Log.Out(Logs::General, Logs::Error, "NPC not on grid - can't resume wandering: %lu", (unsigned long)GetNPCTypeID()); } return; }
void NPC::MoveTo(const glm::vec4& position, bool saveguardspot) { // makes mob walk to specified location if (IsNPC() && GetGrid() != 0) { // he is on a grid if (GetGrid() < 0) { // currently stopped by a quest command SetGrid( 0 - GetGrid()); // get him moving again Log.Out(Logs::Detail, Logs::AI, "MoveTo during quest wandering. Canceling quest wandering and going back to grid %d when MoveTo is done.", GetGrid()); } AIwalking_timer->Disable(); // disable timer in case he is paused at a wp if (cur_wp>=0) { // we've not already done a MoveTo() save_wp=cur_wp; // save the current waypoint cur_wp=-1; // flag this move as quest controlled } Log.Out(Logs::Detail, Logs::AI, "MoveTo %s, pausing regular grid wandering. Grid %d, save_wp %d",to_string(static_cast<glm::vec3>(position)).c_str(), -GetGrid(), save_wp); } else { // not on a grid roamer=true; save_wp=0; cur_wp=-2; // flag as quest controlled w/no grid Log.Out(Logs::Detail, Logs::AI, "MoveTo %s without a grid.", to_string(static_cast<glm::vec3>(position)).c_str()); } if (saveguardspot) { m_GuardPoint = position; if(m_GuardPoint.w == 0) m_GuardPoint.w = 0.0001; //hack to make IsGuarding simpler if(m_GuardPoint.w == -1) m_GuardPoint.w = this->CalculateHeadingToTarget(position.x, position.y); Log.Out(Logs::Detail, Logs::AI, "Setting guard position to %s", to_string(static_cast<glm::vec3>(m_GuardPoint)).c_str()); } m_CurrentWayPoint = position; cur_wp_pause = 0; pLastFightingDelayMoving = 0; if(AIwalking_timer->Enabled()) AIwalking_timer->Start(100); }
IsGrid<T>& IsGrid<T>::operator=(const IsGrid<T>& rhs) { if (this != &rhs) { global = rhs.Global(); local = rhs.Local(); extent = rhs.Extent(); iterators = rhs.Iterators(); level = rhs.Level(); delete [] grid; grid = new T[local.SizeTotal().Product()]; SetGrid(rhs); } return *this; }
void AxisAttributes::SetFromNode(DataNode *parentNode) { if(parentNode == 0) return; DataNode *searchNode = parentNode->GetNode("AxisAttributes"); if(searchNode == 0) return; DataNode *node; if((node = searchNode->GetNode("title")) != 0) title.SetFromNode(node); if((node = searchNode->GetNode("label")) != 0) label.SetFromNode(node); if((node = searchNode->GetNode("tickMarks")) != 0) tickMarks.SetFromNode(node); if((node = searchNode->GetNode("grid")) != 0) SetGrid(node->AsBool()); }
PL_EDITOR_SCREEN::PL_EDITOR_SCREEN( const wxSize& aPageSizeIU ) : BASE_SCREEN( SCREEN_T ) { for( unsigned i = 0; i < DIM( pl_editorZoomList ); ++i ) m_ZoomList.push_back( pl_editorZoomList[i] ); for( unsigned i = 0; i < DIM( pl_editorGridList ); ++i ) AddGrid( pl_editorGridList[i] ); // pl_editor uses the same frame position as schematic and board editors m_Center = false; // Set the working grid size to a reasonable value SetGrid( MM_GRID( 1.0 ) ); SetZoom( ZOOM_FACTOR( 350 ) ); // a default value for zoom InitDataPoints( aPageSizeIU ); m_NumberOfScreens = 2; }
void CGridCellBase::operator=( CGridCellBase& cell) { if (this == &cell) return; SetGrid(cell.GetGrid()); // do first in case of dependencies SetText(cell.GetText()); SetImage(cell.GetImage()); SetData(cell.GetData()); SetState(cell.GetState()); SetFormat(cell.GetFormat()); SetTextClr(cell.GetTextClr()); SetBackClr(cell.GetBackClr()); SetFont(cell.IsDefaultFont()? NULL : cell.GetFont()); SetMargin(cell.GetMargin()); //Used for merge cells //by Huang Wei SetMergeCellID(cell.GetMergeCellID()); SetMergeRange(cell.GetMergeRange()); Show(cell.IsShow()); }
SCH_SCREEN::SCH_SCREEN( KIWAY* aKiway ) : BASE_SCREEN( SCH_SCREEN_T ), KIWAY_HOLDER( aKiway ), m_paper( wxT( "A4" ) ) { SetZoom( 32 ); for( unsigned i = 0; i < DIM( SchematicZoomList ); i++ ) m_ZoomList.push_back( SchematicZoomList[i] ); for( unsigned i = 0; i < DIM( SchematicGridList ); i++ ) AddGrid( SchematicGridList[i] ); SetGrid( wxRealPoint( 50, 50 ) ); // Default grid size. m_refCount = 0; // Suitable for schematic only. For libedit and viewlib, must be set to true m_Center = false; InitDataPoints( m_paper.GetSizeIU() ); }
SCH_SCREEN::SCH_SCREEN() : BASE_SCREEN( SCH_SCREEN_T ), m_paper( wxT( "A4" ) ) { size_t i; SetZoom( 32 ); for( i = 0; i < SCHEMATIC_ZOOM_LIST_CNT; i++ ) m_ZoomList.push_back( SchematicZoomList[i] ); for( i = 0; i < SCHEMATIC_GRID_LIST_CNT; i++ ) AddGrid( SchematicGridList[i] ); SetGrid( wxRealPoint( 50, 50 ) ); // Default grid size. m_refCount = 0; // Suitable for schematic only. For libedit and viewlib, must be set to true m_Center = false; InitDataPoints( m_paper.GetSizeIU() ); }
void NPC::PauseWandering(int pausetime) { // causes wandering to stop but is resumable // 0 pausetime means pause until resumed // otherwise automatically resume when time is up if (GetGrid() != 0) { DistractedFromGrid = true; Log.Out(Logs::Detail, Logs::Pathing, "Paused Wandering requested. Grid %d. Resuming in %d ms (0=not until told)", GetGrid(), pausetime); SendPosition(); if (pausetime<1) { // negative grid number stops him dead in his tracks until ResumeWandering() SetGrid( 0 - GetGrid()); } else { // specified waiting time, he'll resume after that AIwalking_timer->Start(pausetime*1000); // set the timer } } else { Log.Out(Logs::General, Logs::Error, "NPC not on grid - can't pause wandering: %lu", (unsigned long)GetNPCTypeID()); } return; }
PCB_SCREEN::PCB_SCREEN( const wxSize& aPageSizeIU ) : BASE_SCREEN( SCREEN_T ) { // D(wxSize displayz = wxGetDisplaySize();) // D(printf( "displayz x:%d y:%d lastZoomFactor: %.16g\n", displayz.x, displayz.y, pcbZoomList[DIM(pcbZoomList)-1] );) for( unsigned i = 0; i < DIM( pcbZoomList ); ++i ) m_ZoomList.push_back( pcbZoomList[i] ); for( unsigned i = 0; i < DIM( pcbGridList ); ++i ) AddGrid( pcbGridList[i] ); // Set the working grid size to a reasonable value (in 1/10000 inch) SetGrid( DMIL_GRID( 500 ) ); m_Active_Layer = F_Cu; // default active layer = front layer m_Route_Layer_TOP = F_Cu; // default layers pair for vias (bottom to top) m_Route_Layer_BOTTOM = B_Cu; SetZoom( DEFAULT_ZOOM ); // a default value for zoom InitDataPoints( aPageSizeIU ); }
//________________________________________________________________ Bool_t KVCanvas::HandleKey(Int_t , Int_t py) { // Handle keys // Info("HandleKey","key pressed : %d %d",px,py); TObject* obj = 0; TIter next(GetListOfPrimitives()); if (!fEnabledShortcuts) return kTRUE; if (fSelected->InheritsFrom("TFrame")) fSelected = FindHisto(); if (fSelected->InheritsFrom("TH2")) fSelected = FindHisto(); if (!fSelected) return kTRUE; switch ((EKeySym)py) { case kKey_F1: break; case kKey_F2: break; case kKey_F3: break; case kKey_F4: break; case kKey_F5: break; case kKey_F6: break; case kKey_F7: break; case kKey_F8: break; case kKey_F9: SetLogx(!fLogx); Modified(); Update(); break; case kKey_F10: SetLogy(!fLogy); Modified(); Update(); break; case kKey_F11: SetLogz(!fLogz); Modified(); Update(); break; case kKey_F12: if (fSelected->InheritsFrom("TH1")) { gPad->cd(); ((TH1*)fSelected)->GetXaxis()->UnZoom(); ((TH1*)fSelected)->GetYaxis()->UnZoom(); Modified(); Update(); } else if (fSelected->InheritsFrom("TAxis")) { ((TAxis*)fSelected)->UnZoom(); Modified(); Update(); } break; case kKey_a: break; case kKey_b: break; case kKey_c: if (gCopyObject) { gCopyObject->Delete(); gCopyObject = 0; } if (fSelected) gCopyObject = fSelected->Clone(); // gCopyObject = fSelected; break; case kKey_d: if (fSelected->InheritsFrom("TF1")) { TH1* hh = 0; if ((hh = FindHisto())) hh->GetListOfFunctions()->Remove(fSelected); } else GetListOfPrimitives()->Remove(fSelected); Modified(); Update(); break; case kKey_e: GetCanvasImp()->ShowEditor(!GetCanvasImp()->HasEditor()); break; case kKey_f: if (fSelected->InheritsFrom("TH1"))((TH1*)fSelected)->FitPanel(); break; case kKey_g: if (GetGridx() && GetGridy()) { SetGrid(0, 0); while ((obj = next())) { if (obj->InheritsFrom(TPad::Class())) { ((TPad*)obj)->SetGrid(0, 0); } } } else { SetGrid(); while ((obj = next())) { if (obj->InheritsFrom(TPad::Class())) { ((TPad*)obj)->SetGrid(); } } } Modified(); Update(); break; case kKey_i: ShowShortcutsInfos(); break; case kKey_j: fJPressed = kTRUE; return kTRUE; break; case kKey_l: if (fSelected->InheritsFrom("TH2")) SetLogz(!fLogz); else if (fSelected->InheritsFrom("TH1")) SetLogy(!fLogy); Modified(); Update(); break; case kKey_n: if (fSelected->InheritsFrom("TH1")) { ((TH1*)fSelected)->Sumw2(); ((TH1*)fSelected)->Scale(1. / ((TH1*)fSelected)->Integral()); } Modified(); Update(); break; case kKey_p: fPPressed = kTRUE; return kTRUE; break; // case kKey_q: // Close(); // return kTRUE; // break; case kKey_r: if (ExpandFunctionRange()) { Modified(); Update(); } break; case kKey_s: SaveCanvasAs(); break; case kKey_t: break; case kKey_u: Modified(); Update(); break; case kKey_v: if (gCopyObject) { cd(); Modified(); Update(); TString option = ""; if (FindHisto()) option += "same"; gCopyObject->Draw(option.Data()); Modified(); Update(); gCopyObject = 0; } break; case kKey_w: fAgeOfEmpire = !fAgeOfEmpire; break; case kKey_x: if (fPPressed && fSelected->InheritsFrom("TH2")) ProfileX((TH2*)fSelected); if (fJPressed && fSelected->InheritsFrom("TH2")) ProjectionX((TH2*)fSelected); if (!fPPressed && !fJPressed) { gCopyObject = fSelected; GetListOfPrimitives()->Remove(gCopyObject); Modified(); Update(); } break; case kKey_y: if (fPPressed && fSelected->InheritsFrom("TH2")) ProfileY((TH2*)fSelected); if (fJPressed && fSelected->InheritsFrom("TH2")) ProjectionY((TH2*)fSelected); break; case kKey_Left: if (fSelected->InheritsFrom("TAxis")) MoveAxis((TAxis*)fSelected, -1); else if (fSelected->InheritsFrom("TH1")) MoveAxis(FindHisto()->GetXaxis(), -1); break; case kKey_Down: if (fSelected->InheritsFrom("TAxis")) MoveAxis((TAxis*)fSelected, -1); else if (fSelected->InheritsFrom("TH1")) MoveAxis(FindHisto()->GetYaxis(), -1); break; case kKey_Right: if (fSelected->InheritsFrom("TAxis")) MoveAxis((TAxis*)fSelected, 1); else if (fSelected->InheritsFrom("TH1")) MoveAxis(FindHisto()->GetXaxis(), 1); break; case kKey_Up: if (fSelected->InheritsFrom("TAxis")) MoveAxis((TAxis*)fSelected, 1); else if (fSelected->InheritsFrom("TH1")) MoveAxis(FindHisto()->GetYaxis(), 1); break; case kKey_Plus: if (fSelected->InheritsFrom("TH2")) { ((TH2*)fSelected)->SetMinimum(((TH1*)fSelected)->GetMinimum() + 1); Modified(); Update(); } else if (fSelected->InheritsFrom("TF1")) { ((TF1*)fSelected)->SetNpx(((TF1*)fSelected)->GetNpx() + 50); Modified(); Update(); } else if (fSelected->InheritsFrom("TH1")) { TObject* obj = 0; TIter it(((TH1*)fSelected)->GetListOfFunctions()); while ((obj = it())) { ((TF1*)obj)->SetNpx(((TF1*)obj)->GetNpx() + 50); } Modified(); Update(); } break; case kKey_Minus: if (fSelected->InheritsFrom("TH2")) { if (((TH1*)fSelected)->GetMinimum() > 0)((TH2*)fSelected)->SetMinimum(((TH1*)fSelected)->GetMinimum() - 1); Modified(); Update(); } else if (fSelected->InheritsFrom("TF1")) { ((TF1*)fSelected)->SetNpx(((TF1*)fSelected)->GetNpx() - 50); Modified(); Update(); } else if (fSelected->InheritsFrom("TH1")) { TObject* obj = 0; TIter it(((TH1*)fSelected)->GetListOfFunctions()); while ((obj = it()))((TF1*)obj)->SetNpx(((TF1*)obj)->GetNpx() - 50); Modified(); Update(); } break; case kKey_Space: break; default: fPPressed = kFALSE; fJPressed = kFALSE; return kTRUE; } fPPressed = kFALSE; fJPressed = kFALSE; return kTRUE; }
// Load the grid from file, returning true if an error occurred with the error reason appended to the buffer bool HeightMap::LoadFromFile(FileStore *f, StringRef& r) { const size_t MaxLineLength = (MaxXGridPoints * 8) + 2; // maximum length of a line in the height map file, need 8 characters per grid point const char* const readFailureText = "failed to read line from file"; char buffer[MaxLineLength + 1]; StringRef s(buffer, ARRAY_SIZE(buffer)); ClearGridHeights(); GridDefinition newGrid; if (f->ReadLine(buffer, sizeof(buffer)) <= 0) { r.cat(readFailureText); } else if (!StringStartsWith(buffer, HeightMapComment)) // check the version line is as expected { r.cat("bad header line or wrong version header"); } else if (f->ReadLine(buffer, sizeof(buffer)) <= 0) { r.cat(readFailureText); } else if (!GridDefinition::CheckHeading(s)) // check the label line is as expected { r.cat("bad label line"); } else if (f->ReadLine(buffer, sizeof(buffer)) <= 0) // read the height map parameters { r.cat(readFailureText); } else if (!newGrid.ReadParameters(s)) { r.cat("failed to parse grid parameters"); } else if (!newGrid.IsValid()) { r.cat("invalid grid"); } else { SetGrid(newGrid); for (uint32_t row = 0; row < def.numY; ++row) // read the grid a row at a time { if (f->ReadLine(buffer, sizeof(buffer)) <= 0) { r.cat(readFailureText); return true; // failed to read a line } const char *p = buffer; for (uint32_t col = 0; col < def.numX; ++col) { if (*p == '0' && (p[1] == ',' || p[1] == 0)) { // Values of 0 with no decimal places in un-probed values, so leave the point set as not valid ++p; } else { char* np = nullptr; const float f = strtod(p, &np); if (np == p) { r.catf("number expected at line %u column %d", row + 3, (p - buffer) + 1); return true; // failed to read a number } SetGridHeight(col, row, f); p = np; } if (*p == ',') { ++p; } } } ExtrapolateMissing(); return false; // success! } return true; // an error occurred }
void pull( int n_toys = 10000, int n_tot_entries = 100, int nbins = 40, bool do_chi2=true ){ TString method_prefix("Log-Likelihood "); if (do_chi2) method_prefix="#chi^{2} "; // Create histo TH1F h4(method_prefix+"h4", method_prefix+" Random Gauss", nbins,-4,4); h4.SetMarkerStyle(21); h4.SetMarkerSize(0.8); h4.SetMarkerColor(kRed); // Histogram for sigma and pull TH1F sigma(method_prefix+"sigma", method_prefix+"sigma from gaus fit", 50,0.5,1.5); TH1F pull(method_prefix+"pull", method_prefix+"pull from gaus fit", 50,-4.,4.); // Make nice canvases auto c0 = new TCanvas(method_prefix+"Gauss", method_prefix+"Gauss",0,0,320,240); c0->SetGrid(); // Make nice canvases auto c1 = new TCanvas(method_prefix+"Result", method_prefix+"Sigma-Distribution", 0,300,600,400); c0->cd(); float sig, mean; for (int i=0; i<n_toys; i++){ // Reset histo contents h4.Reset(); // Fill histo for ( int j = 0; j<n_tot_entries; j++ ) h4.Fill(gRandom->Gaus()); // perform fit if (do_chi2) h4.Fit("gaus","q"); // Chi2 fit else h4.Fit("gaus","lq"); // Likelihood fit // some control output on the way if (!(i%100)){ h4.Draw("ep"); c0->Update();} // Get sigma from fit TF1 *fit = h4.GetFunction("gaus"); sig = fit->GetParameter(2); mean= fit->GetParameter(1); sigma.Fill(sig); pull.Fill(mean/sig * sqrt(n_tot_entries)); } // end of toy MC loop // print result c1->cd(); pull.DrawClone(); }
void ImageButton::SetGrid(const wxRect& rect) { SetGrid(rect.GetLeft(), rect.GetTop(), rect.GetWidth(), rect.GetHeight()); }
void CPaymentHistory::fnInitPaymentHistoryDT_Bidi() { char GridDataHead[11][30]; Setfont(IDC_BUTTON_PMT_OK); char sBillRefResets[50]; strcpy(sBillRefResets,resobj.LoadString(IDS_BILL_REF_RESETS)); strcpy(GridDataHead[0],resobj.LoadString(IDS_WRITE_OFF_ID)); strcpy(GridDataHead[1],resobj.LoadString(IDS_BILL_REF_NO)); strcpy(GridDataHead[2],sBillRefResets); strcpy(GridDataHead[3],resobj.LoadString(IDS_TYPE)); strcpy(GridDataHead[4],resobj.LoadString(IDS_AMOUNT)); //strcpy(GridDataHead[5],resobj.LoadString(IDS_DATE)); strcpy(GridDataHead[5],"Charge Date"); strcpy(GridDataHead[6],"Transaction Date"); strcpy(GridDataHead[7],"Payment Source"); strcpy(GridDataHead[8],"Balance"); strcpy(GridDataHead[9],"date in int"); strcpy(GridDataHead[10],"amountinlong"); char *GridDataName[] = { "WriteOffId.", "BillRefNo", "BillRefResets", "WriteOffTypecode", "Amount", "Charge Date", "Transaction Date", "Payment Source", "WriteOff Balance", "dateinint", "amountinlong", }; int GridDataLen[] = { 0, 0, 0, GAL_ARMGUI_DISPLAY_VALUE_LEN, ABP_MONEY_LEN, ABP_DATE_LEN, ABP_DATE_LEN, GAL_ARMGUI_DISPLAY_VALUE_LEN, //NEED TO CONFIRM ABP_MONEY_LEN, 0, 0, }; int GridDataWidth[] = { (strlen(GridDataHead[0]) * 3), (strlen(GridDataHead[1]) * 3), (strlen(GridDataHead[2]) * 3), (ABP_DESCR_DU), (ABP_MONEY_DU), (ABP_DATE_DU), (ABP_DATE_DU), (ABP_DESCR_DU), (ABP_MONEY_DU), (ABP_DESCR_DU), (ABP_DESCR_DU) }; m_pPaymentHistoryDT = (CDataTbl*)GetDlgItem(IDC_PAYMENT_HISTORY); m_pPaymentHistoryDT->SetWndStyle(ABP_DATA_TABLE_WND_STYLE_01|DTS_ROWBUTTONS|WS_TABSTOP); m_pPaymentHistoryDT->SetExtWndStyle(ABP_DATA_TABLE_EXT_WND_STYLE_01); int nCols = 11; m_pPaymentHistoryDT->Set3dEffect(DT3D_LIGHTINDENT); // 3d effect indent frame m_pPaymentHistoryDT->SetColWidth(DTPOS_LABELS,(DWORD)(10)); m_pPaymentHistoryDT->SetColCount(nCols); // there are 3 columns // there are 3 columns for(int i=11,j=11;i>0;i--,j--) { switch(i) { case 0: case 1: case 2: case 9: case 10: SetGrid(m_pPaymentHistoryDT,i,GridDataHead[i],GridDataName[i],DTT_INT4,GridDataLen[i],GridDataWidth[i]); break; case 4: case 8: SetGrid(m_pPaymentHistoryDT,i,GridDataHead[i],GridDataName[i],DTT_KENANMONEY,GridDataLen[i],GridDataWidth[i]); break; case 5: case 6: SetGrid(m_pPaymentHistoryDT,i,GridDataHead[i],GridDataName[i],DTT_CDATETIME,GridDataLen[i], GridDataWidth[i]); break; case 3: case 7: default: SetGrid(m_pPaymentHistoryDT,i,GridDataHead[i],GridDataName[i],DTT_ZSTRING,GridDataLen[i],GridDataWidth[i]); } } m_pPaymentHistoryDT->SetAccessPos(1,DTPOS_HEADINGS); m_pPaymentHistoryDT->SetColStyle(9,DTCS_HEADCENTER | DTCS_CENTER| DTCS_SORTASC | DTCS_HIDDEN); m_pPaymentHistoryDT->SetColStyle(10,DTCS_HEADCENTER | DTCS_CENTER | DTCS_HIDDEN); m_pPaymentHistoryDT->SetColStyle(5,DTCS_HEADCENTER | DTCS_CENTER); m_pPaymentHistoryDT->SetColStyle(6,DTCS_HEADCENTER | DTCS_CENTER); m_pPaymentHistoryDT->SetColStyle(4,DTCS_HEADCENTER | DTCS_RIGHT); m_pPaymentHistoryDT->SetColStyle(8,DTCS_HEADCENTER | DTCS_RIGHT); DTCOLORSTRUCT ColorStruct; ColorStruct.BkgrdColor = ::GetSysColor(COLOR_INACTIVECAPTION); ColorStruct.TextColor = ::GetSysColor(COLOR_INACTIVECAPTIONTEXT); ColorStruct.SelBkgrdColor = DEFAULTCOLOR; ColorStruct.SelTextColor = DEFAULTCOLOR; m_pPaymentHistoryDT->SetAccessPos (0, DTPOS_HEADINGS); LOGFONT lf; CFont *font = GetDlgItem(IDC_BUTTON_PMT_OK)->GetFont(); if (font) { font->GetLogFont(&lf); } lf.lfWeight = 700; m_pPaymentHistoryDT->SetDTFont(&lf); return; }
void NPC::AssignWaypoints(int32 grid) { if (grid == 0) return; // grid ID 0 not supported if (grid < 0) { // Allow setting negative grid values for pausing pathing this->CastToNPC()->SetGrid(grid); return; } Waypoints.clear(); roamer = false; // Retrieve the wander and pause types for this grid std::string query = StringFormat("SELECT `type`, `type2` FROM `grid` WHERE `id` = %i AND `zoneid` = %i", grid, zone->GetZoneID()); auto results = database.QueryDatabase(query); if (!results.Success()) { return; } if (results.RowCount() == 0) return; auto row = results.begin(); wandertype = atoi(row[0]); pausetype = atoi(row[1]); SetGrid(grid); // Assign grid number // Retrieve all waypoints for this grid query = StringFormat("SELECT `x`,`y`,`z`,`pause`,`heading` " "FROM grid_entries WHERE `gridid` = %i AND `zoneid` = %i " "ORDER BY `number`", grid, zone->GetZoneID()); results = database.QueryDatabase(query); if (!results.Success()) { return; } roamer = true; max_wp = 0; // Initialize it; will increment it for each waypoint successfully added to the list for (auto row = results.begin(); row != results.end(); ++row, ++max_wp) { wplist newwp; newwp.index = max_wp; newwp.x = atof(row[0]); newwp.y = atof(row[1]); newwp.z = atof(row[2]); if(zone->HasMap() && RuleB(Map, FixPathingZWhenLoading) ) { auto positon = glm::vec3(newwp.x,newwp.y,newwp.z); if(!RuleB(Watermap, CheckWaypointsInWaterWhenLoading) || !zone->HasWaterMap() || (zone->HasWaterMap() && !zone->watermap->InWater(positon))) { glm::vec3 dest(newwp.x, newwp.y, newwp.z); float newz = zone->zonemap->FindBestZ(dest, nullptr); if ((newz > -2000) && std::abs(newz - dest.z) < RuleR(Map, FixPathingZMaxDeltaLoading)) newwp.z = newz + 1; } } newwp.pause = atoi(row[3]); newwp.heading = atof(row[4]); Waypoints.push_back(newwp); } UpdateWaypoint(0); SetWaypointPause(); if (wandertype == 1 || wandertype == 2 || wandertype == 5) CalculateNewWaypoint(); if (wandertype == 1 || wandertype == 2 || wandertype == 5) CalculateNewWaypoint(); }