本文整理汇总了C++中Axis类的典型用法代码示例。如果您正苦于以下问题:C++ Axis类的具体用法?C++ Axis怎么用?C++ Axis使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Axis类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runstart
/** Set up the output workspace in a Workspace2D
* @param numentries :: number of log entries to output
* @param times :: vector of Kernel::DateAndTime
* @param values :: vector of log value in double
*/
void ExportTimeSeriesLog::setupWorkspace2D(int numentries,
vector<DateAndTime> ×,
vector<double> values) {
Kernel::DateAndTime runstart(
m_dataWS->run().getProperty("run_start")->value());
size_t size = static_cast<size_t>(numentries);
m_outWS = boost::dynamic_pointer_cast<MatrixWorkspace>(
WorkspaceFactory::Instance().create("Workspace2D", 1, size, size));
if (!m_outWS)
throw runtime_error(
"Unable to create a Workspace2D casted to MatrixWorkspace.");
MantidVec &vecX = m_outWS->dataX(0);
MantidVec &vecY = m_outWS->dataY(0);
MantidVec &vecE = m_outWS->dataE(0);
for (size_t i = 0; i < size; ++i) {
int64_t dtns = times[i].totalNanoseconds() - runstart.totalNanoseconds();
vecX[i] = static_cast<double>(dtns) * 1.0E-9;
vecY[i] = values[i];
vecE[i] = 0.0;
}
Axis *xaxis = m_outWS->getAxis(0);
xaxis->setUnit("Time");
return;
}
示例2: TH2F
TH2* RootWriter::CreateTH2(Histogram2D* h)
{
const Axis& xax = h->GetAxisX(), yax = h->GetAxisY();
const int xchannels = xax.GetBinCount();
const int ychannels = yax.GetBinCount();
TH2* mat = new TH2F( h->GetName().c_str(), h->GetTitle().c_str(),
xchannels, xax.GetLeft(), xax.GetRight(),
ychannels, yax.GetLeft(), yax.GetRight() );
mat->SetOption( "colz" );
mat->SetContour( 64 );
TAxis* rxax = mat->GetXaxis();
rxax->SetTitle(xax.GetTitle().c_str());
rxax->SetTitleSize(0.03);
rxax->SetLabelSize(0.03);
TAxis* ryax = mat->GetYaxis();
ryax->SetTitle(yax.GetTitle().c_str());
ryax->SetTitleSize(0.03);
ryax->SetLabelSize(0.03);
ryax->SetTitleOffset(1.3);
TAxis* zax = mat->GetZaxis();
zax->SetLabelSize(0.025);
for(int iy=0; iy<ychannels+2; ++iy)
for(int ix=0; ix<xchannels+2; ++ix)
mat->SetBinContent(ix, iy, h->GetBinContent(ix, iy));
mat->SetEntries( h->GetEntries() );
return mat;
}
示例3: rcAxis
void AxisPlot::DrawAxesArray(wxDC &dc, wxRect rc, AxisArray *axes, bool vertical)
{
wxRect rcAxis(rc);
for (size_t nAxis = 0; nAxis < axes->Count(); nAxis++) {
Axis *axis = (*axes)[nAxis];
wxCoord ext = axis->GetExtent(dc);
if (vertical) {
rcAxis.width = ext;
}
else {
rcAxis.height = ext;
}
axis->Draw(dc, rcAxis);
if (vertical) {
rcAxis.x += ext;
}
else {
rcAxis.y += ext;
}
}
}
示例4: check
void Pulsar::ComponentModel::evaluate (float *vals,
unsigned nvals, int icomp_selected)
{
//Construct the summed model
SumRule< Univariate<Scalar> > m;
if (icomp_selected >= 0)
{
check ("evaluate", icomp_selected);
m += components[icomp_selected];
}
else
{
for (unsigned icomp=0; icomp < components.size(); icomp++)
m += components[icomp];
}
// evaluate
Axis<double> argument;
m.set_argument (0, &argument);
for (unsigned i=0; i < nvals; i++)
{
argument.set_value( (i+0.5)/nvals * 2*M_PI );
vals[i] = m.evaluate();
}
}
示例5: Tcl_GetString
int Graph::createAxis(int objc, Tcl_Obj* const objv[])
{
char *string = Tcl_GetString(objv[3]);
if (string[0] == '-') {
Tcl_AppendResult(interp_, "name of axis \"", string,
"\" can't start with a '-'", NULL);
return TCL_ERROR;
}
int isNew;
Tcl_HashEntry* hPtr = Tcl_CreateHashEntry(&axes_.table, string, &isNew);
if (!isNew) {
Tcl_AppendResult(interp_, "axis \"", string, "\" already exists in \"",
Tcl_GetString(objv[0]), "\"", NULL);
return TCL_ERROR;
}
Axis* axisPtr = new Axis(this, Tcl_GetString(objv[3]), MARGIN_NONE, hPtr);
if (!axisPtr)
return TCL_ERROR;
Tcl_SetHashValue(hPtr, axisPtr);
if ((Tk_InitOptions(interp_, (char*)axisPtr->ops(), axisPtr->optionTable(), tkwin_) != TCL_OK) || (AxisObjConfigure(axisPtr, interp_, objc-4, objv+4) != TCL_OK)) {
delete axisPtr;
return TCL_ERROR;
}
return TCL_OK;
}
示例6: check
void Pulsar::ComponentModel::evaluate (float *vals,
unsigned nvals, int icomp_selected)
{
double phase_offset = 0;
if (report_absolute_phases)
phase_offset = phase->get_value().val;
if (verbose)
cerr << "Pulsar::ComponentModel::evaluate"
" phase_offset=" << phase_offset/(2*M_PI) << " turns" << endl;
//Construct the summed model
SumRule< Univariate<Scalar> > m;
if (icomp_selected >= 0)
{
check ("evaluate", icomp_selected);
m += components[icomp_selected];
}
else
{
for (unsigned icomp=0; icomp < components.size(); icomp++)
m += components[icomp];
}
// evaluate
Axis<double> argument;
m.set_argument (0, &argument);
for (unsigned i=0; i < nvals; i++)
{
argument.set_value( (i+0.5)/nvals * 2*M_PI + phase_offset );
vals[i] = m.evaluate();
}
}
示例7: switch
void wxChartPanel::OnScrollWin(wxScrollWinEvent &ev)
{
if (m_chart == NULL) {
return ;
}
Axis *axis = NULL;
switch (ev.GetOrientation()) {
case wxHORIZONTAL:
axis = m_chart->GetHorizScrolledAxis();
break;
case wxVERTICAL:
axis = m_chart->GetVertScrolledAxis();
break;
default: // BUG
return ;
}
if (axis != NULL) {
double winPos = (double) ev.GetPosition() / (double) stepMult;
double minValue, maxValue;
axis->GetDataBounds(minValue, maxValue);
winPos += minValue;
axis->SetWindowPosition(winPos);
}
ev.Skip();
}
示例8: Tcl_NextHashEntry
Axis* Graph::nearestAxis(int x, int y)
{
Tcl_HashSearch cursor;
for (Tcl_HashEntry* hPtr=Tcl_FirstHashEntry(&axes_.table, &cursor);
hPtr; hPtr = Tcl_NextHashEntry(&cursor)) {
Axis *axisPtr = (Axis*)Tcl_GetHashValue(hPtr);
AxisOptions* ops = (AxisOptions*)axisPtr->ops();
if (ops->hide || !axisPtr->use_)
continue;
if (ops->showTicks) {
for (ChainLink* link = Chain_FirstLink(axisPtr->tickLabels_); link;
link = Chain_NextLink(link)) {
TickLabel *labelPtr = (TickLabel*)Chain_GetValue(link);
double rw, rh;
Point2d bbox[5];
getBoundingBox(labelPtr->width, labelPtr->height, ops->tickAngle,
&rw, &rh, bbox);
Point2d t;
t = anchorPoint(labelPtr->anchorPos.x, labelPtr->anchorPos.y,
rw, rh, axisPtr->tickAnchor_);
t.x = x - t.x - (rw * 0.5);
t.y = y - t.y - (rh * 0.5);
bbox[4] = bbox[0];
if (pointInPolygon(&t, bbox, 5)) {
return axisPtr;
}
}
}
if (ops->title) {
int w, h;
double rw, rh;
Point2d bbox[5];
getTextExtents(ops->titleFont, ops->title, -1, &w, &h);
getBoundingBox(w, h, axisPtr->titleAngle_, &rw, &rh, bbox);
Point2d t = anchorPoint(axisPtr->titlePos_.x, axisPtr->titlePos_.y,
rw, rh, axisPtr->titleAnchor_);
// Translate the point so that the 0,0 is the upper left
// corner of the bounding box
t.x = x - t.x - (rw * 0.5);
t.y = y - t.y - (rh * 0.5);
bbox[4] = bbox[0];
if (pointInPolygon(&t, bbox, 5)) {
return axisPtr;
}
}
if (ops->lineWidth > 0) {
if ((x <= axisPtr->right_) && (x >= axisPtr->left_) &&
(y <= axisPtr->bottom_) && (y >= axisPtr->top_)) {
return axisPtr;
}
}
}
return NULL;
}
示例9: extents
ClientData Graph::pickEntry(int xx, int yy, ClassId* classIdPtr)
{
if (flags & (LAYOUT | MAP_MARKERS)) {
*classIdPtr = CID_NONE;
return NULL;
}
// Sample coordinate is in one of the graph margins. Can only pick an axis.
Region2d exts;
extents(&exts);
if (xx>=exts.right || xx<exts.left || yy>=exts.bottom || yy<exts.top) {
Axis* axisPtr = nearestAxis(xx, yy);
if (axisPtr) {
*classIdPtr = axisPtr->classId();
return axisPtr;
}
}
// From top-to-bottom check:
// 1. markers drawn on top (-under false).
// 2. elements using its display list back to front.
// 3. markers drawn under element (-under true).
Marker* markerPtr = nearestMarker(xx, yy, 0);
if (markerPtr) {
*classIdPtr = markerPtr->classId();
return markerPtr;
}
GraphOptions* ops = (GraphOptions*)ops_;
ClosestSearch* searchPtr = &ops->search;
searchPtr->index = -1;
searchPtr->x = xx;
searchPtr->y = yy;
searchPtr->dist = (double)(searchPtr->halo + 1);
for (ChainLink* link = Chain_LastLink(elements_.displayList); link;
link = Chain_PrevLink(link)) {
Element* elemPtr = (Element*)Chain_GetValue(link);
ElementOptions* eops = (ElementOptions*)elemPtr->ops();
if (eops->hide)
continue;
elemPtr->closest();
}
// Found an element within the minimum halo distance.
if (searchPtr->dist <= (double)searchPtr->halo) {
*classIdPtr = searchPtr->elemPtr->classId();
return searchPtr->elemPtr;
}
markerPtr = nearestMarker(xx, yy, 1);
if (markerPtr) {
*classIdPtr = markerPtr->classId();
return markerPtr;
}
*classIdPtr = CID_NONE;
return NULL;
}
示例10: getProperty
/** Creates the output workspace, setting the X vector to the bins boundaries in
* Qx.
* @return A pointer to the newly-created workspace
*/
API::MatrixWorkspace_sptr
Qxy::setUpOutputWorkspace(API::MatrixWorkspace_const_sptr inputWorkspace) {
const double max = getProperty("MaxQxy");
const double delta = getProperty("DeltaQ");
int bins = static_cast<int>(max / delta);
if (bins * delta != max)
++bins; // Stop at first boundary past MaxQxy if max is not a multiple of
// delta
const double startVal = -1.0 * delta * bins;
bins *= 2; // go from -max to +max
bins += 1; // Add 1 - this is a histogram
// Create an output workspace with the same meta-data as the input
MatrixWorkspace_sptr outputWorkspace = WorkspaceFactory::Instance().create(
inputWorkspace, bins - 1, bins, bins - 1);
// ... but clear the masking from the parameter map as we don't want to carry
// that over since this is essentially
// a 2D rebin
ParameterMap &pmap = outputWorkspace->instrumentParameters();
pmap.clearParametersByName("masked");
// Create a numeric axis to replace the vertical one
Axis *verticalAxis = new BinEdgeAxis(bins);
outputWorkspace->replaceAxis(1, verticalAxis);
// Build up the X values
Kernel::cow_ptr<MantidVec> axis;
MantidVec &horizontalAxisRef = axis.access();
horizontalAxisRef.resize(bins);
for (int i = 0; i < bins; ++i) {
const double currentVal = startVal + i * delta;
// Set the X value
horizontalAxisRef[i] = currentVal;
// Set the Y value on the axis
verticalAxis->setValue(i, currentVal);
}
// Fill the X vectors in the output workspace
for (int i = 0; i < bins - 1; ++i) {
outputWorkspace->setX(i, axis);
for (int j = 0; j < bins - j; ++j) {
outputWorkspace->dataY(i)[j] = std::numeric_limits<double>::quiet_NaN();
outputWorkspace->dataE(i)[j] = std::numeric_limits<double>::quiet_NaN();
}
}
// Set the axis units
outputWorkspace->getAxis(1)->unit() = outputWorkspace->getAxis(0)->unit() =
UnitFactory::Instance().create("MomentumTransfer");
// Set the 'Y' unit (gets confusing here...this is probably a Z axis in this
// case)
outputWorkspace->setYUnitLabel("Cross Section (1/cm)");
setProperty("OutputWorkspace", outputWorkspace);
return outputWorkspace;
}
示例11: it
void RegionLoad::UpdateRegions()
{
//Define all regions actors
//Reset axis (Solve the bug "Game behavior differ based on editor grid position when uses regions", ALPHA_1_1_4.ged)
int xAxisAnt, yAxisAnt;
double scaleAnt;
Axis *pAxis = GameControl::Get()->GetAxis();
scaleAnt = pAxis->getScale();
xAxisAnt = pAxis->getImage()->X();
yAxisAnt = pAxis->getImage()->Y();
pAxis->SetScale(1.0);
pAxis->SetPos(0, 0);
pAxis->getImage()->Invalidate();
//Define actors
MapRegionsIterator it(regions);
RegionLoad *pRegion;
for( it.Begin(); !it.Done(); it.Next() )
{
pRegion = *it.Key();
pRegion->DefineActors();
}
SetDefaultRegionView();
//Restore axis (Solve the bug "Game behavior differ based on editor grid position when uses regions", ALPHA_1_1_4.ged)
pAxis->SetScale(scaleAnt);
pAxis->SetPos(xAxisAnt, yAxisAnt);
pAxis->getImage()->Invalidate();
}
示例12: recompute_axis_y
// ************************************************ Window::recompute_axis_y
void recompute_axis_y( int key )
{
// Re-compute Y-Axis
_axis_y = Axis{ "Y", {0.0, 1.0, 5, 2} };
for( auto& pt: _c_sim_convol.get_samples()) {
_axis_y.get_range().update( pt.y );
}
std::cout << "New AxisY: " << _axis_y.get_range()._min << ", " << _axis_y.get_range()._max << std::endl;
}
示例13: Chain_NextLink
void Graph::printAxes(PSOutput* psPtr)
{
GraphOptions* ops = (GraphOptions*)ops_;
for (Margin *mp = ops->margins, *mend = mp + 4; mp < mend; mp++) {
for (ChainLink* link = Chain_FirstLink(mp->axes); link;
link = Chain_NextLink(link)) {
Axis *axisPtr = (Axis*)Chain_GetValue(link);
axisPtr->print(psPtr);
}
}
}
示例14: Chain_PrevLink
void Graph::drawAxes(Drawable drawable)
{
GraphOptions* ops = (GraphOptions*)ops_;
for (int ii=0; ii<4; ii++) {
for (ChainLink* link = Chain_LastLink(ops->margins[ii].axes); link;
link = Chain_PrevLink(link)) {
Axis *axisPtr = (Axis*)Chain_GetValue(link);
axisPtr->draw(drawable);
}
}
}
示例15: timeshift
/** Set up the output workspace in a Workspace2D
* @brief ExportTimeSeriesLog::setupWorkspace2D
* @param start_index :: array index for the first log entry
* @param stop_index :: array index for the last log entry
* @param numentries :: number of log entries to output
* @param times :: vector of Kernel::DateAndTime
* @param values :: vector of log value in double
* @param epochtime :: flag to output time in epoch time/absolute time
* @param timeunitfactor :: conversion factor for various unit of time for
* output
*/
void ExportTimeSeriesLog::setupWorkspace2D(
const size_t &start_index, const size_t &stop_index, int numentries,
vector<DateAndTime> ×, vector<double> values, const bool &epochtime,
const double &timeunitfactor) {
// Determine time shift
int64_t timeshift(0);
if (!epochtime) {
// relative time
Kernel::DateAndTime runstart(
m_inputWS->run().getProperty("run_start")->value());
timeshift = runstart.totalNanoseconds();
}
// Determine the size
size_t outsize = stop_index - start_index + 1;
if (outsize > static_cast<size_t>(numentries))
outsize = static_cast<size_t>(numentries);
// Create 2D workspace
m_outWS = boost::dynamic_pointer_cast<MatrixWorkspace>(
WorkspaceFactory::Instance().create("Workspace2D", 1, outsize, outsize));
if (!m_outWS)
throw runtime_error(
"Unable to create a Workspace2D casted to MatrixWorkspace.");
MantidVec &vecX = m_outWS->dataX(0);
MantidVec &vecY = m_outWS->dataY(0);
MantidVec &vecE = m_outWS->dataE(0);
for (size_t index = 0; index < outsize; ++index) {
size_t i_time = index + start_index;
// safety check
if (i_time >= times.size()) {
std::stringstream errss;
errss << "It shouldn't happen that the index is out of boundary."
<< "start index = " << start_index << ", output size = " << outsize
<< ", index = " << index << "\n";
throw std::runtime_error(errss.str());
}
int64_t dtns = times[i_time].totalNanoseconds() - timeshift;
vecX[index] = static_cast<double>(dtns) * timeunitfactor;
vecY[index] = values[i_time];
vecE[index] = 0.0;
}
Axis *xaxis = m_outWS->getAxis(0);
xaxis->setUnit("Time");
return;
}