wxSize wxRadioButton::DoGetBestSize() const { static int s_radioSize = 0; if ( !s_radioSize ) { wxScreenDC dc; dc.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); s_radioSize = dc.GetCharHeight(); // radio button bitmap size under CE is bigger than the font height, // adding just one pixel seems to work fine for the default font but it // would be nice to find some better way to find the correct height #ifdef __WXWINCE__ s_radioSize++; #endif // __WXWINCE__ } wxString str = GetLabel(); int wRadio, hRadio; if ( !str.empty() ) { GetTextExtent(GetLabelText(str), &wRadio, &hRadio); wRadio += s_radioSize + GetCharWidth(); if ( hRadio < s_radioSize ) hRadio = s_radioSize; } else { wRadio = s_radioSize; hRadio = s_radioSize; } wxSize best(wRadio, hRadio); CacheBestSize(best); return best; }
wxSize wxButton::OldGetBestSize() const { Dimension xmargin, ymargin, highlight, shadow, defThickness; XtVaGetValues( (Widget)m_mainWidget, XmNmarginWidth, &xmargin, XmNmarginHeight, &ymargin, XmNhighlightThickness, &highlight, XmNshadowThickness, &shadow, XmNdefaultButtonShadowThickness, &defThickness, NULL ); int x = 0; int y = 0; GetTextExtent( GetLabel(), &x, &y ); int margin = highlight * 2 + ( defThickness ? ( ( shadow + defThickness ) * 4 ) : ( shadow * 2 ) ); wxSize best( x + xmargin * 2 + margin, y + ymargin * 2 + margin ); // all buttons have at least the standard size unless the user explicitly // wants them to be of smaller size and used wxBU_EXACTFIT style when // creating the button if( !HasFlag( wxBU_EXACTFIT ) ) { wxSize def = GetDefaultSize(); int margin = highlight * 2 + ( defThickness ? ( shadow * 4 + defThickness * 4 ) : 0 ); def.x += margin; def.y += margin; if( def.x > best.x ) best.x = def.x; if( def.y > best.y ) best.y = def.y; } return best; }
void StatGetter::GetStatsForPath(const QString& rootPath) { pathInWork_ = rootPath; assert(!pathInWork_.isEmpty()); if (IsRunning()) { RiseRunningThreadWarningMsg(); return; } statTree_.clear(); subdirsInCurPathCount_ = 0; StatsCont cont {statTree_, subdirsInCurPathCount_}; currentThreadClass_.reset(new StatGetterThread(rootPath, cont, GetProgBar(), GetLabel()) ); connect(&GetWorkerThread(), SIGNAL(started()), currentThreadClass_.data(), SLOT(onStart())); RunThread(currentThreadClass_.data()); }
void HTMLTrackElement::CreateTextTrack() { nsString label, srcLang; GetSrclang(srcLang); GetLabel(label); TextTrackKind kind; if (const nsAttrValue* value = GetParsedAttr(nsGkAtoms::kind)) { kind = static_cast<TextTrackKind>(value->GetEnumValue()); } else { kind = TextTrackKind::Subtitles; } mTrack = new TextTrack(OwnerDoc()->GetParentObject(), kind, label, srcLang, TextTrackMode::Disabled, TextTrackSource::Track); mTrack->SetTrackElement(this); if (mMediaParent) { mMediaParent->AddTextTrack(mTrack); } }
static PyObject *Icn_GetLabel(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; OSErr _err; SInt16 labelNumber; RGBColor labelColor; Str255 labelString; #ifndef GetLabel PyMac_PRECHECK(GetLabel); #endif if (!PyArg_ParseTuple(_args, "hO&", &labelNumber, PyMac_GetStr255, labelString)) return NULL; _err = GetLabel(labelNumber, &labelColor, labelString); if (_err != noErr) return PyMac_Error(_err); _res = Py_BuildValue("O&", QdRGB_New, &labelColor); return _res; }
void ControlToolBar::RegenerateTooltips() { #if wxUSE_TOOLTIPS std::vector<wxString> commands; for (long iWinID = ID_PLAY_BUTTON; iWinID < BUTTON_COUNT; iWinID++) { commands.clear(); auto pCtrl = static_cast<AButton*>(this->FindWindow(iWinID)); commands.push_back(pCtrl->GetLabel()); switch (iWinID) { case ID_PLAY_BUTTON: commands.push_back(wxT("Play")); commands.push_back(_("Loop Play")); commands.push_back(wxT("PlayLooped")); break; case ID_RECORD_BUTTON: commands.push_back(wxT("Record")); commands.push_back(_("Append Record")); commands.push_back(wxT("RecordAppend")); break; case ID_PAUSE_BUTTON: commands.push_back(wxT("Pause")); break; case ID_STOP_BUTTON: commands.push_back(wxT("Stop")); break; case ID_FF_BUTTON: commands.push_back(wxT("SkipEnd")); break; case ID_REW_BUTTON: commands.push_back(wxT("SkipStart")); break; } ToolBar::SetButtonToolTip(*pCtrl, commands); } #endif }
void XmlSettingsDialog::ParsePage (const QDomElement& page) { Titles_ << GetLabel (page); QStringList icons; if (page.hasAttribute ("icon")) icons << page.attribute ("icon"); auto iconElem = page .firstChildElement ("icons") .firstChildElement ("icon"); while (!iconElem.isNull ()) { icons << iconElem.text (); iconElem = iconElem.nextSiblingElement ("icon"); } IconNames_ << icons; const auto baseWidget = new QWidget; Pages_->addWidget (baseWidget); const auto lay = new QGridLayout; lay->setContentsMargins (0, 0, 0, 0); baseWidget->setLayout (lay); ParseEntity (page, baseWidget); bool foundExpanding = false; for (const auto w : baseWidget->findChildren<QWidget*> ()) if (w->sizePolicy ().verticalPolicy () & QSizePolicy::ExpandFlag) { foundExpanding = true; break; } if (!foundExpanding) lay->addItem (new QSpacerItem (0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding), lay->rowCount (), 0, 1, 2); }
CvMat* ShiftMapHierarchy::CalculateLabelMapGuess() { CvMat* output = cvCreateMat(_outputSize.height, _outputSize.width, CV_32SC2); int num_pixels = _outputSize.width * _outputSize.height; printf("Getting label map... \n"); for(int i = 0; i < num_pixels; i++) { int label = _gc->whatLabel(i); CvPoint point = GetPoint(i, _outputSize); CvPoint shift = GetShift(label, _shiftSize); CvPoint guess = GetLabel(point, _initialGuess); CvPoint pointLabel = cvPoint(shift.x + guess.x, shift.y + guess.y); // test //CvPoint mapped = cvPoint(point.x + pointLabel.x, point.y + pointLabel.y); //if(IsOutside(mapped, _inputSize)) // printf("test"); SetLabel(point, pointLabel, output); } return output; }
void SearchTreeNode::Dump(BasicSearchTree* tree, nSearchTreeNode node_id, const wxString& prefix, wxString& result) { wxString suffix(_T("")); suffix << _T("- \"") << SerializeString(GetLabel(tree)) << _T("\" (") << U2S(node_id) << _T(")"); if (prefix.length() && prefix[prefix.length()-1]=='|') result << prefix.substr(0,prefix.length()-1) << _T('+') << suffix << _T('\n'); else if (prefix.length() && prefix[prefix.length()-1]==' ') result << prefix.substr(0,prefix.length()-1) << _T('\\') << suffix << _T('\n'); else result << prefix << suffix << _T('\n'); wxString newprefix(prefix); newprefix.append(suffix.length() - 2, _T(' ')); newprefix << _T("|"); SearchTreeLinkMap::iterator i; unsigned int cnt = 0; for (i = m_Children.begin(); i!= m_Children.end(); i++) { if (cnt == m_Children.size() - 1) newprefix[newprefix.length() - 1] = _T(' '); tree->GetNode(i->second,false)->Dump(tree,i->second,newprefix,result); cnt++; } }
// // Returns the value to be presented to accessibility // // Current, the command and key are both provided. // wxString KeyView::GetValue(int line) { // Make sure line is valid if (line < 0 || line >= (int) mLines.GetCount()) { wxASSERT(false); return wxEmptyString; } // Get the label and key values wxString value; if (mViewType == ViewByTree) { value = GetLabel(LineToIndex(line)); } else { value = GetFullLabel(LineToIndex(line)); } wxString key = GetKey(LineToIndex(line)); // Add the key if it isn't empty if (!key.IsEmpty()) { if (mViewType == ViewByKey) { value = key + wxT(" ") + value; } else { value = value + wxT(" ") + key; } } return value; }
std::ostream& LoadBalanceInverseOperator::Print(std::ostream& os, const bool verbose) const { StackPush(); if (GetMyPID() == 0) { os << "***MLAPI::InverseOperator" << std::endl; os << "Label = " << GetLabel() << std::endl; os << "Number of rows = " << GetRangeSpace().GetNumGlobalElements() << std::endl; os << "Number of columns = " << GetRangeSpace().GetNumGlobalElements() << std::endl; os << "Flop count = " << GetFlops() << std::endl; os << "Cumulative time = " << GetTime() << std::endl; if (GetTime() != 0.0) os << "MFlops rate = " << 1.0e-6 * GetFlops() / GetTime() << std::endl; else os << "MFlops rate = 0.0" << std::endl; os << std::endl; } StackPop(); return(os); }
// wxControl-specific processing after processing the update event void wxControlBase::DoUpdateWindowUI(wxUpdateUIEvent& event) { // call inherited wxWindowBase::DoUpdateWindowUI(event); // update label if ( event.GetSetText() ) { if ( event.GetText() != GetLabel() ) SetLabel(event.GetText()); } // Unfortunately we don't yet have common base class for // wxRadioButton, so we handle updates of radiobuttons here. // TODO: If once wxRadioButtonBase will exist, move this code there. #if wxUSE_RADIOBTN if ( event.GetSetChecked() ) { wxRadioButton *radiobtn = wxDynamicCastThis(wxRadioButton); if ( radiobtn ) radiobtn->SetValue(event.GetChecked()); } #endif // wxUSE_RADIOBTN }
int32_t CPDF_PageLabel::GetPageByLabel(const CFX_ByteStringC& bsLabel) const { if (!m_pDocument) { return -1; } CPDF_Dictionary* pPDFRoot = m_pDocument->GetRoot(); if (!pPDFRoot) { return -1; } int nPages = m_pDocument->GetPageCount(); CFX_ByteString bsLbl; CFX_ByteString bsOrig = bsLabel; for (int i = 0; i < nPages; i++) { bsLbl = PDF_EncodeText(GetLabel(i)); if (!bsLbl.Compare(bsOrig)) { return i; } } bsLbl = bsOrig; int nPage = FXSYS_atoi(bsLbl); if (nPage > 0 && nPage <= nPages) { return nPage; } return -1; }
sf::Vector2f Button::CalculateRequisition() { float padding( Context::Get().GetEngine().GetProperty<float>( "Padding", shared_from_this() ) ); float spacing( Context::Get().GetEngine().GetProperty<float>( "Spacing", shared_from_this() ) ); const std::string& font_name( Context::Get().GetEngine().GetProperty<std::string>( "FontName", shared_from_this() ) ); unsigned int font_size( Context::Get().GetEngine().GetProperty<unsigned int>( "FontSize", shared_from_this() ) ); const sf::Font& font( *Context::Get().GetEngine().GetResourceManager().GetFont( font_name ) ); auto requisition = Context::Get().GetEngine().GetTextMetrics( m_label, font, font_size ); requisition.y = Context::Get().GetEngine().GetFontLineHeight( font, font_size ); requisition.x += 2 * padding; requisition.y += 2 * padding; if( GetChild() ) { requisition.x += GetChild()->GetRequisition().x; requisition.y = std::max( requisition.y, GetChild()->GetRequisition().y + 2 * padding ); if( GetLabel().getSize() > 0 ) { requisition.x += spacing; } } return requisition; }
wxString wxTopLevelWindowMSW::GetTitle() const { return GetLabel(); }
void wxCustomButton::Paint( wxDC &dc ) { #if (wxMINOR_VERSION<8) dc.BeginDrawing(); #endif int w, h; GetSize(&w,&h); wxColour foreColour = GetForegroundColour(); wxColour backColour = GetBackgroundColour(); if (m_focused) { backColour.Set( wxMin(backColour.Red() + 20, 255), wxMin(backColour.Green() + 20, 255), wxMin(backColour.Blue() + 20, 255) ); } wxBitmap bitmap; if (IsEnabled()) { if (GetValue() && m_bmpSelected.Ok()) bitmap = m_bmpSelected; else if (m_focused && m_bmpFocus.Ok()) bitmap = m_bmpFocus; else if (m_bmpLabel.Ok()) bitmap = m_bmpLabel; } else { // try to create disabled if it doesn't exist if (!m_bmpDisabled.Ok() && m_bmpLabel.Ok()) m_bmpDisabled = CreateBitmapDisabled(m_bmpLabel); if (m_bmpDisabled.Ok()) bitmap = m_bmpDisabled; else if (m_bmpLabel.Ok()) bitmap = m_bmpLabel; foreColour = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT); } wxBrush brush(backColour, wxSOLID); dc.SetBackground(brush); dc.SetBrush(brush); dc.SetPen(*wxTRANSPARENT_PEN); dc.DrawRectangle(0, 0, w, h); if (bitmap.Ok()) dc.DrawBitmap(bitmap, m_bitmapPos.x, m_bitmapPos.y, TRUE ); if (!GetLabel().IsEmpty()) { dc.SetFont(GetFont()); dc.SetTextBackground(backColour); dc.SetTextForeground(foreColour); dc.DrawText(GetLabel(), m_labelPos.x, m_labelPos.y); } if (GetValue()) // draw sunken border { dc.SetPen(*wxGREY_PEN); dc.DrawLine(0,h-1,0,0); dc.DrawLine(0,0,w,0); dc.SetPen(*wxWHITE_PEN); dc.DrawLine(w-1,1,w-1,h-1); dc.DrawLine(w-1,h-1,0,h-1); dc.SetPen(*wxBLACK_PEN); dc.DrawLine(1,h-2,1,1); dc.DrawLine(1,1,w-1,1); } else if (((m_button_style & wxCUSTBUT_FLAT) == 0) || m_focused) // draw raised border { dc.SetPen(*wxWHITE_PEN); dc.DrawLine(0,h-2,0,0); dc.DrawLine(0,0,w-1,0); dc.SetPen(*wxBLACK_PEN); dc.DrawLine(w-1,0,w-1,h-1); dc.DrawLine(w-1,h-1,-1,h-1); dc.SetPen(*wxGREY_PEN); dc.DrawLine(2,h-2,w-2,h-2); dc.DrawLine(w-2,h-2,w-2,1); } dc.SetBackground(wxNullBrush); dc.SetBrush(wxNullBrush); dc.SetPen(wxNullPen); #if (wxMINOR_VERSION<8) dc.EndDrawing(); #endif }
bool SCH_SCREEN::IsTerminalPoint( const wxPoint& aPosition, int aLayer ) { wxCHECK_MSG( aLayer == LAYER_NOTES || aLayer == LAYER_BUS || aLayer == LAYER_WIRE, false, wxT( "Invalid layer type passed to SCH_SCREEN::IsTerminalPoint()." ) ); SCH_SHEET_PIN* label; SCH_TEXT* text; switch( aLayer ) { case LAYER_BUS: if( GetBus( aPosition ) ) return true; label = GetSheetLabel( aPosition ); if( label && IsBusLabel( label->GetText() ) && label->IsConnected( aPosition ) ) return true; text = GetLabel( aPosition ); if( text && IsBusLabel( text->GetText() ) && text->IsConnected( aPosition ) && (text->Type() != SCH_LABEL_T) ) return true; break; case LAYER_NOTES: if( GetLine( aPosition ) ) return true; break; case LAYER_WIRE: if( GetItem( aPosition, std::max( GetDefaultLineThickness(), 3 ), SCH_BUS_WIRE_ENTRY_T) ) return true; if( GetItem( aPosition, std::max( GetDefaultLineThickness(), 3 ), SCH_BUS_BUS_ENTRY_T) ) return true; if( GetItem( aPosition, std::max( GetDefaultLineThickness(), 3 ), SCH_JUNCTION_T ) ) return true; if( GetPin( aPosition, NULL, true ) ) return true; if( GetWire( aPosition ) ) return true; text = GetLabel( aPosition ); if( text && text->IsConnected( aPosition ) && !IsBusLabel( text->GetText() ) ) return true; label = GetSheetLabel( aPosition ); if( label && label->IsConnected( aPosition ) && !IsBusLabel( label->GetText() ) ) return true; break; default: break; } return false; }
bool wxCheckBox::MSWOnDraw(WXDRAWITEMSTRUCT *item) { DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)item; if ( !IsOwnerDrawn() || dis->CtlType != ODT_BUTTON ) return wxCheckBoxBase::MSWOnDraw(item); // calculate the rectangles for the check mark itself and the label HDC hdc = dis->hDC; RECT& rect = dis->rcItem; RECT rectCheck, rectLabel; rectCheck.top = rectLabel.top = rect.top; rectCheck.bottom = rectLabel.bottom = rect.bottom; const int checkSize = GetBestSize().y; const int MARGIN = 3; const bool isRightAligned = HasFlag(wxALIGN_RIGHT); if ( isRightAligned ) { rectCheck.right = rect.right; rectCheck.left = rectCheck.right - checkSize; rectLabel.right = rectCheck.left - MARGIN; rectLabel.left = rect.left; } else // normal, left-aligned checkbox { rectCheck.left = rect.left; rectCheck.right = rectCheck.left + checkSize; rectLabel.left = rectCheck.right + MARGIN; rectLabel.right = rect.right; } // show we draw a focus rect? const bool isFocused = m_isPressed || FindFocus() == this; // draw the checkbox itself: note that this should really, really be in // wxRendererNative but unfortunately we can't add a new virtual function // to it without breaking backwards compatibility // classic Win32 version -- this can be useful when we move this into // wxRendererNative #if defined(__WXWINCE__) || !wxUSE_UXTHEME UINT state = DFCS_BUTTONCHECK; if ( !IsEnabled() ) state |= DFCS_INACTIVE; switch ( Get3StateValue() ) { case wxCHK_CHECKED: state |= DFCS_CHECKED; break; case wxCHK_UNDETERMINED: state |= DFCS_PUSHED; break; default: wxFAIL_MSG( _T("unexpected Get3StateValue() return value") ); // fall through case wxCHK_UNCHECKED: // no extra styles needed break; } if ( wxFindWindowAtPoint(wxGetMousePosition()) == this ) state |= DFCS_HOT; if ( !::DrawFrameControl(hdc, &rectCheck, DFC_BUTTON, state) ) { wxLogLastError(_T("DrawFrameControl(DFC_BUTTON)")); } #else // XP version wxUxThemeEngine *themeEngine = wxUxThemeEngine::GetIfActive(); if ( !themeEngine ) return false; wxUxThemeHandle theme(this, L"BUTTON"); if ( !theme ) return false; int state; switch ( Get3StateValue() ) { case wxCHK_CHECKED: state = CBS_CHECKEDNORMAL; break; case wxCHK_UNDETERMINED: state = CBS_MIXEDNORMAL; break; default: wxFAIL_MSG( _T("unexpected Get3StateValue() return value") ); // fall through case wxCHK_UNCHECKED: state = CBS_UNCHECKEDNORMAL; break; } if ( !IsEnabled() ) state += CBS_DISABLED_OFFSET; else if ( m_isPressed ) state += CBS_PRESSED_OFFSET; else if ( m_isHot ) state += CBS_HOT_OFFSET; HRESULT hr = themeEngine->DrawThemeBackground ( theme, hdc, BP_CHECKBOX, state, &rectCheck, NULL ); if ( FAILED(hr) ) { wxLogApiError(_T("DrawThemeBackground(BP_CHECKBOX)"), hr); } #endif // 0/1 // draw the text const wxString& label = GetLabel(); // first we need to measure it UINT fmt = DT_NOCLIP; // drawing underlying doesn't look well with focus rect (and the native // control doesn't do it) if ( isFocused ) fmt |= DT_HIDEPREFIX; if ( isRightAligned ) fmt |= DT_RIGHT; // TODO: also use DT_HIDEPREFIX if the system is configured so // we need to get the label real size first if we have to draw a focus rect // around it if ( isFocused ) { if ( !::DrawText(hdc, label, label.length(), &rectLabel, fmt | DT_CALCRECT) ) { wxLogLastError(_T("DrawText(DT_CALCRECT)")); } } if ( !IsEnabled() ) { ::SetTextColor(hdc, ::GetSysColor(COLOR_GRAYTEXT)); } if ( !::DrawText(hdc, label, label.length(), &rectLabel, fmt) ) { wxLogLastError(_T("DrawText()")); } // finally draw the focus if ( isFocused ) { rectLabel.left--; rectLabel.right++; if ( !::DrawFocusRect(hdc, &rectLabel) ) { wxLogLastError(_T("DrawFocusRect()")); } } return true; }
void wxCustomButton::Paint( wxDC &dc ) { int w, h; GetSize(&w,&h); wxColour foreColour = GetForegroundColour(); wxColour backColour = GetBackgroundColour(); if (m_focused) { backColour.Set( wxMin(backColour.Red() + 20, 255), wxMin(backColour.Green() + 20, 255), wxMin(backColour.Blue() + 20, 255) ); } wxBitmap bitmap; if (IsEnabled()) { if (GetValue() && m_bmpSelected.Ok()) bitmap = m_bmpSelected; else if (m_focused && m_bmpFocus.Ok()) bitmap = m_bmpFocus; else if (m_bmpLabel.Ok()) bitmap = m_bmpLabel; } else { // try to create disabled if it doesn't exist if (!m_bmpDisabled.Ok() && m_bmpLabel.Ok()) m_bmpDisabled = CreateBitmapDisabled(m_bmpLabel); if (m_bmpDisabled.Ok()) bitmap = m_bmpDisabled; else if (m_bmpLabel.Ok()) bitmap = m_bmpLabel; foreColour = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT); } #if wxCHECK_VERSION(2, 8, 0) // wxCONTROL_DISABLED //flags may have the wxCONTROL_PRESSED, wxCONTROL_CURRENT or wxCONTROL_ISDEFAULT int ren_flags = 0; if (GetValue()) ren_flags |= wxCONTROL_PRESSED; if (m_focused) ren_flags |= wxCONTROL_CURRENT; if (!IsEnabled()) ren_flags |= wxCONTROL_DISABLED; wxRendererNative::Get().DrawPushButton(this, dc, wxRect(0, 0, w, h), ren_flags); #else wxBrush brush(backColour, wxSOLID); dc.SetBackground(brush); dc.SetBrush(brush); dc.SetPen(*wxTRANSPARENT_PEN); dc.DrawRectangle(0, 0, w, h); #endif // !wxCHECK_VERSION(2, 8, 0) if (bitmap.Ok()) dc.DrawBitmap(bitmap, m_bitmapPos.x, m_bitmapPos.y, true ); if (!GetLabel().IsEmpty()) { dc.SetFont(GetFont()); dc.SetTextBackground(backColour); dc.SetTextForeground(foreColour); dc.DrawText(GetLabel(), m_labelPos.x, m_labelPos.y); } #if !wxCHECK_VERSION(2, 8, 0) if (GetValue()) // draw sunken border { dc.SetPen(*wxGREY_PEN); dc.DrawLine(0,h-1,0,0); dc.DrawLine(0,0,w,0); dc.SetPen(*wxWHITE_PEN); dc.DrawLine(w-1,1,w-1,h-1); dc.DrawLine(w-1,h-1,0,h-1); dc.SetPen(*wxBLACK_PEN); dc.DrawLine(1,h-2,1,1); dc.DrawLine(1,1,w-1,1); } else if (((m_button_style & wxCUSTBUT_FLAT) == 0) || m_focused) // draw raised border { dc.SetPen(*wxWHITE_PEN); dc.DrawLine(0,h-2,0,0); dc.DrawLine(0,0,w-1,0); dc.SetPen(*wxBLACK_PEN); dc.DrawLine(w-1,0,w-1,h-1); dc.DrawLine(w-1,h-1,-1,h-1); dc.SetPen(*wxGREY_PEN); dc.DrawLine(2,h-2,w-2,h-2); dc.DrawLine(w-2,h-2,w-2,1); } #endif // !wxCHECK_VERSION(2, 8, 0) dc.SetBackground(wxNullBrush); dc.SetBrush(wxNullBrush); dc.SetPen(wxNullPen); }
int ChargedHiggsQCDPurity::analyze(Event*e,string systname) { #ifdef VERBOSE if (VERBOSE >0 ) cout<<"[ChargedHiggsQCDPurity]::[analyze]::[DEBUG1] start analyze event"<<endl; #endif string label = GetLabel(e); // do not distinguish between data and mc, // so we can run closures // Fill Real Iso Tau *t = e->GetTau(0); // Fill Inverted Iso Tau *tInv = e->GetTauInvIso(0); e->ApplyTopReweight(); e->ApplyWReweight(); #ifdef VERBOSE if (VERBOSE >0 ) cout<<"[ChargedHiggsQCDPurity]::[analyze]::[DEBUG1] is Tau? "<< (t==NULL) <<endl; if (VERBOSE >0 ) cout<<"[ChargedHiggsQCDPurity]::[analyze]::[DEBUG1] is TauInv? "<< (tInv == NULL)<<endl; #endif // --- take the selection from the tau nu analysis CutSelector direct; direct.SetMask(ChargedHiggsTauNu::MaxCut-1); direct.SetCut(ChargedHiggsTauNu::Selection(e,true,false,is80X,isLightMass)); CutSelector inverse; inverse.SetMask(ChargedHiggsTauNu::MaxCut-1); inverse.SetCut(ChargedHiggsTauNu::Selection(e,false,false,is80X,isLightMass)); // TODO: // * what do I do with event with a Tau and an Inv tau? -> DY ? // * put a limit on the TauInv sideband ? 3.0 -20 GeV bool passDirectLoose=direct.passAllUpTo(ChargedHiggsTauNu::ThreeJets); bool passInverseLoose=inverse.passAllUpTo(ChargedHiggsTauNu::ThreeJets); // bool passDirectLoose=direct.passAllUpTo(ChargedHiggsTauNu::OneBjet); // bool passInverseLoose=inverse.passAllUpTo(ChargedHiggsTauNu::OneBjet); //#warning QCD BJets //LogN(__FUNCTION__,"WARNING","ONE B REQUIRED FOR QCD LOOSE",10); // check minimal selection: Three bjets if ( not passDirectLoose and not passInverseLoose ) return EVENT_NOT_USED; bool passPrescale=false; if(e->GetWeight()->GetMC().find("ST") != string::npos || e->GetWeight()->GetMC().find("WZ") != string::npos || e->GetWeight()->GetMC().find("WW") != string::npos || e->GetWeight()->GetMC().find("ZZ") != string::npos) { passPrescale=true; // set trigger, but apply SF! // Met SF only for pT > 20 (only for MC) string metLegSF = "metLegData"; if(not e->ExistSF(metLegSF)) Log(__FUNCTION__,"WARING" ,"No Tau metLeg SF"); else if(e->GetMet().Pt()>20 and not e->IsRealData()) { e->SetPtEtaSF(metLegSF, e->GetMet().Pt(), 0); e->ApplySF(metLegSF); } } else { // Apply MET leg SF (only on MC) // NEGLECT IT /* string metLegSF = "metLeg"; if(not e->ExistSF(metLegSF)) Log(__FUNCTION__,"WARING" ,"No Tau metLeg SF"); else if(e->GetMet().Pt()>20 and not e->IsRealData()) { e->SetPtEtaSF(metLegSF, e->GetMet().Pt(), 0); e->ApplySF(metLegSF); } */ if(e->IsTriggered("HLT_LooseIsoPFTau50_Trk30_eta2p1_MET90")) passPrescale=true; } // USE PRESCALE PATH ONLY FOR THE "inclusive/Loose" selection //bool passPrescale=false; //if (not e->IsRealData()) passPrescale=true; //if ( e->IsTriggered("HLT_LooseIsoPFTau50_Trk30_eta2p1_v") ) passPrescale=true; //#warning MET80 TRigger in QCD //if ( e->IsTriggered("HLT_LooseIsoPFTau50_Trk30_eta2p1_MET90") ) passPrescale=true; //LogN(__FUNCTION__,"WARNING","MET 80 in QCD Loose",10); // //bool passMatchDirect=true; //bool passMatchInverse=true; #warning Tau Match bool passMatchDirect=false; bool passMatchInverse=false; if (e->IsRealData()) { passMatchDirect=true; passMatchInverse=true;} else { if (e->GetTau(0) !=NULL and e->GetTau(0)->Rematch(e)==15) passMatchDirect=true; if (e->GetTauInvIso(0) !=NULL and e->GetTauInvIso(0)->Rematch(e)==15) passMatchInverse=true; } /* if (not e->IsRealData() ) { if (passDirectLoose) { e->SetPtEtaSF("antiE",e->GetTau(0)->Pt(),e->GetTau(0)->Eta() ); e->ApplySF("antiE"); } else if (passInverseLoose) // don't apply them twice { e->SetPtEtaSF("antiE",e->GetTauInvIso(0)->Pt(),e->GetTauInvIso(0)->Eta() ); e->ApplySF("antiE"); } } */ //-------------- if (t != NULL and passMatchDirect and passDirectLoose and passPrescale) // direct { float pt = t->Pt(); int flavor= t->Rematch(e); if (pt > 8000 or pt <0 ) Log(__FUNCTION__,"INFO",Form("strange event : tau Pt=%.0f",pt)); string hist = HistName(pt,true, false); Fill( dir + hist +"_"+label,systname, e->GetMet().Pt(), e->weight() ); hist = HistName(pt,true, false,"Uperp"); Fill( dir+hist +"_"+label,systname, Upar(e,t), e->weight() ); hist = HistName(pt,true, false,"Upar"); Fill( dir+hist +"_"+label,systname, Uperp(e,t), e->weight() ); hist = HistName(pt, true, false, "TauPt") ; Fill( dir+hist +"_"+label,systname, t->Pt(), e->weight() ); /* hist = HistName(pt, true, false) ; if (flavor == 15) hist += "_T"; else if (flavor == 21 ) hist+="_G"; else if (flavor <5 and flavor != 0 ) hist+="_Q"; else hist += "_U"; Fill( dir + hist +"_"+label,systname, e->GetMet().Pt(), e->weight() ); */ hist = HistName(pt, true, false) ; if (t->GetNProng()==1) hist +="_1p"; else hist+="_3p"; Fill( dir + hist +"_"+label,systname, e->GetMet().Pt(), e->weight() ); { // CONTROL PLOTS -- LOOSE SELECTION string hist= "TauPt_Control"; Fill( dir+hist +"_"+label,systname, t->Pt(), e->weight() ); hist= "EtMiss_Control"; Fill( dir+hist +"_"+label,systname, e->GetMet().Pt(), e->weight() ); } } if (tInv != NULL and passMatchInverse and passInverseLoose and passPrescale) // inv iso { float pt = tInv->Pt(); int flavor= tInv->Rematch(e); if (pt > 8000 or pt <0 ) Log(__FUNCTION__,"INFO",Form("strange event : tau Pt=%.0f",pt)); string hist = HistName(pt,false,false); Fill( dir+hist +"_"+label,systname, e->GetMet().Pt(), e->weight() ); hist = HistName(pt,false, false,"Uperp"); Fill( dir+hist +"_"+label,systname, Upar(e,tInv), e->weight() ); hist = HistName(pt,false, false,"Upar"); Fill( dir+hist +"_"+label,systname, Uperp(e,tInv), e->weight() ); hist = HistName(pt, false, false, "TauPt") ; Fill( dir+hist +"_"+label,systname, tInv->Pt(), e->weight() ); /* hist = HistName(pt, false, false) ; if (flavor == 15) hist += "_T"; else if (flavor == 21 ) hist+="_G"; else if (flavor <5 and flavor != 0 ) hist+="_Q"; else hist += "_U"; Fill( dir + hist +"_"+label,systname, e->GetMet().Pt(), e->weight() ); */ hist = HistName(pt, false, false) ; if (tInv->GetNProng()==1) hist+="_1p"; else hist+="_3p"; Fill( dir + hist +"_"+label,systname, e->GetMet().Pt(), e->weight() ); } // not in the LOOSE --- BTAG SF, only MC //#warning no-btag-sf if (not e->IsRealData()) e->ApplyBTagSF(0);// 0=loos wp // -------------------------- FULL SELECTION ----------------------------------------------- // if (t!=NULL and passMatchDirect and not e->IsRealData()) { e->ApplyTauSF(t, false); } // N minus one direct if (t!=NULL and passMatchDirect and direct.passAllExcept(ChargedHiggsTauNu::Met) ) { Fill( none + "EtMiss" +"_"+label,systname, e->GetMet().Pt(), e->weight() ); } if (t!=NULL and passMatchDirect and direct.passAllExcept(ChargedHiggsTauNu::AngRbb) ) { Fill( none + "RbbMin" +"_"+label,systname, e->RbbMin(), e->weight() ); } if (t!=NULL and passMatchDirect and direct.passAllExcept(ChargedHiggsTauNu::AngColl) ) { Fill( none + "RCollMin" +"_"+label,systname, e->RCollMin(), e->weight() ); } if (t!=NULL and passMatchDirect and direct.passAllExcept(ChargedHiggsTauNu::OneTau) ) { Fill( none + "Tau1Pt" +"_"+label,systname, t->Pt(), e->weight() ); } if (t!=NULL and passMatchDirect and direct.passAll() ) { //if ( not e->IsRealData()) e->ApplySF("btag"); #ifdef VERBOSE if (VERBOSE >0 ) Log(__FUNCTION__,"DEBUG", "is tau pass full selection"); #endif //if(e->IsRealData() and (systname=="NONE" or systname=="") ) Log(__FUNCTION__,"SYNC",Form("%d,%d,%ld",e->runNum(),e->lumiNum(),e->eventNum()) ); float pt = t->Pt(); int flavor= t->Rematch(e); string hist = HistName(pt,true,true); Fill(dir+hist+"_"+label,systname, e->GetMet().Pt() ,e->weight()); hist= "Mt"; //UNBLIND -------- if ( Unblind(e) ) Fill(dir+hist+"_"+label,systname, e->Mt() ,e->weight()); hist = HistName(pt,true, true,"Uperp"); Fill( dir+hist +"_"+label,systname, Upar(e,t), e->weight() ); hist = HistName(pt,true, true,"Upar"); Fill( dir+hist +"_"+label,systname, Uperp(e,t), e->weight() ); hist = HistName(pt, true,true) ; if (flavor == 15) hist += "_T"; else if (flavor == 21 ) hist+="_G"; else if (flavor <5 and flavor != 0 ) hist+="_Q"; else hist += "_U"; Fill( dir + hist +"_"+label,systname, e->GetMet().Pt(), e->weight() ); hist = HistName(pt, true,true) ; if (t->GetNProng()==1) hist+="_1p"; else hist+="_3p"; Fill( dir + hist +"_"+label,systname, e->GetMet().Pt(), e->weight() ); } // ---------------------- INF TAU SF // if (tInv != NULL and passMatchInverse and passInverseLoose ){ // USE weight(false) to apply TF on data! float pt = tInv->Pt(); //const string sf="tauinviso"; string sfname="tauinvisospline"; //if (tInv->GetNProng() ==1 ) sfname+="_1p"; //else sfname+="_3p"; // if the SF don't exist go on, but don't fill inconsistent events if( not e->ExistSF(sfname) ){ LogN(__FUNCTION__,"WARNING","Tau inviso SF does not exist",10); return EVENT_NOT_USED; } e->SetPtEtaSF(sfname,tInv->Pt(),tInv->Eta()); e->ApplySF(sfname); // only in weight(false) sf are applied in data if(inverse.passAllUpTo(ChargedHiggsTauNu::ThreeJets) && inverse.pass(ChargedHiggsTauNu::Trigger)) Fill("ChargedHiggsTauNu/CutFlowQCD/CutFlowQCD_"+label,systname,0,e->weight(false)); if(inverse.passAllUpTo(ChargedHiggsTauNu::OneBjet) && inverse.pass(ChargedHiggsTauNu::Trigger)) Fill("ChargedHiggsTauNu/CutFlowQCD/CutFlowQCD_"+label,systname,1,e->weight(false)); if(inverse.passAllUpTo(ChargedHiggsTauNu::Met)) Fill("ChargedHiggsTauNu/CutFlowQCD/CutFlowQCD_"+label,systname,2,e->weight(false)); if(inverse.passAllUpTo(ChargedHiggsTauNu::AngRbb)) Fill("ChargedHiggsTauNu/CutFlowQCD/CutFlowQCD_"+label,systname,3,e->weight(false)); //Log(__FUNCTION__,"DEBUG",string("syst name is ") + systname + Form("weight is %f",e->weight(false)) ); if (tInv != NULL and passInverseLoose and passPrescale){ // CONTROL PLOTS -- LOOSE SELECTION string hist= "TauPt_IsoInv_Control"; Fill( dir+hist +"_"+label,systname, tInv->Pt(), e->weight(false) ); hist= "EtMiss_IsoInv_Control"; Fill( dir+hist +"_"+label,systname, e->GetMet().Pt(), e->weight(false) ); } if (inverse.passAllExcept(ChargedHiggsTauNu::Met)) { //if (not e->IsTriggered("HLT_LooseIsoPFTau50_Trk30_eta2p1_MET120") ) Log(__FUNCTION__,"ERROR","Event Is NOT Triggered!!! Why am I here?"); //Log(__FUNCTION__,"DEBUG",Form("N-1 MET Selection InvIso w=%.4f",e->weight(false))); Fill( none + "EtMissIsoInv" +"_"+label,systname, e->GetMet().Pt(), e->weight(false) ); } if (inverse.passAllExcept(ChargedHiggsTauNu::AngRbb) ) { Fill( none + "RbbMinIsoInv" +"_"+label,systname, e->RbbMin(3,tInv), e->weight(false) ); } if (inverse.passAllExcept(ChargedHiggsTauNu::AngColl) ) { Fill( none + "RCollMinIsoInv" +"_"+label,systname, e->RCollMin(3,tInv), e->weight(false) ); } if (inverse.passAllExcept(ChargedHiggsTauNu::OneBjet) ) { Fill( none + "NBjetsIsoInv" +"_"+label,systname, e->Bjets(), e->weight(false) ); } // TauPtIsoInv if (inverse.passAllExcept(ChargedHiggsTauNu::OneTau) ) { Fill( none + "Tau1PtIsoInv" +"_"+label,systname, pt, e->weight(false) ); } // remove trigger & met /* unsigned mymask = 0 ; for(unsigned i=0;i<ChargedHiggsTauNu::MaxCut;++i){ if (i==ChargedHiggsTauNu::Trigger) continue; if (i==ChargedHiggsTauNu::Met) continue; mymask |= (1<<i); // set all 1 } if (passPrescale and passInverseLoose and inverse.passMask(mymask) ) { // On data avoid R fact -- n minus one string hist=HistName(pt, false, true)+"_NoR"; Fill(dir+hist+"_"+label,systname, e->GetMet().Pt() ,e->weight(true)); } */ if (inverse.passAll()) { // FULL SELECTION //if ( not e->IsRealData()) e->ApplySF("btag"); #ifdef VERBOSE if (VERBOSE >0 ) Log(__FUNCTION__,"DEBUG","is tauInv full selection"); #endif if (e->weight(false) == 0 )Log(__FUNCTION__,"WARNING","event weight after SF is 0 "); int flavor= tInv->Rematch(e); string hist = HistName(pt,false,true); Fill(dir+hist+"_"+label,systname, e->GetMet().Pt() ,e->weight(false)); //hist = HistName(pt,false,true,"Mt"); hist = "MtIsoInv"; Fill(dir+hist+"_"+label,systname, e->Mt(Event::MtTauInv) ,e->weight(false)); hist = HistName(pt,false, true,"Uperp"); Fill( dir+hist +"_"+label,systname, Upar(e,tInv), e->weight(false) ); hist = HistName(pt,false, true,"Upar"); Fill( dir+hist +"_"+label,systname, Uperp(e,tInv), e->weight(false) ); /* hist = HistName(pt, false, true) ; if (flavor == 15) hist += "_T"; else if (flavor == 21 ) hist+="_G"; else if (flavor <5 and flavor != 0 ) hist+="_Q"; else hist += "_U"; Fill( dir + hist +"_"+label,systname, e->GetMet().Pt(), e->weight(false) ); */ hist = HistName(pt, false, true) ; if (tInv->GetNProng() ==1 ) hist+="_1p"; else hist+="_3p"; Fill( dir + hist +"_"+label,systname, e->GetMet().Pt(), e->weight(false) ); } // inverse.passAll } // tInv return EVENT_NOT_USED; }
void SpaceStation::LoadFromJson(const Json::Value &jsonObj, Space *space) { ModelBody::LoadFromJson(jsonObj, space); GetModel()->SetLabel(GetLabel()); if (!jsonObj.isMember("space_station")) throw SavedGameCorruptException(); Json::Value spaceStationObj = jsonObj["space_station"]; if (!spaceStationObj.isMember("ship_docking")) throw SavedGameCorruptException(); if (!spaceStationObj.isMember("ports")) throw SavedGameCorruptException(); if (!spaceStationObj.isMember("index_for_system_body")) throw SavedGameCorruptException(); if (!spaceStationObj.isMember("door_animation_step")) throw SavedGameCorruptException(); if (!spaceStationObj.isMember("door_animation_state")) throw SavedGameCorruptException(); m_oldAngDisplacement = 0.0; Json::Value shipDockingArray = spaceStationObj["ship_docking"]; if (!shipDockingArray.isArray()) throw SavedGameCorruptException(); m_shipDocking.reserve(shipDockingArray.size()); for (Uint32 i = 0; i < shipDockingArray.size(); i++) { m_shipDocking.push_back(shipDocking_t()); shipDocking_t &sd = m_shipDocking.back(); Json::Value shipDockingArrayEl = shipDockingArray[i]; if (!shipDockingArrayEl.isMember("index_for_body")) throw SavedGameCorruptException(); if (!shipDockingArrayEl.isMember("stage")) throw SavedGameCorruptException(); if (!shipDockingArrayEl.isMember("stage_pos")) throw SavedGameCorruptException(); if (!shipDockingArrayEl.isMember("from_pos")) throw SavedGameCorruptException(); if (!shipDockingArrayEl.isMember("from_rot")) throw SavedGameCorruptException(); sd.shipIndex = shipDockingArrayEl["index_for_body"].asInt(); sd.stage = shipDockingArrayEl["stage"].asInt(); sd.stagePos = StrToDouble(shipDockingArrayEl["stage_pos"].asString()); // For some reason stagePos was saved as a float in pre-JSON system (saved & loaded as double here). JsonToVector(&(sd.fromPos), shipDockingArrayEl, "from_pos"); JsonToQuaternion(&(sd.fromRot), shipDockingArrayEl, "from_rot"); } // retrieve each of the port details and bay IDs Json::Value portArray = spaceStationObj["ports"]; if (!portArray.isArray()) throw SavedGameCorruptException(); m_ports.reserve(portArray.size()); for (Uint32 i = 0; i < portArray.size(); i++) { m_ports.push_back(SpaceStationType::SPort()); SpaceStationType::SPort &port = m_ports.back(); Json::Value portArrayEl = portArray[i]; if (!portArrayEl.isMember("min_ship_size")) throw SavedGameCorruptException(); if (!portArrayEl.isMember("max_ship_size")) throw SavedGameCorruptException(); if (!portArrayEl.isMember("in_use")) throw SavedGameCorruptException(); if (!portArrayEl.isMember("bays")) throw SavedGameCorruptException(); port.minShipSize = portArrayEl["min_ship_size"].asInt(); port.maxShipSize = portArrayEl["max_ship_size"].asInt(); port.inUse = portArrayEl["in_use"].asBool(); Json::Value bayArray = portArrayEl["bays"]; if (!bayArray.isArray()) throw SavedGameCorruptException(); port.bayIDs.reserve(bayArray.size()); for (Uint32 j = 0; j < bayArray.size(); j++) { Json::Value bayArrayEl = bayArray[j]; if (!bayArrayEl.isMember("bay_id")) throw SavedGameCorruptException(); if (!bayArrayEl.isMember("name")) throw SavedGameCorruptException(); port.bayIDs.push_back(std::make_pair(bayArrayEl["bay_id"].asInt(), bayArrayEl["name"].asString())); } } m_sbody = space->GetSystemBodyByIndex(spaceStationObj["index_for_system_body"].asUInt()); m_doorAnimationStep = StrToDouble(spaceStationObj["door_animation_step"].asString()); m_doorAnimationState = StrToDouble(spaceStationObj["door_animation_state"].asString()); InitStation(); m_navLights->LoadFromJson(spaceStationObj); }
void wxTabControl::OnDraw(wxDC& dc, bool lastInRow) { // Old, but in some ways better (drawing opaque tabs) #ifndef wxUSE_NEW_METHOD if (!m_view) return; // Top-left of tab view area int viewX = m_view->GetViewRect().x; int viewY = m_view->GetViewRect().y; // Top-left of tab control int tabX = GetX() + viewX; int tabY = GetY() + viewY; int tabHeightInc = 0; if (m_isSelected) { tabHeightInc = (m_view->GetTabSelectionHeight() - m_view->GetTabHeight()); tabY -= tabHeightInc; } dc.SetPen(*wxTRANSPARENT_PEN); // Draw grey background if (m_view->GetTabStyle() & wxTAB_STYLE_COLOUR_INTERIOR) { if(m_view->GetBackgroundBrush()) dc.SetBrush(*m_view->GetBackgroundBrush()); // Add 1 because the pen is transparent. Under Motif, may be different. #ifdef __WXMOTIF__ dc.DrawRectangle(tabX, tabY, (GetWidth()+1), (GetHeight() + tabHeightInc)); #else dc.DrawRectangle(tabX, tabY, (GetWidth()+1), (GetHeight() + 1 + tabHeightInc)); #endif } // Draw highlight and shadow dc.SetPen(*m_view->GetHighlightPen()); // Calculate the top of the tab beneath. It's the height of the tab, MINUS // a bit if the tab below happens to be selected. Check. wxTabControl *tabBeneath = NULL; int subtractThis = 0; if (GetColPosition() > 0) tabBeneath = m_view->FindTabControlForPosition(GetColPosition() - 1, GetRowPosition()); if (tabBeneath && tabBeneath->IsSelected()) subtractThis = (m_view->GetTabSelectionHeight() - m_view->GetTabHeight()); // Vertical highlight: if first tab, draw to bottom of view if (tabX == m_view->GetViewRect().x && (m_view->GetTabStyle() & wxTAB_STYLE_DRAW_BOX)) dc.DrawLine(tabX, tabY, tabX, (m_view->GetViewRect().y + m_view->GetViewRect().height)); else if (tabX == m_view->GetViewRect().x) // Not box drawing, just to top of view. dc.DrawLine(tabX, tabY, tabX, (m_view->GetViewRect().y)); else dc.DrawLine(tabX, tabY, tabX, (tabY + GetHeight() + tabHeightInc - subtractThis)); dc.DrawLine(tabX, tabY, (tabX + GetWidth()), tabY); dc.SetPen(*m_view->GetShadowPen()); // Test if we're outside the right-hand edge of the view area if (((tabX + GetWidth()) >= m_view->GetViewRect().x + m_view->GetViewRect().width) && (m_view->GetTabStyle() & wxTAB_STYLE_DRAW_BOX)) { int bottomY = m_view->GetViewRect().y + m_view->GetViewRect().height + GetY() + m_view->GetTabHeight() + m_view->GetTopMargin(); // Add a tab height since we wish to draw to the bottom of the view. dc.DrawLine((tabX + GetWidth()), tabY, (tabX + GetWidth()), bottomY); // Calculate the far-right of the view, since we don't wish to // draw inside that int rightOfView = m_view->GetViewRect().x + m_view->GetViewRect().width + 1; // Draw the horizontal bit to connect to the view rectangle dc.DrawLine((wxMax((tabX + GetWidth() - m_view->GetHorizontalTabOffset()), rightOfView)), (bottomY-1), (tabX + GetWidth()), (bottomY-1)); // Draw black line to emphasize shadow dc.SetPen(*wxBLACK_PEN); dc.DrawLine((tabX + GetWidth() + 1), (tabY+1), (tabX + GetWidth() + 1), bottomY); // Draw the horizontal bit to connect to the view rectangle dc.DrawLine((wxMax((tabX + GetWidth() - m_view->GetHorizontalTabOffset()), rightOfView)), (bottomY), (tabX + GetWidth() + 1), (bottomY)); } else { if (lastInRow) { // 25/5/97 UNLESS it's less than the max number of positions in this row int topY = m_view->GetViewRect().y - m_view->GetTopMargin(); int maxPositions = ((wxTabLayer *)m_view->GetLayers().Item(0)->GetData())->GetCount(); // Only down to the bottom of the tab, not to the top of the view if ( GetRowPosition() < (maxPositions - 1) ) topY = tabY + GetHeight() + tabHeightInc; #ifdef __WXMOTIF__ topY -= 1; #endif // Shadow dc.DrawLine((tabX + GetWidth()), tabY, (tabX + GetWidth()), topY); // Draw black line to emphasize shadow dc.SetPen(*wxBLACK_PEN); dc.DrawLine((tabX + GetWidth() + 1), (tabY+1), (tabX + GetWidth() + 1), topY); } else { // Calculate the top of the tab beneath. It's the height of the tab, MINUS // a bit if the tab below (and next col along) happens to be selected. Check. wxTabControl *tabBeneath = NULL; int subtractThis = 0; if (GetColPosition() > 0) tabBeneath = m_view->FindTabControlForPosition(GetColPosition() - 1, GetRowPosition() + 1); if (tabBeneath && tabBeneath->IsSelected()) subtractThis = (m_view->GetTabSelectionHeight() - m_view->GetTabHeight()); #ifdef __WXMOTIF__ subtractThis += 1; #endif // Draw only to next tab down. dc.DrawLine((tabX + GetWidth()), tabY, (tabX + GetWidth()), (tabY + GetHeight() + tabHeightInc - subtractThis)); // Draw black line to emphasize shadow dc.SetPen(*wxBLACK_PEN); dc.DrawLine((tabX + GetWidth() + 1), (tabY+1), (tabX + GetWidth() + 1), (tabY + GetHeight() + tabHeightInc - subtractThis)); } } // Draw centered text int textY = tabY + m_view->GetVerticalTabTextSpacing() + tabHeightInc; if (m_isSelected) dc.SetFont(* m_view->GetSelectedTabFont()); else dc.SetFont(* GetFont()); wxColour col(m_view->GetTextColour()); dc.SetTextForeground(col); dc.SetBackgroundMode(wxTRANSPARENT); wxCoord textWidth, textHeight; dc.GetTextExtent(GetLabel(), &textWidth, &textHeight); int textX = (int)(tabX + (GetWidth() - textWidth)/2.0); if (textX < (tabX + 2)) textX = (tabX + 2); dc.SetClippingRegion(tabX, tabY, GetWidth(), GetHeight()); dc.DrawText(GetLabel(), textX, textY); dc.DestroyClippingRegion(); if (m_isSelected) { dc.SetPen(*m_view->GetHighlightPen()); // Draw white highlight from the tab's left side to the left hand edge of the view dc.DrawLine(m_view->GetViewRect().x, (tabY + GetHeight() + tabHeightInc), tabX, (tabY + GetHeight() + tabHeightInc)); // Draw white highlight from the tab's right side to the right hand edge of the view dc.DrawLine((tabX + GetWidth()), (tabY + GetHeight() + tabHeightInc), m_view->GetViewRect().x + m_view->GetViewRect().width, (tabY + GetHeight() + tabHeightInc)); } #else // New HEL version with rounder tabs if (!m_view) return; int tabInc = 0; if (m_isSelected) { tabInc = m_view->GetTabSelectionHeight() - m_view->GetTabHeight(); } int tabLeft = GetX() + m_view->GetViewRect().x; int tabTop = GetY() + m_view->GetViewRect().y - tabInc; int tabRight = tabLeft + m_view->GetTabWidth(); int left = m_view->GetViewRect().x; int top = tabTop + m_view->GetTabHeight() + tabInc; int right = left + m_view->GetViewRect().width; int bottom = top + m_view->GetViewRect().height; if (m_isSelected) { // TAB is selected - draw TAB and the View's full outline dc.SetPen(*(m_view->GetHighlightPen())); wxPoint pnts[10]; int n = 0; pnts[n].x = left; pnts[n++].y = bottom; pnts[n].x = left; pnts[n++].y = top; pnts[n].x = tabLeft; pnts[n++].y = top; pnts[n].x = tabLeft; pnts[n++].y = tabTop + 2; pnts[n].x = tabLeft + 2; pnts[n++].y = tabTop; pnts[n].x = tabRight - 1; pnts[n++].y = tabTop; dc.DrawLines(n, pnts); if (!lastInRow) { dc.DrawLine( (tabRight + 2), top, right, top ); } dc.SetPen(*(m_view->GetShadowPen())); dc.DrawLine( tabRight, tabTop + 2, tabRight, top ); dc.DrawLine( right, top, right, bottom ); dc.DrawLine( right, bottom, left, bottom ); dc.SetPen(*wxBLACK_PEN); dc.DrawPoint( tabRight, tabTop + 1 ); dc.DrawPoint( tabRight + 1, tabTop + 2 ); if (lastInRow) { dc.DrawLine( tabRight + 1, bottom, tabRight + 1, tabTop + 1 ); } else { dc.DrawLine( tabRight + 1, tabTop + 2, tabRight + 1, top ); dc.DrawLine( right + 1, top, right + 1, bottom + 1 ); } dc.DrawLine( right + 1, bottom + 1, left + 1, bottom + 1 ); } else { // TAB is not selected - just draw TAB outline and RH edge // if the TAB is the last in the row int maxPositions = ((wxTabLayer*)m_view->GetLayers().Item(0)->GetData())->GetCount(); wxTabControl* tabBelow = 0; wxTabControl* tabBelowRight = 0; if (GetColPosition() > 0) { tabBelow = m_view->FindTabControlForPosition( GetColPosition() - 1, GetRowPosition() ); } if (!lastInRow && GetColPosition() > 0) { tabBelowRight = m_view->FindTabControlForPosition( GetColPosition() - 1, GetRowPosition() + 1 ); } float raisedTop = top - m_view->GetTabSelectionHeight() + m_view->GetTabHeight(); dc.SetPen(*(m_view->GetHighlightPen())); wxPoint pnts[10]; int n = 0; pnts[n].x = tabLeft; if (tabBelow && tabBelow->IsSelected()) { pnts[n++].y = (long)raisedTop; } else { pnts[n++].y = top; } pnts[n].x = tabLeft; pnts[n++].y = tabTop + 2; pnts[n].x = tabLeft + 2; pnts[n++].y = tabTop; pnts[n].x = tabRight - 1; pnts[n++].y = tabTop; dc.DrawLines(n, pnts); dc.SetPen(*(m_view->GetShadowPen())); if (GetRowPosition() >= maxPositions - 1) { dc.DrawLine( tabRight, (tabTop + 2), tabRight, bottom ); dc.DrawLine( tabRight, bottom, (tabRight - m_view->GetHorizontalTabOffset()), bottom ); } else { if (tabBelowRight && tabBelowRight->IsSelected()) { dc.DrawLine( tabRight, (long)raisedTop, tabRight, tabTop + 1 ); } else { dc.DrawLine( tabRight, top - 1, tabRight, tabTop + 1 ); } } dc.SetPen(*wxBLACK_PEN); dc.DrawPoint( tabRight, tabTop + 1 ); dc.DrawPoint( tabRight + 1, tabTop + 2 ); if (GetRowPosition() >= maxPositions - 1) { // draw right hand edge to bottom of view dc.DrawLine( tabRight + 1, bottom + 1, tabRight + 1, tabTop + 2 ); dc.DrawLine( tabRight + 1, bottom + 1, (tabRight - m_view->GetHorizontalTabOffset()), bottom + 1 ); } else { // draw right hand edge of TAB if (tabBelowRight && tabBelowRight->IsSelected()) { dc.DrawLine( tabRight + 1, (long)(raisedTop - 1), tabRight + 1, tabTop + 2 ); } else { dc.DrawLine( tabRight + 1, top - 1, tabRight + 1, tabTop + 2 ); } } } // Draw centered text dc.SetPen(*wxBLACK_PEN); if (m_isSelected) { dc.SetFont(*(m_view->GetSelectedTabFont())); } else { dc.SetFont(*(GetFont())); } wxColour col(m_view->GetTextColour()); dc.SetTextForeground(col); dc.SetBackgroundMode(wxTRANSPARENT); long textWidth, textHeight; dc.GetTextExtent(GetLabel(), &textWidth, &textHeight); float textX = (tabLeft + tabRight - textWidth) / 2; float textY = (tabInc + tabTop + m_view->GetVerticalTabTextSpacing()); dc.DrawText(GetLabel(), (long)textX, (long)textY); #endif }
// Renders space station and adjacent city if applicable // For orbital starports: renders as normal // For surface starports: // Lighting: Calculates available light for model and splits light between directly and ambiently lit // Lighting is done by manipulating global lights or setting uniforms in atmospheric models shader // Adds an ambient light at close ranges if dark by manipulating the global ambient level void SpaceStation::Render(Graphics::Renderer *r, const Camera *camera, const vector3d &viewCoords, const matrix4x4d &viewTransform) { LmrObjParams ¶ms = GetLmrObjParams(); params.label = GetLabel().c_str(); SetLmrTimeParams(); for (int i=0; i<MAX_DOCKING_PORTS; i++) { params.animStages[ANIM_DOCKING_BAY_1 + i] = m_shipDocking[i].stage; params.animValues[ANIM_DOCKING_BAY_1 + i] = m_shipDocking[i].stagePos; } Body *b = GetFrame()->m_astroBody; assert(b); if (!b->IsType(Object::PLANET)) { // orbital spaceport -- don't make city turds or change lighting based on atmosphere RenderLmrModel(r, viewCoords, viewTransform); } else { Planet *planet = static_cast<Planet*>(b); // calculate lighting // available light is calculated and split between directly (diffusely/specularly) lit and ambiently lit const std::vector<Camera::LightSource> &lightSources = camera->GetLightSources(); double ambient, intensity; CalcLighting(planet, ambient, intensity, lightSources); std::vector<Graphics::Light> origLights, newLights; for(size_t i = 0; i < lightSources.size(); i++) { Graphics::Light light(lightSources[i].GetLight()); origLights.push_back(light); Color c = light.GetDiffuse(); Color ca = light.GetAmbient(); Color cs = light.GetSpecular(); ca.r = c.r * float(ambient); ca.g = c.g * float(ambient); ca.b = c.b * float(ambient); c.r*=float(intensity); c.g*=float(intensity); c.b*=float(intensity); cs.r*=float(intensity); cs.g*=float(intensity); cs.b*=float(intensity); light.SetDiffuse(c); light.SetAmbient(ca); light.SetSpecular(cs); newLights.push_back(light); } r->SetLights(newLights.size(), &newLights[0]); double overallLighting = ambient+intensity; // turn off global ambient color const Color oldAmbient = r->GetAmbientColor(); r->SetAmbientColor(Color::BLACK); // as the camera gets close adjust scene ambient so that intensity+ambient = minIllumination double fadeInEnd, fadeInLength, minIllumination; if (Graphics::AreShadersEnabled()) { minIllumination = 0.125; fadeInEnd = 800.0; fadeInLength = 2000.0; } else { minIllumination = 0.25; fadeInEnd = 1500.0; fadeInLength = 3000.0; } /* don't render city if too far away */ if (viewCoords.Length() < 1000000.0){ r->SetAmbientColor(Color::BLACK); if (!m_adjacentCity) { m_adjacentCity = new CityOnPlanet(planet, this, m_sbody->seed); } m_adjacentCity->Render(r, camera, this, viewCoords, viewTransform, overallLighting, minIllumination); } r->SetAmbientColor(Color::BLACK); FadeInModelIfDark(r, GetCollMesh()->GetBoundingRadius(), viewCoords.Length(), fadeInEnd, fadeInLength, overallLighting, minIllumination); RenderLmrModel(r, viewCoords, viewTransform); // restore old lights r->SetLights(origLights.size(), &origLights[0]); // restore old ambient color r->SetAmbientColor(oldAmbient); } }
std::string CGUISpinControlEx::GetDescription() const { return StringUtils::Format("%s (%s)", m_buttonControl.GetDescription().c_str(), GetLabel().c_str()); }
void frmExtract::onExtract(wxCommandEvent &e) { if(m_bIsDirectory) { RainString sFolder = m_pDestinationPath->GetValue(); if(!_ensureDirectoryExists(sFolder)) return; wxSizer *pMainSizer = GetSizer(); if(m_pButtonsSizer) { FindWindow(wxID_OK)->Hide(); FindWindow(wxID_CANCEL)->Hide(); pMainSizer->Detach(m_pButtonsSizer); } pMainSizer->Add(new wxStaticLine(this), 0, wxEXPAND | wxALL, 4); wxGauge *pProgressBar = new wxGauge(this, wxID_ANY, 1, wxDefaultPosition, wxDefaultSize, wxGA_HORIZONTAL | wxGA_SMOOTH); wxStaticText *pCurrentItem = new wxStaticText(this, wxID_ANY, L"Initialising extraction..."); pMainSizer->Add(pProgressBar, 0, wxEXPAND | wxALL, 2); pMainSizer->Add(pCurrentItem, 0, wxEXPAND | wxALL, 2); pMainSizer->RecalcSizes(); SetSize(pMainSizer->GetMinSize()); Layout(); ::wxSafeYield(this); int iTotalCount = 1, iDoneCount = 0; std::queue<IDirectory*> qTodo; try { qTodo.push(m_pArchive->openDirectory(m_sPathToExtract)); iTotalCount += static_cast<int>(qTodo.front()->getItemCount()); size_t iSkipLength = qTodo.front()->getPath().length(); pProgressBar->SetRange(iTotalCount); while(!qTodo.empty()) { IDirectory *pDirectory = qTodo.front(); pCurrentItem->SetLabel(pDirectory->getPath()); pProgressBar->SetValue(++iDoneCount); ::wxSafeYield(this); RainString sDirectoryBase = pDirectory->getPath(); sDirectoryBase = sFolder + sDirectoryBase.mid(iSkipLength, sDirectoryBase.length() - iSkipLength); if(!RainDoesDirectoryExist(sDirectoryBase)) RainCreateDirectory(sDirectoryBase); for(IDirectory::iterator itr = pDirectory->begin(), itrEnd = pDirectory->end(); itr != itrEnd; ++itr) { if(itr->isDirectory()) { IDirectory *pChild = itr->open(); iTotalCount += 1 + static_cast<int>(pChild->getItemCount()); qTodo.push(pChild); pProgressBar->SetRange(iTotalCount); } else { std::auto_ptr<IFile> pFile; pCurrentItem->SetLabel(pDirectory->getPath() + itr->name()); pProgressBar->SetValue(++iDoneCount); ::wxSafeYield(this); pFile.reset(RainOpenFile(sDirectoryBase + itr->name(), FM_Write)); itr->pump(&*pFile); } } delete pDirectory; qTodo.pop(); } } catch(RainException *pE) { while(!qTodo.empty()) { delete qTodo.front(); qTodo.pop(); } EXCEPTION_MESSAGE_BOX_1(L"Error extracting directory \'%s\'", m_sPathToExtract.getCharacters(), pE); SetReturnCode(GetEscapeId()); return; } } else { wxFileName oFilename(m_pDestinationPath->GetValue()); RainString sFolder = oFilename.GetPath(); IFile *pFile = 0; try { if(!_ensureDirectoryExists(sFolder)) return; pFile = RainOpenFile(m_pDestinationPath->GetValue(), FM_Write); m_pArchive->pumpFile(m_sPathToExtract, pFile); } catch(RainException *pE) { delete pFile; EXCEPTION_MESSAGE_BOX_1(L"Error extracting \'%s\'", m_sPathToExtract.getCharacters(), pE); return; } delete pFile; } wxString sMessage = L"Extracted " + m_sPathToExtract; if(m_pPositiveResultNoficiationBar) m_pPositiveResultNoficiationBar->SetStatusText(sMessage); else ::wxMessageBox(sMessage, GetLabel(), wxOK | wxCENTER | wxICON_INFORMATION, this); EndModal(GetAffirmativeId()); }
wxSize wxGenericHyperlinkCtrl::DoGetBestClientSize() const { wxClientDC dc((wxWindow *)this); return dc.GetTextExtent(GetLabel()); }
void SpaceStation::DockingUpdate(const double timeStep) { vector3d p1, p2, zaxis; for (Uint32 i=0; i<m_shipDocking.size(); i++) { shipDocking_t &dt = m_shipDocking[i]; if (!dt.ship) continue; // docked stage is m_type->NumDockingPorts() + 1 => ship docked if (dt.stage > m_type->NumDockingStages()) continue; double stageDuration = (dt.stage > 0 ? m_type->GetDockAnimStageDuration(dt.stage-1) : m_type->GetUndockAnimStageDuration(abs(dt.stage)-1)); dt.stagePos += timeStep / stageDuration; if (dt.stage == 1) { // SPECIAL stage! Docking granted but waiting for ship to dock m_doorAnimationStep = 0.3; // open door if (dt.stagePos >= 1.0) { if (dt.ship == Pi::player) Pi::game->log->Add(GetLabel(), Lang::DOCKING_CLEARANCE_EXPIRED); dt.ship = 0; dt.stage = 0; m_doorAnimationStep = -0.3; // close door } continue; } if (dt.stagePos > 1.0) { // use end position of last segment for start position of new segment SpaceStationType::positionOrient_t dport; PiVerify(m_type->GetDockAnimPositionOrient(i, dt.stage, 1.0f, dt.fromPos, dport, dt.ship)); matrix3x3d fromRot = matrix3x3d::FromVectors(dport.xaxis, dport.yaxis, dport.zaxis); dt.fromRot = Quaterniond::FromMatrix3x3(fromRot); dt.fromPos = dport.pos; // transition between docking stages dt.stagePos = 0; if (dt.stage >= 0) dt.stage++; else dt.stage--; } if (dt.stage < -m_type->ShipLaunchStage() && dt.ship->GetFlightState() != Ship::FLYING) { // launch ship dt.ship->SetFlightState(Ship::FLYING); dt.ship->SetAngVelocity(GetAngVelocity()); if (m_type->IsSurfaceStation()) { dt.ship->SetThrusterState(1, 1.0); // up } else { dt.ship->SetThrusterState(2, -1.0); // forward } LuaEvent::Queue("onShipUndocked", dt.ship, this); } if (dt.stage < -m_type->NumUndockStages()) { // undock animation finished, clear port dt.stage = 0; dt.ship = 0; LockPort(i, false); m_doorAnimationStep = -0.3; // close door } else if (dt.stage > m_type->NumDockingStages()) { // set docked dt.ship->SetDockedWith(this, i); LuaEvent::Queue("onShipDocked", dt.ship, this); LockPort(i, false); m_doorAnimationStep = -0.3; // close door } } m_doorAnimationState = Clamp(m_doorAnimationState + m_doorAnimationStep*timeStep, 0.0, 1.0); if (m_doorAnimation) m_doorAnimation->SetProgress(m_doorAnimationState); }
C3DFileAdapter::OutputTables C3DFileAdapter::extendRead(const std::string& fileName) const { auto reader = btk::AcquisitionFileReader::New(); reader->SetFilename(fileName); reader->Update(); auto acquisition = reader->GetOutput(); EventTable event_table{}; auto events = acquisition->GetEvents(); for (auto it = events->Begin(); it != events->End(); ++it) { auto et = *it; event_table.push_back({ et->GetLabel(), et->GetTime(), et->GetFrame(), et->GetDescription() }); } OutputTables tables{}; auto marker_pts = btk::PointCollection::New(); for(auto it = acquisition->BeginPoint(); it != acquisition->EndPoint(); ++it) { auto pt = *it; if(pt->GetType() == btk::Point::Marker) marker_pts->InsertItem(pt); } if(marker_pts->GetItemNumber() != 0) { int marker_nrow = marker_pts->GetFrontItem()->GetFrameNumber(); int marker_ncol = marker_pts->GetItemNumber(); std::vector<double> marker_times(marker_nrow); SimTK::Matrix_<SimTK::Vec3> marker_matrix(marker_nrow, marker_ncol); std::vector<std::string> marker_labels{}; for (auto it = marker_pts->Begin(); it != marker_pts->End(); ++it) { marker_labels.push_back(SimTK::Value<std::string>((*it)->GetLabel())); } double time_step{1.0 / acquisition->GetPointFrequency()}; for(int f = 0; f < marker_nrow; ++f) { SimTK::RowVector_<SimTK::Vec3> row{ marker_pts->GetItemNumber(), SimTK::Vec3(SimTK::NaN) }; int m{0}; for(auto it = marker_pts->Begin(); it != marker_pts->End(); ++it) { auto pt = *it; // BTK reads empty values as zero, but sets a "residual" value // to -1 and it is how it knows to export these values as // blank, instead of 0, when exporting to .trc // See: BTKCore/Code/IO/btkTRCFileIO.cpp#L359-L360 // Read in value if it is not zero or residual is not -1 if (!pt->GetValues().row(f).isZero() || //not precisely zero (pt->GetResiduals().coeff(f) != -1) ) {//residual is not -1 row[m] = SimTK::Vec3{ pt->GetValues().coeff(f, 0), pt->GetValues().coeff(f, 1), pt->GetValues().coeff(f, 2) }; } ++m; } marker_matrix.updRow(f) = row; marker_times[f] = 0 + f * time_step; //TODO: 0 should be start_time } // Create the data auto marker_table = std::make_shared<TimeSeriesTableVec3>(marker_times, marker_matrix, marker_labels); marker_table-> updTableMetaData(). setValueForKey("DataRate", std::to_string(acquisition->GetPointFrequency())); marker_table-> updTableMetaData(). setValueForKey("Units", acquisition->GetPointUnit()); marker_table->updTableMetaData().setValueForKey("events", event_table); tables.emplace(_markers, marker_table); } // This is probably the right way to get the raw forces data from force // platforms. Extract the collection of force platforms. auto force_platforms_extractor = btk::ForcePlatformsExtractor::New(); force_platforms_extractor->SetInput(acquisition); auto force_platform_collection = force_platforms_extractor->GetOutput(); force_platforms_extractor->Update(); std::vector<SimTK::Matrix_<double>> fpCalMatrices{}; std::vector<SimTK::Matrix_<double>> fpCorners{}; std::vector<SimTK::Matrix_<double>> fpOrigins{}; std::vector<unsigned> fpTypes{}; auto fp_force_pts = btk::PointCollection::New(); auto fp_moment_pts = btk::PointCollection::New(); auto fp_position_pts = btk::PointCollection::New(); for(auto platform = force_platform_collection->Begin(); platform != force_platform_collection->End(); ++platform) { const auto& calMatrix = (*platform)->GetCalMatrix(); const auto& corners = (*platform)->GetCorners(); const auto& origins = (*platform)->GetOrigin(); fpCalMatrices.push_back(convertToSimtkMatrix(calMatrix)); fpCorners.push_back(convertToSimtkMatrix(corners)); fpOrigins.push_back(convertToSimtkMatrix(origins)); fpTypes.push_back(static_cast<unsigned>((*platform)->GetType())); // Get ground reaction wrenches for the force platform. auto ground_reaction_wrench_filter = btk::GroundReactionWrenchFilter::New(); ground_reaction_wrench_filter->setLocation( btk::GroundReactionWrenchFilter::Location(getLocationForForceExpression())); ground_reaction_wrench_filter->SetInput(*platform); auto wrench_collection = ground_reaction_wrench_filter->GetOutput(); ground_reaction_wrench_filter->Update(); for(auto wrench = wrench_collection->Begin(); wrench != wrench_collection->End(); ++wrench) { // Forces time series. fp_force_pts->InsertItem((*wrench)->GetForce()); // Moment time series. fp_moment_pts->InsertItem((*wrench)->GetMoment()); // Position time series. fp_position_pts->InsertItem((*wrench)->GetPosition()); } } if(fp_force_pts->GetItemNumber() != 0) { std::vector<std::string> labels{}; ValueArray<std::string> units{}; for(int fp = 1; fp <= fp_force_pts->GetItemNumber(); ++fp) { auto fp_str = std::to_string(fp); labels.push_back(SimTK::Value<std::string>("f" + fp_str)); auto force_unit = acquisition->GetPointUnits(). at(_unit_index.at("force")); units.upd().push_back(SimTK::Value<std::string>(force_unit)); labels.push_back(SimTK::Value<std::string>("p" + fp_str)); auto position_unit = acquisition->GetPointUnits(). at(_unit_index.at("marker")); units.upd().push_back(SimTK::Value<std::string>(position_unit)); labels.push_back(SimTK::Value<std::string>("m" + fp_str)); auto moment_unit = acquisition->GetPointUnits(). at(_unit_index.at("moment")); units.upd().push_back(SimTK::Value<std::string>(moment_unit)); } const int nf = fp_force_pts->GetFrontItem()->GetFrameNumber(); std::vector<double> force_times(nf); SimTK::Matrix_<SimTK::Vec3> force_matrix(nf, (int)labels.size()); double time_step{1.0 / acquisition->GetAnalogFrequency()}; for(int f = 0; f < nf; ++f) { SimTK::RowVector_<SimTK::Vec3> row{fp_force_pts->GetItemNumber() * 3}; int col{0}; for(auto fit = fp_force_pts->Begin(), mit = fp_moment_pts->Begin(), pit = fp_position_pts->Begin(); fit != fp_force_pts->End(); ++fit, ++mit, ++pit) { row[col] = SimTK::Vec3{(*fit)->GetValues().coeff(f, 0), (*fit)->GetValues().coeff(f, 1), (*fit)->GetValues().coeff(f, 2)}; ++col; row[col] = SimTK::Vec3{(*pit)->GetValues().coeff(f, 0), (*pit)->GetValues().coeff(f, 1), (*pit)->GetValues().coeff(f, 2)}; ++col; row[col] = SimTK::Vec3{(*mit)->GetValues().coeff(f, 0), (*mit)->GetValues().coeff(f, 1), (*mit)->GetValues().coeff(f, 2)}; ++col; } force_matrix.updRow(f) = row; force_times[f] = 0 + f * time_step; //TODO: 0 should be start_time } auto& force_table = *(new TimeSeriesTableVec3(force_times, force_matrix, labels)); TimeSeriesTableVec3::DependentsMetaData force_dep_metadata = force_table.getDependentsMetaData(); // add units to the dependent meta data force_dep_metadata.setValueArrayForKey("units", units); force_table.setDependentsMetaData(force_dep_metadata); force_table. updTableMetaData(). setValueForKey("CalibrationMatrices", std::move(fpCalMatrices)); force_table. updTableMetaData(). setValueForKey("Corners", std::move(fpCorners)); force_table. updTableMetaData(). setValueForKey("Origins", std::move(fpOrigins)); force_table. updTableMetaData(). setValueForKey("Types", std::move(fpTypes)); force_table. updTableMetaData(). setValueForKey("DataRate", std::to_string(acquisition->GetAnalogFrequency())); tables.emplace(_forces, std::shared_ptr<TimeSeriesTableVec3>(&force_table)); force_table.updTableMetaData().setValueForKey("events", event_table); } return tables; }
CStdString CGUISpinControlEx::GetDescription() const { CStdString strLabel; strLabel.Format("%s (%s)", m_buttonControl.GetDescription(), GetLabel()); return strLabel; }
bool wxCheckBox::MSWOnDraw(WXDRAWITEMSTRUCT *item) { DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)item; if ( !IsOwnerDrawn() || dis->CtlType != ODT_BUTTON ) return wxCheckBoxBase::MSWOnDraw(item); // calculate the rectangles for the check mark itself and the label HDC hdc = dis->hDC; RECT& rect = dis->rcItem; RECT rectCheck, rectLabel; rectLabel.top = rect.top + (rect.bottom - rect.top - GetBestSize().y) / 2; rectLabel.bottom = rectLabel.top + GetBestSize().y; const int MARGIN = 3; const int CXMENUCHECK = ::GetSystemMetrics(SM_CXMENUCHECK); // the space between the checkbox and the label is included in the // check-mark bitmap const int checkSize = wxMin(CXMENUCHECK - MARGIN, GetSize().y); rectCheck.top = rect.top + (rect.bottom - rect.top - checkSize) / 2; rectCheck.bottom = rectCheck.top + checkSize; const bool isRightAligned = HasFlag(wxALIGN_RIGHT); if ( isRightAligned ) { rectLabel.right = rect.right - CXMENUCHECK; rectLabel.left = rect.left; rectCheck.left = rectLabel.right + ( CXMENUCHECK + MARGIN - checkSize ) / 2; rectCheck.right = rectCheck.left + checkSize; } else // normal, left-aligned checkbox { rectCheck.left = rect.left + ( CXMENUCHECK - MARGIN - checkSize ) / 2; rectCheck.right = rectCheck.left + checkSize; rectLabel.left = rect.left + CXMENUCHECK; rectLabel.right = rect.right; } // shall we draw a focus rect? const bool isFocused = m_isPressed || FindFocus() == this; // draw the checkbox itself wxDCTemp dc(hdc); int flags = 0; if ( !IsEnabled() ) flags |= wxCONTROL_DISABLED; switch ( Get3StateValue() ) { case wxCHK_CHECKED: flags |= wxCONTROL_CHECKED; break; case wxCHK_UNDETERMINED: flags |= wxCONTROL_PRESSED; break; default: wxFAIL_MSG( wxT("unexpected Get3StateValue() return value") ); // fall through case wxCHK_UNCHECKED: // no extra styles needed break; } if ( wxFindWindowAtPoint(wxGetMousePosition()) == this ) flags |= wxCONTROL_CURRENT; wxRendererNative::Get(). DrawCheckBox(this, dc, wxRectFromRECT(rectCheck), flags); // draw the text const wxString& label = GetLabel(); // first we need to measure it UINT fmt = DT_NOCLIP; // drawing underlying doesn't look well with focus rect (and the native // control doesn't do it) if ( isFocused ) fmt |= DT_HIDEPREFIX; if ( isRightAligned ) fmt |= DT_RIGHT; // TODO: also use DT_HIDEPREFIX if the system is configured so // we need to get the label real size first if we have to draw a focus rect // around it if ( isFocused ) { RECT oldLabelRect = rectLabel; // needed if right aligned if ( !::DrawText(hdc, label.t_str(), label.length(), &rectLabel, fmt | DT_CALCRECT) ) { wxLogLastError(wxT("DrawText(DT_CALCRECT)")); } if ( isRightAligned ) { // move the label rect to the right const int labelWidth = rectLabel.right - rectLabel.left; rectLabel.right = oldLabelRect.right; rectLabel.left = rectLabel.right - labelWidth; } } if ( !IsEnabled() ) { ::SetTextColor(hdc, ::GetSysColor(COLOR_GRAYTEXT)); } if ( !::DrawText(hdc, label.t_str(), label.length(), &rectLabel, fmt) ) { wxLogLastError(wxT("DrawText()")); } // finally draw the focus if ( isFocused ) { rectLabel.left--; rectLabel.right++; if ( !::DrawFocusRect(hdc, &rectLabel) ) { wxLogLastError(wxT("DrawFocusRect()")); } } return true; }