本文整理汇总了C++中CSettingList类的典型用法代码示例。如果您正苦于以下问题:C++ CSettingList类的具体用法?C++ CSettingList怎么用?C++ CSettingList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CSettingList类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnClick
bool CGUIControlRangeSetting::OnClick()
{
if (m_pSlider == NULL ||
m_pSetting->GetType() != SettingTypeList)
return false;
CSettingList *settingList = static_cast<CSettingList*>(m_pSetting);
const SettingPtrList &settingListValues = settingList->GetValue();
if (settingListValues.size() != 2)
return false;
std::vector<CVariant> values;
const CSetting *listDefintion = settingList->GetDefinition();
switch (listDefintion->GetType())
{
case SettingTypeInteger:
values.push_back(m_pSlider->GetIntValue(CGUISliderControl::RangeSelectorLower));
values.push_back(m_pSlider->GetIntValue(CGUISliderControl::RangeSelectorUpper));
break;
case SettingTypeNumber:
values.push_back(m_pSlider->GetFloatValue(CGUISliderControl::RangeSelectorLower));
values.push_back(m_pSlider->GetFloatValue(CGUISliderControl::RangeSelectorUpper));
break;
default:
return false;
}
if (values.size() != 2)
return false;
SetValid(CSettingUtils::SetList(settingList, values));
return IsValid();
}
示例2: SetList
bool CSettings::SetList(const std::string &id, const std::vector<CVariant> &value)
{
CSetting *setting = m_settingsManager->GetSetting(id);
if (setting == NULL || setting->GetType() != SettingTypeList)
return false;
CSettingList *listSetting = static_cast<CSettingList*>(setting);
SettingPtrList newValues;
bool ret = true;
int index = 0;
for (std::vector<CVariant>::const_iterator itValue = value.begin(); itValue != value.end(); ++itValue)
{
CSetting *settingValue = listSetting->GetDefinition()->Clone(StringUtils::Format("%s.%d", listSetting->GetId().c_str(), index++));
if (settingValue == NULL)
return false;
switch (listSetting->GetElementType())
{
case SettingTypeBool:
if (!itValue->isBoolean())
return false;
ret = static_cast<CSettingBool*>(settingValue)->SetValue(itValue->asBoolean());
break;
case SettingTypeInteger:
if (!itValue->isInteger())
return false;
ret = static_cast<CSettingInt*>(settingValue)->SetValue((int)itValue->asInteger());
break;
case SettingTypeNumber:
if (!itValue->isDouble())
return false;
ret = static_cast<CSettingNumber*>(settingValue)->SetValue(itValue->asDouble());
break;
case SettingTypeString:
if (!itValue->isString())
return false;
ret = static_cast<CSettingString*>(settingValue)->SetValue(itValue->asString());
break;
default:
ret = false;
break;
}
if (!ret)
{
delete settingValue;
return false;
}
newValues.push_back(SettingPtr(settingValue));
}
return listSetting->SetValue(newValues);
}
示例3: ListToValues
std::vector<CVariant> CSettings::GetList(const std::string &id) const
{
CSetting *setting = m_settingsManager->GetSetting(id);
if (setting == NULL || setting->GetType() != SettingTypeList)
return std::vector<CVariant>();
CSettingList *listSetting = static_cast<CSettingList*>(setting);
return ListToValues(listSetting, listSetting->GetValue());
}
示例4: new
/**
* Construct the control (first phase).
* Creates an instance and initializes it.
* Instance is left on cleanup stack.
* @param aRect The rectangle for this window
* @param aParent owning parent, or NULL
* @param aCommandObserver command observer
* @return new instance of CSettingList
*/
CSettingList* CSettingList::NewLC(
const TRect& aRect,
const CCoeControl* aParent,
MEikCommandObserver* aCommandObserver )
{
CSettingList* self = new ( ELeave ) CSettingList();
CleanupStack::PushL( self );
self->ConstructL( aRect, aParent, aCommandObserver );
return self;
}
示例5: CGUIControlBaseSetting
CGUIControlRangeSetting::CGUIControlRangeSetting(CGUISettingsSliderControl *pSlider, int id, CSetting *pSetting)
: CGUIControlBaseSetting(id, pSetting)
{
m_pSlider = pSlider;
if (m_pSlider == NULL)
return;
m_pSlider->SetID(id);
m_pSlider->SetRangeSelection(true);
if (m_pSetting->GetType() == SettingTypeList)
{
CSettingList *settingList = static_cast<CSettingList*>(m_pSetting);
const CSetting *listDefintion = settingList->GetDefinition();
switch (listDefintion->GetType())
{
case SettingTypeInteger:
{
const CSettingInt *listDefintionInt = static_cast<const CSettingInt*>(listDefintion);
if (m_pSetting->GetControl()->GetFormat() == "percentage")
m_pSlider->SetType(SLIDER_CONTROL_TYPE_PERCENTAGE);
else
{
m_pSlider->SetType(SLIDER_CONTROL_TYPE_INT);
m_pSlider->SetRange(listDefintionInt->GetMinimum(), listDefintionInt->GetMaximum());
}
m_pSlider->SetIntInterval(listDefintionInt->GetStep());
break;
}
case SettingTypeNumber:
{
const CSettingNumber *listDefinitionNumber = static_cast<const CSettingNumber*>(listDefintion);
m_pSlider->SetType(SLIDER_CONTROL_TYPE_FLOAT);
m_pSlider->SetFloatRange((float)listDefinitionNumber->GetMinimum(), (float)listDefinitionNumber->GetMaximum());
m_pSlider->SetFloatInterval((float)listDefinitionNumber->GetStep());
break;
}
default:
break;
}
}
Update();
}
示例6: GetSetting
CSettingList* CGUIDialogSettingsManualBase::AddRange(CSettingGroup *group, const std::string &id, int label, int level, float valueLower, float valueUpper, float minimum,
float step, float maximum, const std::string &format, int formatLabel, int valueFormatLabel,
const std::string &valueFormatString, bool delayed, bool visible, int help)
{
if (group == NULL || id.empty() || label < 0 ||
GetSetting(id) != NULL)
return NULL;
CSettingNumber *settingDefinition = new CSettingNumber(id, m_settingsManager);
if (settingDefinition == NULL)
return NULL;
settingDefinition->SetMinimum(minimum);
settingDefinition->SetStep(step);
settingDefinition->SetMaximum(maximum);
CSettingList *setting = new CSettingList(id, settingDefinition, label, m_settingsManager);
if (setting == NULL)
{
delete settingDefinition;
return NULL;
}
std::vector<CVariant> valueList;
valueList.push_back(valueLower);
valueList.push_back(valueUpper);
SettingPtrList settingValues;
if (!CSettingUtils::ValuesToList(setting, valueList, settingValues))
{
delete settingDefinition;
delete setting;
return NULL;
}
// setting the default will also set the actual value on an unchanged setting
setting->SetDefault(settingValues);
setting->SetControl(GetRangeControl(format, delayed, formatLabel, valueFormatLabel, valueFormatString));
setting->SetMinimumItems(2);
setting->SetMaximumItems(2);
setSettingDetails(setting, level, visible, help);
group->AddSetting(setting);
return setting;
}
示例7: Update
void CGUIControlRangeSetting::Update(bool updateDisplayOnly /* = false */)
{
if (m_pSlider == NULL ||
m_pSetting->GetType() != SettingTypeList)
return;
CGUIControlBaseSetting::Update();
CSettingList *settingList = static_cast<CSettingList*>(m_pSetting);
const SettingPtrList &settingListValues = settingList->GetValue();
if (settingListValues.size() != 2)
return;
const CSetting *listDefintion = settingList->GetDefinition();
const CSettingControlRange *controlRange = static_cast<const CSettingControlRange*>(m_pSetting->GetControl());
const std::string &controlFormat = controlRange->GetFormat();
std::string strText;
std::string strTextLower, strTextUpper;
std::string formatString = g_localizeStrings.Get(controlRange->GetFormatLabel() > -1 ? controlRange->GetFormatLabel() : 21469);
std::string valueFormat = controlRange->GetValueFormat();
if (controlRange->GetValueFormatLabel() > -1)
valueFormat = g_localizeStrings.Get(controlRange->GetValueFormatLabel());
switch (listDefintion->GetType())
{
case SettingTypeInteger:
{
int valueLower, valueUpper;
if (updateDisplayOnly)
{
valueLower = m_pSlider->GetIntValue(CGUISliderControl::RangeSelectorLower);
valueUpper = m_pSlider->GetIntValue(CGUISliderControl::RangeSelectorUpper);
}
else
{
valueLower = static_cast<CSettingInt*>(settingListValues[0].get())->GetValue();
valueUpper = static_cast<CSettingInt*>(settingListValues[1].get())->GetValue();
m_pSlider->SetIntValue(valueLower, CGUISliderControl::RangeSelectorLower);
m_pSlider->SetIntValue(valueUpper, CGUISliderControl::RangeSelectorUpper);
}
if (controlFormat == "date" || controlFormat == "time")
{
CDateTime dateLower = (time_t)valueLower;
CDateTime dateUpper = (time_t)valueUpper;
if (controlFormat == "date")
{
if (valueFormat.empty())
{
strTextLower = dateLower.GetAsLocalizedDate();
strTextUpper = dateUpper.GetAsLocalizedDate();
}
else
{
strTextLower = dateLower.GetAsLocalizedDate(valueFormat);
strTextUpper = dateUpper.GetAsLocalizedDate(valueFormat);
}
}
else
{
if (valueFormat.empty())
valueFormat = "mm:ss";
strTextLower = dateLower.GetAsLocalizedTime(valueFormat);
strTextUpper = dateUpper.GetAsLocalizedTime(valueFormat);
}
}
else
{
strTextLower = StringUtils::Format(valueFormat.c_str(), valueLower);
strTextUpper = StringUtils::Format(valueFormat.c_str(), valueUpper);
}
if (valueLower != valueUpper)
strText = StringUtils::Format(formatString.c_str(), strTextLower.c_str(), strTextUpper.c_str());
else
strText = strTextLower;
break;
}
case SettingTypeNumber:
{
double valueLower, valueUpper;
if (updateDisplayOnly)
{
valueLower = static_cast<double>(m_pSlider->GetFloatValue(CGUISliderControl::RangeSelectorLower));
valueUpper = static_cast<double>(m_pSlider->GetFloatValue(CGUISliderControl::RangeSelectorUpper));
}
else
{
valueLower = static_cast<CSettingNumber*>(settingListValues[0].get())->GetValue();
valueUpper = static_cast<CSettingNumber*>(settingListValues[1].get())->GetValue();
m_pSlider->SetFloatValue((float)valueLower, CGUISliderControl::RangeSelectorLower);
m_pSlider->SetFloatValue((float)valueUpper, CGUISliderControl::RangeSelectorUpper);
}
strTextLower = StringUtils::Format(valueFormat.c_str(), valueLower);
if (valueLower != valueUpper)
//.........这里部分代码省略.........
示例8: setCameraExposure
void setCameraExposure()
{
int rv = system("v4l2-ctl -d /dev/video0 --set-ctrl exposure_auto=1");
usleep(1000000);
char buf2[128] = {0};
strcpy(buf2, "v4l2-ctl -d /dev/video0 --set-ctrl exposure_absolute=");
strcat(buf2, g_settings.getSettingText(CSetting::SETTING_EXPOSURE).c_str());
int rv2 = system(buf2);
usleep(1000000);
if (rv2 != 0)
{
printf("rv2 = %d, %s\n", rv2, buf2);
}
}
示例9: data_mat
/******************************************************************************
Description.: this thread worker grabs a frame and copies it to the global buffer
Input Value.: unused
Return Value: unused, always NULL
******************************************************************************/
void *cam_thread(void *arg) {
g_settings.init();
setCameraExposure();
CVideoFrame* pFrame = NULL;
#ifndef TEST_USE_JPEGS_NOT_CAMERA
int width = VIEW_PIXEL_X_WIDTH;
int height = VIEW_PIXEL_Y_HEIGHT;
IplImage * img = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 3); // obraz OpenCV
#endif
frameGrinder.init();
#ifdef TEST_USE_JPEGS_NOT_CAMERA
std::string sBasePath = "/home/";
sBasePath += HOME_NAME;
std::string sPath = sBasePath;
sPath += "/0243-20150125-22-21-46.jpg";
//sPath += "/0007-20150125-22-36-25.jpg";
cv::Mat frame1 = cv::imread(sPath.c_str(), CV_LOAD_IMAGE_COLOR);
if (frame1.empty()) {
dbgMsg_s("Failed to read image data from a file1\n");
}
sPath = sBasePath;
sPath += "/0243-20150125-22-21-46.jpg";
//sPath += "/0007-20150125-22-36-25.jpg";
cv::Mat frame2 = cv::imread(sPath.c_str(), CV_LOAD_IMAGE_COLOR);
if (frame2.empty()) {
dbgMsg_s("Failed to read image data from a file2\n");
}
bool toggle = false;
#endif
context *pcontext = (context*) arg;
pglobal = pcontext->pglobal;
/* set cleanup handler to cleanup allocated ressources */
pthread_cleanup_push(cam_cleanup, pcontext);
while (!pglobal->stop) {
while (pcontext->videoIn->streamingState == STREAMING_PAUSED) {
usleep(1); // maybe not the best way so FIXME
}
#ifdef TEST_USE_JPEGS_NOT_CAMERA
if (frameGrinder.safeGetFreeFrame(&pFrame)) {
if (toggle) {
pFrame->m_frame = frame1;
} else {
pFrame->m_frame = frame2;
}
toggle = (!toggle);
if (!pFrame->m_frame.empty()) {
frameGrinder.safeAddTail(pFrame, CVideoFrame::FRAME_QUEUE_WAIT_FOR_BLOB_DETECT);
} else {
dbgMsg_s("Frame is empty\n");
frameGrinder.safeAddTail(pFrame, CVideoFrame::FRAME_QUEUE_FREE);
}
frameGrinder.m_testMonitor.m_nTasksDone[CTestMonitor::TASK_DONE_CAMERA]++;
}
#else
/* grab a frame */
if (uvcGrab(pcontext->videoIn) < 0) {
IPRINT("Error grabbing frames\n");
exit(EXIT_FAILURE);
}
DBG("received frame of size: %d from plugin: %d\n", pcontext->videoIn->buf.bytesused, pcontext->id);
/*
* Workaround for broken, corrupted frames:
* Under low light conditions corrupted frames may get captured.
* The good thing is such frames are quite small compared to the regular pictures.
* For example a VGA (640x480) webcam picture is normally >= 8kByte large,
* corrupted frames are smaller.
*/
if (pcontext->videoIn->buf.bytesused < minimum_size) {
DBG("dropping too small frame, assuming it as broken\n");
continue;
}
if (g_settings.isDynamicSettingsEnabled())
{
g_settings.getValueFromFile(CSetting::SETTING_EXPOSURE);
}
if(g_settings.isValueChanged(CSetting::SETTING_EXPOSURE))
{
setCameraExposure();
}
#ifdef NO_CV_JUST_STREAM_THE_CAMERA
//.........这里部分代码省略.........
示例10: detectBlobs
void CUpperGoalDetector::detectBlobs(CVideoFrame * pFrame, CFrameGrinder* pFrameGrinder)
{
try
{
static struct timespec timeLastCameraFrame = {0};
static struct timespec timeNow = {0};
static cv::Scalar lowerBounds = cv::Scalar(79,0,150);
static cv::Scalar upperBounds = cv::Scalar(96,255,250);
cv::Mat img_hsv, img_blur, goal_blob;
static int iCount = 0;
int timeSinceLastCameraFrameMilliseconds = (int) CTestMonitor::getDeltaTimeMilliseconds(
timeLastCameraFrame,
pFrame->m_timeAddedToQueue[(int) CVideoFrame::FRAME_QUEUE_WAIT_FOR_BLOB_DETECT]);
timeLastCameraFrame = pFrame->m_timeAddedToQueue[(int) CVideoFrame::FRAME_QUEUE_WAIT_FOR_BLOB_DETECT];
// RBG is flawed as a way to filter based on color because the brightness is combined
// with the color info.
// Not so with HSV, where Hue and Saturation are maintained separately
// OpenCV has a handy conversion from RGB to HSV
cv::cvtColor(pFrame->m_frame, img_hsv, CV_BGR2HSV);
cv::GaussianBlur(img_hsv, img_blur, cv::Size(5,5),1.5);
// Look for the green hue we are emitting from the LED halo
if(g_settings.isDynamicSettingsEnabled())
{
g_settings.getValueFromFile(CSetting::SETTING_FILTER_HUE_LOWER_BOUND);
g_settings.getValueFromFile(CSetting::SETTING_FILTER_HUE_UPPER_BOUND);
}
if(g_settings.isValueChanged(CSetting::SETTING_FILTER_HUE_LOWER_BOUND))
{
lowerBounds = cv::Scalar(g_settings.getSetting(CSetting::SETTING_FILTER_HUE_LOWER_BOUND),0,150);
}
if(g_settings.isValueChanged(CSetting::SETTING_FILTER_HUE_UPPER_BOUND))
{
upperBounds = cv::Scalar(g_settings.getSetting(CSetting::SETTING_FILTER_HUE_UPPER_BOUND),255,250);
}
// Find the bright response from the retro-reflective tape
cv::inRange(img_blur, lowerBounds, upperBounds, goal_blob);
pFrame->m_filteredFrame = goal_blob.clone();
iCount++;
if ((iCount % 17) == 0)
{
pFrameGrinder->m_testMonitor.saveFrameToJpeg(pFrame->m_filteredFrame);
}
//Find the contours. Use the contourOutput Mat so the original image doesn't get overwritten
cv::vector<std::vector<cv::Point> > goalContours;
cv::findContours(goal_blob, goalContours, CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE);
CUpperGoalRectangle upperGoalRectangle;
float upperGoalAzimuthDegrees = 0.0;
float distanceToUpperGoalInches = 0.0;
bool isUpperGoalFound = false;
isUpperGoalFound = filterContours(goalContours, pFrame->m_frame.rows, pFrame->m_frame.cols,
upperGoalRectangle, upperGoalAzimuthDegrees, distanceToUpperGoalInches);
CTestMonitor::getTicks(&timeNow);
int timeLatencyThisCameraFrameMilliseconds = (int) CTestMonitor::getDeltaTimeMilliseconds(
pFrame->m_timeAddedToQueue[(int) CVideoFrame::FRAME_QUEUE_WAIT_FOR_BLOB_DETECT],
timeNow);
pFrame->m_targetInfo.updateTargetInfo(
timeSinceLastCameraFrameMilliseconds, timeLatencyThisCameraFrameMilliseconds,
isUpperGoalFound, upperGoalAzimuthDegrees, distanceToUpperGoalInches, upperGoalRectangle.center.x);
pFrame->updateAnnotationInfo(upperGoalRectangle);
m_gpioLed.setGreenLED(isUpperGoalFound, pFrame->m_timeRemovedFromQueue[(int) CVideoFrame::FRAME_QUEUE_WAIT_FOR_BLOB_DETECT]);
}
catch (...)
{
}
}