本文整理汇总了C++中GetControl函数的典型用法代码示例。如果您正苦于以下问题:C++ GetControl函数的具体用法?C++ GetControl怎么用?C++ GetControl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetControl函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetControl
void
DeviceEditWidget::SetConfig(const DeviceConfig &_config)
{
config = _config;
if (config.port_type == DeviceConfig::PortType::DISABLED)
/* if the user configures a new device, forget the old "enabled"
flag and re-enable the device */
config.enabled = true;
WndProperty &port_control = GetControl(Port);
DataFieldEnum &port_df = *(DataFieldEnum *)port_control.GetDataField();
SetPort(port_df, config);
port_control.RefreshDisplay();
WndProperty &baud_control = GetControl(BaudRate);
DataFieldEnum &baud_df = *(DataFieldEnum *)baud_control.GetDataField();
baud_df.Set(config.baud_rate);
baud_control.RefreshDisplay();
WndProperty &bulk_baud_control = GetControl(BulkBaudRate);
DataFieldEnum &bulk_baud_df = *(DataFieldEnum *)
bulk_baud_control.GetDataField();
bulk_baud_df.Set(config.bulk_baud_rate);
bulk_baud_control.RefreshDisplay();
WndProperty &ip_address_control = GetControl(IP_ADDRESS);
DataFieldEnum &ip_address_df = *(DataFieldEnum *)
ip_address_control.GetDataField();
ip_address_df.Set(config.ip_address);
ip_address_control.RefreshDisplay();
WndProperty &tcp_port_control = GetControl(TCPPort);
DataFieldEnum &tcp_port_df = *(DataFieldEnum *)
tcp_port_control.GetDataField();
tcp_port_df.Set(config.tcp_port);
tcp_port_control.RefreshDisplay();
WndProperty &i2c_bus_control = GetControl(I2CBus);
DataFieldEnum &i2c_bus_df = *(DataFieldEnum *)
i2c_bus_control.GetDataField();
i2c_bus_df.Set(config.i2c_bus);
i2c_bus_control.RefreshDisplay();
WndProperty &i2c_addr_control = GetControl(I2CAddr);
DataFieldEnum &i2c_addr_df = *(DataFieldEnum *)
i2c_addr_control.GetDataField();
i2c_addr_df.Set(config.i2c_addr);
i2c_addr_control.RefreshDisplay();
WndProperty &press_control = GetControl(PressureUsage);
DataFieldEnum &press_df = *(DataFieldEnum *)
press_control.GetDataField();
press_df.Set((unsigned)config.press_use);
press_control.RefreshDisplay();
WndProperty &driver_control = GetControl(Driver);
DataFieldEnum &driver_df = *(DataFieldEnum *)driver_control.GetDataField();
driver_df.Set(config.driver_name);
driver_control.RefreshDisplay();
WndProperty &sync_from_control = GetControl(SyncFromDevice);
DataFieldBoolean &sync_from_df =
*(DataFieldBoolean *)sync_from_control.GetDataField();
sync_from_df.Set(config.sync_from_device);
sync_from_control.RefreshDisplay();
WndProperty &sync_to_control = GetControl(SyncToDevice);
DataFieldBoolean &sync_to_df =
*(DataFieldBoolean *)sync_to_control.GetDataField();
sync_to_df.Set(config.sync_to_device);
sync_to_control.RefreshDisplay();
WndProperty &k6bt_control = GetControl(K6Bt);
DataFieldBoolean &k6bt_df =
*(DataFieldBoolean *)k6bt_control.GetDataField();
k6bt_df.Set(config.k6bt);
k6bt_control.RefreshDisplay();
UpdateVisibilities();
}
示例2: GetControl
void* Interface_GUIWindow::get_control_spin(void* kodiBase, void* handle, int control_id)
{
return GetControl(kodiBase, handle, control_id, __FUNCTION__, CGUIControl::GUICONTROL_SPINEX, "spin");
}
示例3: switch
bool CGUIDialogKeyboardGeneric::OnMessage(CGUIMessage& message)
{
switch ( message.GetMessage() )
{
case GUI_MSG_CLICKED:
{
int iControl = message.GetSenderId();
switch (iControl)
{
case CTL_BUTTON_DONE:
OnOK();
break;
case CTL_BUTTON_CANCEL:
Close();
break;
case CTL_BUTTON_SHIFT:
OnShift();
break;
case CTL_BUTTON_CAPS:
if (m_keyType == LOWER)
m_keyType = CAPS;
else if (m_keyType == CAPS)
m_keyType = LOWER;
UpdateButtons();
break;
case CTL_BUTTON_LAYOUT:
OnLayout();
break;
case CTL_BUTTON_SYMBOLS:
OnSymbols();
break;
case CTL_BUTTON_LEFT:
MoveCursor( -1);
break;
case CTL_BUTTON_RIGHT:
MoveCursor(1);
break;
case CTL_BUTTON_IP_ADDRESS:
OnIPAddress();
break;
case CTL_BUTTON_CLEAR:
SetEditText("");
break;
case CTL_EDIT:
{
CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), CTL_EDIT);
OnMessage(msg);
// update callback I guess?
if (m_pCharCallback)
{ // we did _something_, so make sure our search message filter is reset
m_pCharCallback(this, msg.GetLabel());
}
m_text = msg.GetLabel();
return true;
}
default:
OnClickButton(iControl);
break;
}
}
break;
case GUI_MSG_SET_TEXT:
case GUI_MSG_INPUT_TEXT_EDIT:
{
// the edit control only handles these messages if it is either focues
// or its specific control ID is set in the message. As neither is the
// case here (focus is on one of the keyboard buttons) we have to force
// the control ID of the message to the control ID of the edit control
// (unfortunately we have to create a whole copy of the message object for that)
CGUIMessage messageCopy(message.GetMessage(), message.GetSenderId(), CTL_EDIT, message.GetParam1(), message.GetParam2(), message.GetItem());
messageCopy.SetLabel(message.GetLabel());
// ensure this goes to the edit control
CGUIControl *edit = GetControl(CTL_EDIT);
if (edit)
edit->OnMessage(messageCopy);
// close the dialog if requested
if (message.GetMessage() == GUI_MSG_SET_TEXT && message.GetParam1() > 0)
OnOK();
return true;
}
}
return CGUIDialog::OnMessage(message);
}
示例4: GetControl
void CGUIWindowSettingsScreenCalibration::UpdateFromControl(int iControl)
{
std::string strStatus;
RESOLUTION_INFO info = g_graphicsContext.GetResInfo(m_Res[m_iCurRes]);
if (iControl == CONTROL_PIXEL_RATIO)
{
CGUIControl *pControl = GetControl(CONTROL_PIXEL_RATIO);
if (pControl)
{
float fWidth = (float)pControl->GetWidth();
float fHeight = (float)pControl->GetHeight();
info.fPixelRatio = fHeight / fWidth;
// recenter our control...
pControl->SetPosition((info.iWidth - pControl->GetWidth()) / 2,
(info.iHeight - pControl->GetHeight()) / 2);
strStatus = StringUtils::Format("%s (%5.3f)", g_localizeStrings.Get(275).c_str(), info.fPixelRatio);
SET_CONTROL_LABEL(CONTROL_LABEL_ROW2, 278);
}
}
else
{
const CGUIMoverControl *pControl = dynamic_cast<const CGUIMoverControl*>(GetControl(iControl));
if (pControl)
{
switch (iControl)
{
case CONTROL_TOP_LEFT:
{
info.Overscan.left = pControl->GetXLocation();
info.Overscan.top = pControl->GetYLocation();
strStatus = StringUtils::Format("%s (%i,%i)", g_localizeStrings.Get(272).c_str(), pControl->GetXLocation(), pControl->GetYLocation());
SET_CONTROL_LABEL(CONTROL_LABEL_ROW2, 276);
}
break;
case CONTROL_BOTTOM_RIGHT:
{
info.Overscan.right = pControl->GetXLocation();
info.Overscan.bottom = pControl->GetYLocation();
int iXOff1 = info.iWidth - pControl->GetXLocation();
int iYOff1 = info.iHeight - pControl->GetYLocation();
strStatus = StringUtils::Format("%s (%i,%i)", g_localizeStrings.Get(273).c_str(), iXOff1, iYOff1);
SET_CONTROL_LABEL(CONTROL_LABEL_ROW2, 276);
}
break;
case CONTROL_SUBTITLES:
{
info.iSubtitles = pControl->GetYLocation();
strStatus = StringUtils::Format("%s (%i)", g_localizeStrings.Get(274).c_str(), pControl->GetYLocation());
SET_CONTROL_LABEL(CONTROL_LABEL_ROW2, 277);
}
break;
}
}
}
g_graphicsContext.SetResInfo(m_Res[m_iCurRes], info);
// set the label control correctly
std::string strText;
if (g_Windowing.IsFullScreen())
strText = StringUtils::Format("%ix%[email protected]%.2f - %s | %s",
info.iScreenWidth,
info.iScreenHeight,
info.fRefreshRate,
g_localizeStrings.Get(244).c_str(),
strStatus.c_str());
else
strText = StringUtils::Format("%ix%i - %s | %s",
info.iScreenWidth,
info.iScreenHeight,
g_localizeStrings.Get(242).c_str(),
strStatus.c_str());
SET_CONTROL_LABEL(CONTROL_LABEL_ROW1, strText);
}
示例5: GetWindow
void
RowFormWidget::UpdateLayout()
{
PixelRect current_rect = GetWindow()->GetClientRect();
const unsigned total_width = current_rect.right - current_rect.left;
const unsigned total_height = current_rect.bottom - current_rect.top;
current_rect.bottom = current_rect.top;
const bool expert = UIGlobals::GetDialogSettings().expert;
/* first row traversal: count the number of "elastic" rows and
determine the minimum total height */
unsigned min_height = 0;
unsigned n_elastic = 0;
unsigned caption_width = 0;
for (auto i = rows.begin(), end = rows.end(); i != end; ++i) {
if (!i->available || (i->expert && !expert))
continue;
min_height += i->GetMinimumHeight();
if (i->IsElastic())
++n_elastic;
if (i->type == Row::Type::EDIT) {
unsigned cw = i->GetControl().GetRecommendedCaptionWidth();
if (cw > caption_width)
caption_width = cw;
}
}
if (caption_width * 3 > total_width * 2)
caption_width = total_width * 2 / 3;
/* how much excess height in addition to the minimum height? */
unsigned excess_height = min_height < total_height
? total_height - min_height
: 0;
/* second row traversal: now move and resize the rows */
for (auto i = rows.begin(), end = rows.end(); i != end; ++i) {
if (i->type == Row::Type::DUMMY)
continue;
Window &window = i->GetWindow();
if (!i->available) {
window.Hide();
continue;
}
if (i->expert) {
if (!expert) {
window.Hide();
continue;
}
if (i->visible)
window.Show();
}
if (caption_width > 0 && i->type == Row::Type::EDIT &&
i->GetControl().HasCaption())
i->GetControl().SetCaptionWidth(caption_width);
/* determine this row's height */
UPixelScalar height = i->GetMinimumHeight();
if (excess_height > 0 && i->IsElastic()) {
assert(n_elastic > 0);
/* distribute excess height among all elastic rows */
unsigned grow_height = excess_height / n_elastic;
if (grow_height > 0) {
height += grow_height;
const UPixelScalar max_height = i->GetMaximumHeight();
if (height > max_height) {
/* never grow beyond declared maximum height */
height = max_height;
grow_height = max_height - height;
}
excess_height -= grow_height;
}
--n_elastic;
}
/* finally move and resize */
NextControlRect(current_rect, height);
window.Move(current_rect);
}
assert(excess_height == 0 || n_elastic == 0);
}
示例6: CGUIButtonControl
void CGUIDialogContextMenu::SetupButtons()
{
if (!m_buttons.size())
return;
// disable the template button control
CGUIButtonControl *pButtonTemplate = dynamic_cast<CGUIButtonControl *>(GetFirstFocusableControl(BUTTON_TEMPLATE));
if (!pButtonTemplate)
pButtonTemplate = dynamic_cast<CGUIButtonControl *>(GetControl(BUTTON_TEMPLATE));
if (!pButtonTemplate)
return;
pButtonTemplate->SetVisible(false);
CGUIControlGroupList* pGroupList = dynamic_cast<CGUIControlGroupList *>(GetControl(GROUP_LIST));
// add our buttons
for (unsigned int i = 0; i < m_buttons.size(); i++)
{
CGUIButtonControl *pButton = new CGUIButtonControl(*pButtonTemplate);
if (pButton)
{ // set the button's ID and position
int id = BUTTON_START + i;
pButton->SetID(id);
pButton->SetVisible(true);
pButton->SetLabel(m_buttons[i].second);
if (pGroupList)
{
pButton->SetPosition(pButtonTemplate->GetXPosition(), pButtonTemplate->GetYPosition());
// try inserting context buttons at position specified by template
// button, if template button is not in grouplist fallback to adding
// new buttons at the end of grouplist
if (!pGroupList->InsertControl(pButton, pButtonTemplate))
pGroupList->AddControl(pButton);
}
}
}
// fix up background images placement and size
CGUIControl *pControl = GetControl(BACKGROUND_IMAGE);
if (pControl)
{
// first set size of background image
if (pGroupList)
{
if (pGroupList->GetOrientation() == VERTICAL)
{
// keep gap between bottom edges of grouplist and background image
pControl->SetHeight(m_backgroundImageSize - pGroupList->Size() + pGroupList->GetHeight());
}
else
{
// keep gap between right edges of grouplist and background image
pControl->SetWidth(m_backgroundImageSize - pGroupList->Size() + pGroupList->GetWidth());
}
}
}
// update our default control
if (pGroupList)
m_defaultControl = pGroupList->GetID();
}
示例7: GetControl
void CXTPReportColumn::EnsureVisible()
{
CXTPReportControl* pControl = GetControl();
if (pControl)
pControl->EnsureVisible(this);
}
示例8: ASSERT
FX_BOOL CPDF_FormField::CheckControl(int iControlIndex,
bool bChecked,
bool bNotify) {
ASSERT(GetType() == CheckBox || GetType() == RadioButton);
CPDF_FormControl* pControl = GetControl(iControlIndex);
if (!pControl) {
return FALSE;
}
if (!bChecked && pControl->IsChecked() == bChecked) {
return FALSE;
}
CFX_WideString csWExport = pControl->GetExportValue();
CFX_ByteString csBExport = PDF_EncodeText(csWExport);
int iCount = CountControls();
FX_BOOL bUnison = PDF_FormField_IsUnison(this);
for (int i = 0; i < iCount; i++) {
CPDF_FormControl* pCtrl = GetControl(i);
if (bUnison) {
CFX_WideString csEValue = pCtrl->GetExportValue();
if (csEValue == csWExport) {
if (pCtrl->GetOnStateName() == pControl->GetOnStateName()) {
pCtrl->CheckControl(bChecked);
} else if (bChecked) {
pCtrl->CheckControl(FALSE);
}
} else if (bChecked) {
pCtrl->CheckControl(FALSE);
}
} else {
if (i == iControlIndex) {
pCtrl->CheckControl(bChecked);
} else if (bChecked) {
pCtrl->CheckControl(FALSE);
}
}
}
CPDF_Object* pOpt = FPDF_GetFieldAttr(m_pDict, "Opt");
if (!ToArray(pOpt)) {
if (bChecked) {
m_pDict->SetAtName("V", csBExport);
} else {
CFX_ByteString csV;
CPDF_Object* pV = FPDF_GetFieldAttr(m_pDict, "V");
if (pV) {
csV = pV->GetString();
}
if (csV == csBExport) {
m_pDict->SetAtName("V", "Off");
}
}
} else if (bChecked) {
CFX_ByteString csIndex;
csIndex.Format("%d", iControlIndex);
m_pDict->SetAtName("V", csIndex);
}
if (bNotify && m_pForm->m_pFormNotify) {
m_pForm->m_pFormNotify->AfterCheckedStatusChange(this);
}
m_pForm->m_bUpdated = TRUE;
return TRUE;
}
示例9: switch
FX_BOOL CPDF_FormField::ResetField(FX_BOOL bNotify) {
switch (m_Type) {
case CPDF_FormField::CheckBox:
case CPDF_FormField::RadioButton: {
int iCount = CountControls();
if (iCount) {
if (PDF_FormField_IsUnison(this)) {
for (int i = 0; i < iCount; i++) {
CheckControl(i, GetControl(i)->IsDefaultChecked(), FALSE);
}
} else {
for (int i = 0; i < iCount; i++) {
CPDF_FormControl* pControl = GetControl(i);
FX_BOOL bChecked = pControl->IsDefaultChecked();
CheckControl(i, bChecked, FALSE);
}
}
}
if (bNotify && m_pForm->m_pFormNotify) {
m_pForm->m_pFormNotify->AfterCheckedStatusChange(this);
}
} break;
case CPDF_FormField::ComboBox: {
CFX_WideString csValue;
ClearSelection();
int iIndex = GetDefaultSelectedItem();
if (iIndex >= 0) {
csValue = GetOptionLabel(iIndex);
}
if (bNotify && m_pForm->m_pFormNotify) {
int iRet = m_pForm->m_pFormNotify->BeforeValueChange(this, csValue);
if (iRet < 0) {
return FALSE;
}
}
SetItemSelection(iIndex, TRUE);
if (bNotify && m_pForm->m_pFormNotify) {
m_pForm->m_pFormNotify->AfterValueChange(this);
}
} break;
case CPDF_FormField::ListBox: {
CFX_WideString csValue;
ClearSelection();
int iIndex = GetDefaultSelectedItem();
if (iIndex >= 0) {
csValue = GetOptionLabel(iIndex);
}
if (bNotify && m_pForm->m_pFormNotify) {
int iRet = m_pForm->m_pFormNotify->BeforeSelectionChange(this, csValue);
if (iRet < 0) {
return FALSE;
}
}
SetItemSelection(iIndex, TRUE);
if (bNotify && m_pForm->m_pFormNotify) {
m_pForm->m_pFormNotify->AfterSelectionChange(this);
}
} break;
case CPDF_FormField::Text:
case CPDF_FormField::RichText:
case CPDF_FormField::File:
default: {
CPDF_Object* pDV = FPDF_GetFieldAttr(m_pDict, "DV");
CFX_WideString csDValue;
if (pDV) {
csDValue = pDV->GetUnicodeText();
}
CPDF_Object* pV = FPDF_GetFieldAttr(m_pDict, "V");
CFX_WideString csValue;
if (pV) {
csValue = pV->GetUnicodeText();
}
CPDF_Object* pRV = FPDF_GetFieldAttr(m_pDict, "RV");
if (!pRV && (csDValue == csValue)) {
return FALSE;
}
if (bNotify && m_pForm->m_pFormNotify) {
int iRet = m_pForm->m_pFormNotify->BeforeValueChange(this, csDValue);
if (iRet < 0) {
return FALSE;
}
}
if (pDV) {
CPDF_Object* pClone = pDV->Clone();
if (!pClone) {
return FALSE;
}
m_pDict->SetAt("V", pClone);
if (pRV) {
CPDF_Object* pCloneR = pDV->Clone();
m_pDict->SetAt("RV", pCloneR);
}
} else {
m_pDict->RemoveAt("V");
m_pDict->RemoveAt("RV");
}
if (bNotify && m_pForm->m_pFormNotify) {
m_pForm->m_pFormNotify->AfterValueChange(this);
}
m_pForm->m_bUpdated = TRUE;
//.........这里部分代码省略.........
示例10: switch
bool CGUIDialogKeyboardGeneric::OnMessage(CGUIMessage& message)
{
switch ( message.GetMessage() )
{
case GUI_MSG_CLICKED:
{
int iControl = message.GetSenderId();
switch (iControl)
{
case CTL_BUTTON_DONE:
OnOK();
break;
case CTL_BUTTON_CANCEL:
Close();
break;
case CTL_BUTTON_SHIFT:
OnShift();
break;
case CTL_BUTTON_CAPS:
if (m_keyType == LOWER)
m_keyType = CAPS;
else if (m_keyType == CAPS)
m_keyType = LOWER;
UpdateButtons();
break;
case CTL_BUTTON_SYMBOLS:
OnSymbols();
break;
case CTL_BUTTON_LEFT:
MoveCursor( -1);
break;
case CTL_BUTTON_RIGHT:
MoveCursor(1);
break;
case CTL_BUTTON_IP_ADDRESS:
OnIPAddress();
break;
case CTL_BUTTON_CLEAR:
SetEditText("");
break;
case CTL_EDIT:
{
CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), CTL_EDIT);
OnMessage(msg);
// update callback I guess?
if (m_pCharCallback)
{ // we did _something_, so make sure our search message filter is reset
m_pCharCallback(this, msg.GetLabel());
}
m_text = msg.GetLabel();
return true;
}
default:
OnClickButton(iControl);
break;
}
}
break;
case GUI_MSG_SET_TEXT:
case GUI_MSG_INPUT_TEXT:
case GUI_MSG_INPUT_TEXT_EDIT:
{
// ensure this goes to the edit control
CGUIControl *edit = GetControl(CTL_EDIT);
if (edit)
edit->OnMessage(message);
// close the dialog if requested
if (message.GetMessage() == GUI_MSG_SET_TEXT && message.GetParam1() > 0)
OnOK();
return true;
}
}
return CGUIDialog::OnMessage(message);
}
示例11: switch
FX_BOOL CPDF_FormField::ResetField(FX_BOOL bNotify) {
switch (m_Type) {
case CPDF_FormField::CheckBox:
case CPDF_FormField::RadioButton: {
int iCount = CountControls();
if (iCount) {
// TODO(weili): Check whether anything special needs to be done for
// unison field. Otherwise, merge these branches.
if (PDF_FormField_IsUnison(this)) {
for (int i = 0; i < iCount; i++) {
CheckControl(i, GetControl(i)->IsDefaultChecked(), FALSE);
}
} else {
for (int i = 0; i < iCount; i++) {
CheckControl(i, GetControl(i)->IsDefaultChecked(), FALSE);
}
}
}
if (bNotify && m_pForm->m_pFormNotify) {
m_pForm->m_pFormNotify->AfterCheckedStatusChange(this);
}
} break;
case CPDF_FormField::ComboBox:
case CPDF_FormField::ListBox: {
CFX_WideString csValue;
ClearSelection();
int iIndex = GetDefaultSelectedItem();
if (iIndex >= 0)
csValue = GetOptionLabel(iIndex);
if (bNotify && !NotifyListOrComboBoxBeforeChange(csValue))
return FALSE;
SetItemSelection(iIndex, TRUE);
if (bNotify)
NotifyListOrComboBoxAfterChange();
} break;
case CPDF_FormField::Text:
case CPDF_FormField::RichText:
case CPDF_FormField::File:
default: {
CPDF_Object* pDV = FPDF_GetFieldAttr(m_pDict, "DV");
CFX_WideString csDValue;
if (pDV)
csDValue = pDV->GetUnicodeText();
CPDF_Object* pV = FPDF_GetFieldAttr(m_pDict, "V");
CFX_WideString csValue;
if (pV)
csValue = pV->GetUnicodeText();
CPDF_Object* pRV = FPDF_GetFieldAttr(m_pDict, "RV");
if (!pRV && (csDValue == csValue))
return FALSE;
if (bNotify && !NotifyBeforeValueChange(csDValue))
return FALSE;
if (pDV) {
CPDF_Object* pClone = pDV->Clone();
if (!pClone)
return FALSE;
m_pDict->SetAt("V", pClone);
if (pRV) {
CPDF_Object* pCloneR = pDV->Clone();
m_pDict->SetAt("RV", pCloneR);
}
} else {
m_pDict->RemoveAt("V");
m_pDict->RemoveAt("RV");
}
if (bNotify)
NotifyAfterValueChange();
} break;
}
return TRUE;
}
示例12: InitializeState
Eigen::VectorXi TvlqrControl::GetControl(const mav_pose_t *msg) {
if (current_trajectory_ == NULL) {
cerr << "Warning: NULL trajectory in GetControl." << endl;
return converter_->GetTrimCommands();
}
//std::cout << "in GetControl" << std::endl;
// check to see if this is the first state we've gotten along this trajectory
if (state_initialized_ == false) {
InitializeState(msg);
}
Eigen::VectorXd state_minus_init = GetStateMinusInit(msg);
/*
printf("BEFORE\troll: %f\tpitch: %f\tyaw: %f\n", state_minus_init(3), state_minus_init(4), state_minus_init(5));
// unwrap angles
state_minus_init(3) = AngleUnwrap(state_minus_init(3), last_state_(3));
state_minus_init(4) = AngleUnwrap(state_minus_init(4), last_state_(4));
state_minus_init(5) = AngleUnwrap(state_minus_init(5), last_state_(5));
printf("AFTER\troll: %f\tpitch: %f\tyaw: %f\n", state_minus_init(3), state_minus_init(4), state_minus_init(5));
last_state_ = state_minus_init;
*/
double t_along_trajectory;
// check for TILQR case
if (current_trajectory_->IsTimeInvariant()) {
t_along_trajectory = 0;
} else {
t_along_trajectory = GetTNow();
}
if (t_along_trajectory <= current_trajectory_->GetMaxTime()) {
Eigen::VectorXd x0 = current_trajectory_->GetState(t_along_trajectory);
Eigen::MatrixXd gain_matrix = current_trajectory_->GetGainMatrix(t_along_trajectory);
Eigen::VectorXd state_error = state_minus_init - x0;
//cout << "state error = " << endl << state_error << endl;
Eigen::VectorXd additional_control_action = gain_matrix * state_error;
//cout << "additional control action = " << endl << additional_control_action << endl;
//cout << "t = " << t_along_trajectory << endl;
//cout << "gain" << endl << gain_matrix << endl << "state_error" << endl << state_error << endl << "additional" << endl << additional_control_action << endl;
Eigen::VectorXd command_in_rad = current_trajectory_->GetUCommand(t_along_trajectory) + additional_control_action;
//cout << "command_in_rad" << endl << command_in_rad << endl;
return converter_->RadiansToServoCommands(command_in_rad);
} else {
// we are past the max time, return stabilizing controller
SetTrajectory(stable_controller_);
return GetControl(msg);
//return converter_->GetTrimCommands();
}
}
示例13: SaveValue
bool
InterfaceConfigPanel::Save(bool &_changed)
{
UISettings &settings = CommonInterface::SetUISettings();
bool changed = false;;
#ifdef HAVE_BLANK
changed |= SaveValue(AutoBlank, ProfileKeys::AutoBlank,
settings.display.enable_auto_blank);
#endif
if (SaveValueFileReader(InputFile, ProfileKeys::InputFile))
require_restart = changed = true;
#ifndef HAVE_NATIVE_GETTEXT
WndProperty *wp = (WndProperty *)&GetControl(LanguageFile);
if (wp != NULL) {
DataFieldEnum &df = *(DataFieldEnum *)wp->GetDataField();
TCHAR old_value[MAX_PATH];
if (!Profile::GetPath(ProfileKeys::LanguageFile, old_value))
old_value[0] = _T('\0');
const TCHAR *old_base = BaseName(old_value);
if (old_base == NULL)
old_base = old_value;
TCHAR buffer[MAX_PATH];
const TCHAR *new_value, *new_base;
switch (df.GetValue()) {
case 0:
new_value = new_base = _T("auto");
break;
case 1:
new_value = new_base = _T("none");
break;
default:
_tcscpy(buffer, df.GetAsString());
ContractLocalPath(buffer);
new_value = buffer;
new_base = BaseName(new_value);
if (new_base == NULL)
new_base = new_value;
break;
}
if (_tcscmp(old_value, new_value) != 0 &&
_tcscmp(old_base, new_base) != 0) {
Profile::Set(ProfileKeys::LanguageFile, new_value);
LanguageChanged = changed = true;
}
}
#endif
if (SaveValueFileReader(StatusFile, ProfileKeys::StatusFile))
require_restart = changed = true;
unsigned menu_timeout = GetValueInteger(MenuTimeout) * 2;
if (settings.menu_timeout != menu_timeout) {
settings.menu_timeout = menu_timeout;
Profile::Set(ProfileKeys::MenuTimeout, menu_timeout);
changed = true;
}
#ifdef HAVE_VIBRATOR
changed |= SaveValueEnum(HapticFeedback, ProfileKeys::HapticFeedback, settings.haptic_feedback);
#endif
_changed |= changed;
return true;
}
示例14: InternalHandleMessage
BOOL CEventPropertiesFireTriggerDialog::HandleMessage( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
m_hDialog = hwndDlg;
bool handled = false;
BOOL bret = InternalHandleMessage( &g_Params, hwndDlg, uMsg, wParam, lParam, handled );
if ( handled )
return bret;
switch(uMsg)
{
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc;
hdc = BeginPaint(hwndDlg, &ps);
DrawSpline( hdc, GetControl( IDC_STATIC_SPLINE ), g_Params.m_pEvent );
EndPaint(hwndDlg, &ps);
return FALSE;
}
break;
case WM_VSCROLL:
{
RECT rcOut;
GetSplineRect( GetControl( IDC_STATIC_SPLINE ), rcOut );
InvalidateRect( hwndDlg, &rcOut, TRUE );
UpdateWindow( hwndDlg );
return FALSE;
}
break;
case WM_INITDIALOG:
{
InitDialog( hwndDlg );
}
return FALSE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
{
HWND control = GetControl( IDC_EVENTCHOICES );
if ( control )
{
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters ), (LPARAM)g_Params.m_szParameters );
}
GetDlgItemText( m_hDialog, IDC_EVENTNAME, g_Params.m_szName, sizeof( g_Params.m_szName ) );
if ( !g_Params.m_szName[ 0 ] )
{
Q_snprintf( g_Params.m_szName, sizeof( g_Params.m_szName ), "Firetrigger %s", g_Params.m_szParameters );
}
char szTime[ 32 ];
GetDlgItemText( m_hDialog, IDC_STARTTIME, szTime, sizeof( szTime ) );
g_Params.m_flStartTime = atof( szTime );
GetDlgItemText( m_hDialog, IDC_ENDTIME, szTime, sizeof( szTime ) );
g_Params.m_flEndTime = atof( szTime );
// Parse tokens from tags
ParseTags( &g_Params );
EndDialog( hwndDlg, 1 );
}
break;
case IDCANCEL:
EndDialog( hwndDlg, 0 );
break;
case IDC_CHECK_ENDTIME:
{
g_Params.m_bHasEndTime = SendMessage( GetControl( IDC_CHECK_ENDTIME ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
if ( !g_Params.m_bHasEndTime )
{
ShowWindow( GetControl( IDC_ENDTIME ), SW_HIDE );
}
else
{
ShowWindow( GetControl( IDC_ENDTIME ), SW_RESTORE );
}
}
break;
case IDC_CHECK_RESUMECONDITION:
{
g_Params.m_bResumeCondition = SendMessage( GetControl( IDC_CHECK_RESUMECONDITION ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false;
}
break;
case IDC_EVENTCHOICES:
{
HWND control = (HWND)lParam;
if ( control )
{
SendMessage( control, WM_GETTEXT, (WPARAM)sizeof( g_Params.m_szParameters ), (LPARAM)g_Params.m_szParameters );
}
}
break;
case IDC_ABSOLUTESTART:
{
//.........这里部分代码省略.........
示例15: DialogProc
BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
// handle notifications
case WM_COMMAND:
{
HWND hwCtl = GetDlgItem(hwndDlg, LOWORD(wParam));
struct nsControl* ctl = GetControl(hwCtl);
if (ctl == NULL)
break;
if (HIWORD(wParam) == BN_CLICKED && (ctl->type == NSCTL_BUTTON || ctl->type == NSCTL_LINK))
{
if (ctl->callbacks.onClick)
{
pushint((int) hwCtl);
g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onClick - 1, 0);
}
}
else if (HIWORD(wParam) == EN_CHANGE && ctl->type == NSCTL_EDIT)
{
if (ctl->callbacks.onChange)
{
pushint((int) hwCtl);
g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0);
}
}
else if (HIWORD(wParam) == LBN_SELCHANGE && ctl->type == NSCTL_LISTBOX)
{
if (ctl->callbacks.onChange)
{
pushint((int) hwCtl);
g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0);
}
}
else if ((HIWORD(wParam) == CBN_EDITUPDATE || HIWORD(wParam) == CBN_SELCHANGE)
&& ctl->type == NSCTL_COMBOBOX)
{
if (ctl->callbacks.onChange)
{
pushint((int) hwCtl);
g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0);
}
}
else if (HIWORD(wParam) == STN_CLICKED && ctl->type == NSCTL_STATIC)
{
if (ctl->callbacks.onClick)
{
pushint((int) hwCtl);
g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onClick - 1, 0);
}
}
break;
}
case WM_NOTIFY:
{
LPNMHDR nmhdr = (LPNMHDR) lParam;
struct nsControl* ctl = GetControl(nmhdr->hwndFrom);
if (ctl == NULL)
break;
if (!ctl->callbacks.onNotify)
break;
pushint((int) nmhdr);
pushint(nmhdr->code);
pushint((int) nmhdr->hwndFrom);
g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onNotify - 1, 0);
}
// handle links
case WM_DRAWITEM:
{
DRAWITEMSTRUCT* lpdis = (DRAWITEMSTRUCT*)lParam;
RECT rc;
TCHAR text[1024];
// http://blogs.msdn.com/oldnewthing/archive/2005/05/03/414317.aspx#414357
// says we should call SystemParametersInfo(SPI_GETKEYBOARDCUES,...) to make
// sure, does not seem to be required, might be a win2k bug, or it might
// only apply to menus
BOOL hideFocus = (lpdis->itemState & ODS_NOFOCUSRECT);
BOOL hideAccel = (lpdis->itemState & ODS_NOACCEL);
struct nsControl* ctl = GetControl(lpdis->hwndItem);
if (ctl == NULL)
break;
// We need lpdis->rcItem later
rc = lpdis->rcItem;
// Get button's text
text[0] = _T('\0');
GetWindowText(lpdis->hwndItem, text, 1024);
//.........这里部分代码省略.........