示例#1
0
文件: xparam.cpp 项目: pdnsoft/PParam
void XParam::saveXmlDoc(string xdoc, bool show_runtime, const int &indent,
	bool with_endl) const throw (Exception)
{
	string sxml;
	try {
		sxml = xml(show_runtime, indent, with_endl);
	} catch (std::exception &e) {
		throw Exception("Can't generate xml to save " 
				+ get_pname() + " !: " + e.what(), 
				TracePoint("pparam"));
	}
	std::fstream xfile;
	try {
		xfile.open(xdoc.c_str(),
			std::ios_base::trunc | std::ios_base::out);
	} catch (std::exception &e) {
		throw Exception("Can't open file to save " 
				+ get_pname() + " !: " + e.what(),
				TracePoint("pparam"));
	}
	if (xfile.fail())
		throw Exception("Can't open file to save " 
				+ get_pname() + " !",
				TracePoint("pparam"));
	xfile << sxml;
	xfile.close();
}
示例#2
0
文件: xparam.cpp 项目: pdnsoft/PParam
void XParam::loadXmlDoc(string xdoc, XmlParser *parser) throw (Exception)
{
	XmlParser *_parser = (parser == NULL) ? new XmlParser : parser;
	try {
		_parser->set_substitute_entities();
		_parser->parse_file(xdoc);
		if ((*_parser)) {
			XmlNode *node =
				_parser->get_document()->get_root_node();
			XParam *_xp = this;
			*_xp = node;
			return;
		}
	} catch (std::exception &e) {
		throw Exception(
			string("Can't parse xml document: ") + e.what(),
			TracePoint("xpram"));
	} catch (Exception &e) {
		e.addTracePoint(TracePoint("pparam"));
		throw e;
	}

	if (parser == NULL)
		delete _parser;
	// In this point, there is no valid parser, so can't parse document
	throw Exception("Can't parse xml document: ",
		TracePoint("pparam"));
}
示例#3
0
void
ZListTip::OnMouseMove( UINT uFlags, CPoint pt )
{
#ifdef DEBUG_ALL
   TraceRect( "ZListTip::OnMouseMove rectTitle: ", m_rectTitle );
   TracePoint( "ZListTip::OnMouseMove pt: ", pt );
#endif
   if ( m_rectTitle.PtInRect( pt ) == FALSE )
   {
#ifdef DEBUG_ALL
   TracePoint( "ZListTip::OnMouseMove PtInRect: ", pt );
#endif

#if 0
      if ( GetCapture( ) == this )
         ReleaseCapture( );

      SetWindowPos( 0, 0, 0, 0, 0,
                    SWP_HIDEWINDOW | SWP_NOMOVE | SWP_NOSIZE |
                      SWP_NOZORDER | SWP_NOACTIVATE );
#else
      Hide( );
#endif

      // Forward the message
      ClientToScreen( &pt );
      CWnd *pWnd = WindowFromPoint( pt );
      if ( pWnd == this )
         pWnd = m_pParentWnd;

      CWnd *pWndTemp = GetFocus( );
      if ( pWndTemp != pWnd )
         pWnd->SetFocus( );

      zLONG lParam = MAKELONG( pt.x, pt.y );
      int nHitTest = (int) pWnd->SendMessage( WM_NCHITTEST, 0, lParam );
      if ( nHitTest == HTCLIENT )
      {
         pWnd->ScreenToClient( &pt );
         lParam = MAKELONG( pt.x, pt.y );
         pWnd->PostMessage( WM_MOUSEMOVE, uFlags, lParam );
      }
      else
      {
         pWnd->PostMessage( WM_NCMOUSEMOVE, nHitTest, lParam );
      }
   }
}
示例#4
0
void
OLCLeague::reset()
{
  AbstractContest::reset();
  std::fill(solution, solution + 5, TracePoint());
  solution_found = false;
  solution_classic.clear();
}
示例#5
0
文件: TzCtlTAB.cpp 项目: DeegC/10d
void
TZNotePage::SelectPoint( CPoint pt )
{
#ifdef DEBUG_ALL
   TracePoint( "TZNotePage::SelectPoint", pt );
#endif
   m_pZNoteBook->SelectPoint( pt );
}
示例#6
0
文件: xparam.cpp 项目: pdnsoft/PParam
XParam& XFloatParam::operator =(const XParam::XFloat& value) throw (Exception)
{
	if ((max >= min) /* we should check boundries. */
	&& (value < min || value > max)) {
		throw Exception(pname + " value is out of range !",
			TracePoint("pparam"));
	}
	val = value;
	return (*this);
}
示例#7
0
void Runner::reset(const glm::vec3& xyz)
{
    control0 = nullptr;
    // fatigue, etc.

    move.pos.x = xyz.x; 
    move.pos.y = xyz.y; 
    move.pos.z = xyz.z; 
    move.pos.w = 1.0; 
    trace.reset( TracePoint( forest.tick, glm::vec3( xyz.x, xyz.y, xyz.z ) ) );
}
示例#8
0
void
OLCLeague::reset()
{
  AbstractContest::reset();
  solution_found = false;
  solution.clear();
  solution_classic.clear();
  for (unsigned i=0; i<5; ++i) {
    solution.append(TracePoint());
  }
}
示例#9
0
文件: xparam.cpp 项目: pdnsoft/PParam
XParam &XTextParam::operator = (const XParam &xp) throw (Exception)
{
	const XTextParam* xtp = dynamic_cast<const XTextParam*>(&xp);

	if (xtp == NULL)
		throw Exception("Bad text XParam in assignment !",
			TracePoint("pparam"));

	// check prameter name.
	if (get_pname() != xtp->get_pname())
		throw Exception("Different test xparameters "
			"in assignment !", TracePoint("pparam"));

	try {
		assignHelper(xp);
	} catch (Exception &e) {
		e.addTracePoint(TracePoint("pparam"));
		throw e;
	}
	val = xtp->val;

	return *this;
}
示例#10
0
文件: xparam.cpp 项目: pdnsoft/PParam
bool XParam::is_myNode(const XmlNode *node) throw (Exception)
{
	if (!node)
		return false;
	if (pname != node->get_name())
		return false;

	/* verify version number */
	if (version.empty())
		return true;
	xmlpp::Attribute *ver = ((xmlpp::Element *) (node))->get_attribute(
		"ver");
	if (!ver)
		throw Exception(
			"There is no \"ver\" attribute in " + pname
				+ " element", TracePoint("pparam"));

	if (ver->get_value() != version)
		throw Exception(
			"Bad " + pname + " version! " + "supported version is: "
				+ version, TracePoint("pparam"));

	return true;
}
示例#11
0
文件: xparam.cpp 项目: pdnsoft/PParam
XParam& XFloatParam::operator =(const XParam& xp) throw (Exception)
{
	const XFloatParam* xip = dynamic_cast<const XFloatParam*>(&xp);
	if (xip == NULL)
		throw Exception(
			get_pname() + ": Bad XFloatParam in assignment !",
			TracePoint("pparam"));

	// check prameter name.
	if (get_pname() != xip->get_pname())
		throw Exception("Different mix xparameters "
			"in assignment !", TracePoint("pparam"));

	try {
		assignHelper(xp);
	} catch (Exception &e) {
		e.addTracePoint(TracePoint("pparam"));
		throw e;
	}
	min = xip->min;
	max = xip->max;
	val = xip->val;
	return *this;
}
示例#12
0
文件: xparam.cpp 项目: pdnsoft/PParam
bool XSingleParam::operator == (const XParam &parameter) throw (Exception)
{
	const XSingleParam	*singleParameter =
				dynamic_cast<const XSingleParam*>(&parameter);
	if (!singleParameter)
		throw Exception(Exception::FAILED,
				"Bad single parameter in assignment !",
				TracePoint("pparam"));
	if (pname != singleParameter->get_pname())
		return false;
	if (value() != singleParameter->value())
		return false;

	return true;
}
示例#13
0
    virtual bool startElement( const QString & namespaceURI, const QString & localName, const QString & qName, const QXmlAttributes & atts ) {
        this->tmp = "";

        if(qName == "trk") {
            this->onTrk = true;
            this->cur_trk = new Track();
        } else if(qName == "trkseg") {
            this->onTrkSeg = true;
            this->cur_seg = new Segment();
        } else if(qName == "trkpt") {
            this->onTrkSegPt = true;
            this->cur_pt = TracePoint();
            setElementDouble(this->cur_pt.lat, atts, "lat");
            setElementDouble(this->cur_pt.lon, atts, "lon");
        }
        return true;
    }
示例#14
0
文件: TzCtlTAB.cpp 项目: DeegC/10d
void
TZNoteBook::SelectPoint( CPoint pt )
{
#ifdef DEBUG_ALL
   TracePoint( "TZNoteBook::SelectPoint", pt );
#endif
   if ( mIs_hWnd( m_hWnd ) == 0 )
      return;

   PostMoveCtrl( );
   m_bDeletable = TRUE;    // mark it as deletable

   CWnd *pWndDlgItem = GetDlgItem( 1 );
   if ( pWndDlgItem )
   {
   // MessageBox( "TZNoteBook::SelectPoint", "Found DlgItem" );
   // TraceLineX( "TZNoteBook::SelectPoint DlgItem: ",
   //             (zLONG) pWndDlgItem->m_hWnd );
      CWnd *pWndChild = ChildWindowFromPoint( pt, CWP_SKIPINVISIBLE );
      if ( pWndChild )
      {
      // TraceLineX( "TZNoteBook::SelectPoint ChildFromPt: ",
      //             (zLONG) pWndChild->m_hWnd );
         if ( pWndDlgItem->m_hWnd == pWndChild->m_hWnd )
         {
            ClientToScreen( &pt );
            pWndDlgItem->ScreenToClient( &pt );
            pWndDlgItem->SendMessage( WM_LBUTTONDOWN, 0, MAKELONG( pt.x, pt.y ) );
            pWndDlgItem->SendMessage( WM_LBUTTONUP, 0, MAKELONG( pt.x, pt.y ) );
            return;
         }
      }
   }

   SendMessage( WM_LBUTTONDOWN, 0, MAKELONG( pt.x, pt.y ) );
   SendMessage( WM_LBUTTONUP, 0, MAKELONG( pt.x, pt.y ) );
//x   zSHORT nActiveTabNbr = GetActivePage( );
// TraceLineI( "TZNoteBook::Select New ActiveTab = ", nActiveTabNbr );
//xif ( nActiveTab != m_nActiveTabNbr )
//x      ActivateTab( nActiveTabNbr );

// TraceLineI( "TZNoteBook::Select Activating tab IdNbr ", GetTabID( ) );
// TraceLineI( "                         tab number ", m_nActiveTabNbr );
// TraceLineI( "                    real tab number ", GetTab( ) );
}
示例#15
0
int main(int argc, char **argv)
{
  Args args(argc, argv, "DRIVER FILE");
  DebugReplay *replay = CreateDebugReplay(args);
  if (replay == NULL)
    return EXIT_FAILURE;

  args.ExpectEnd();

  Trace trace;

  while (replay->Next()) {
    const MoreData &basic = replay->Basic();
    if (basic.time_available && basic.location_available &&
        basic.NavAltitudeAvailable())
      trace.push_back(TracePoint(basic));
  }

  delete replay;
}
示例#16
0
int main(int argc, char **argv)
{
  int start = -1, end = -1;
  unsigned max_points = 1000;

  Args args(argc, argv,
            "[options] DRIVER FILE\n"
            "Options:\n"
            "  --start=5000             Begin flight path at 5000 sec after UTC midnight,\n"
            "                           if not defined takeoff time is used\n"
            "  --end=15000              End flight path at 15000 sec after UTC midnight,\n"
            "                           if not defined the last timestamp in the file is used\n"
            "  --max-points=1000        Maximum number of trace points in output (default = 1000)");

  const char *arg;
  while ((arg = args.PeekNext()) != nullptr && *arg == '-') {
    args.Skip();

    const char *value;
    if ((value = StringAfterPrefix(arg, "--max-points=")) != nullptr) {
      unsigned _max_points = strtol(value, NULL, 10);
      if (_max_points > 0)
        max_points = _max_points;
    } else if ((value = StringAfterPrefix(arg, "--start=")) != nullptr) {
      char *endptr;
      start = strtol(value, &endptr, 10);
      if (endptr == value || *endptr != '\0' || start < 0) {
        fputs("The start parameter could not be parsed correctly.\n", stderr);
        args.UsageError();
      }
    } else if ((value = StringAfterPrefix(arg, "--end=")) != nullptr) {
      char *endptr;
      end = strtol(value, &endptr, 10);
      if (endptr == value || *endptr != '\0' || end < 0) {
        fputs("The end parameter could not be parsed correctly.\n", stderr);
        args.UsageError();
      }
    } else {
      args.UsageError();
    }
  }

  if (start >= 0 && end >= 0 && start >= end) {
    fputs("The start parameter has to be smaller than the end parameter.\n", stderr);
    args.UsageError();
  }

  DebugReplay *replay = CreateDebugReplay(args);
  if (replay == nullptr)
    return EXIT_FAILURE;

  args.ExpectEnd();

  Trace trace(0, Trace::null_time, max_points);

  bool takeoff = false;

  while (replay->Next()) {
    const MoreData &basic = replay->Basic();
    const DerivedInfo &calculated = replay->Calculated();

    if (!basic.time_available || !basic.location_available ||
        !basic.NavAltitudeAvailable())
      continue;

    if (start >= 0 && (int)basic.time < start)
      continue;

    if (end >= 0 && (int)basic.time > end)
      break;

    trace.push_back(TracePoint(basic));

    if (start < 0 && calculated.flight.flying && !takeoff) {
      takeoff = true;
      trace.EraseEarlierThan(calculated.flight.takeoff_time);
    }
  }

  delete replay;

  for (auto i = trace.begin(), end = trace.end(); i != end; ++i) {
    const TracePoint &point = *i;
    printf("%u %f %f %d %u\n",
           point.GetTime(),
           (double)point.GetLocation().latitude.Degrees(),
           (double)point.GetLocation().longitude.Degrees(),
           point.GetIntegerAltitude(),
           point.GetEngineNoiseLevel());
  }
}
示例#17
0
BOOL
ZListTip::PreTranslateMessage( MSG *pMsg )
{
   CWnd *pWnd;
   int nHitTest;
   switch ( pMsg->message )
   {
      case WM_LBUTTONDOWN:
      case WM_RBUTTONDOWN:
      case WM_MBUTTONDOWN:
      {
         POINTS pts = MAKEPOINTS( pMsg->lParam );
         CPoint pt;
         pt.x = pts.x;
         pt.y = pts.y;

#ifdef DEBUG_ALL
   TracePoint( "ZListTip::OnButtonDown: ", pt );
#endif

         ClientToScreen( &pt );
         pWnd = WindowFromPoint( pt );
         if ( pWnd == 0 )
            return( CWnd::PreTranslateMessage( pMsg ) );

         if ( pWnd == this )
            pWnd = m_pParentWnd;

         nHitTest = (int) pWnd->SendMessage( WM_NCHITTEST, 0,
                                             MAKELONG( pt.x, pt.y ) );
         if ( nHitTest == HTCLIENT )
         {
            if ( pMsg->message == WM_LBUTTONDOWN )
            {
               zULONG ulTime = GetCurrentTime( );
               zULONG ulDblclkTime = GetDoubleClickTime( );
               if ( m_ulDblClickInterval == 0 )
               {
                  m_ulDblClickInterval = ulTime;
                  m_ptStart = pt;
               }
               else
               {
                  if ( ulTime - m_ulDblClickInterval > ulDblclkTime ||
                       m_ptStart.x - pt.x > g_lDblClkX ||
                       pt.x - m_ptStart.x > g_lDblClkX ||
                       m_ptStart.y - pt.y > g_lDblClkY ||
                       pt.y - m_ptStart.y > g_lDblClkY )
                  {
                     m_ptStart = pt;
                     m_ulDblClickInterval = ulTime;
                  }
                  else
                  {
                     pMsg->message = WM_LBUTTONDBLCLK;
                     m_ulDblClickInterval = 0;
                     m_ptStart.x = m_ptStart.y = 0;
                  }
               }
            }

            pWnd->ScreenToClient( &pt );
            pMsg->lParam = MAKELONG( pt.x, pt.y );
         }
         else
         {
            switch ( pMsg->message )
            {
               case WM_LBUTTONDOWN:
               {
                  pMsg->message = WM_NCLBUTTONDOWN;
                  break;
               }

               case WM_RBUTTONDOWN:
               {
                  pMsg->message = WM_NCRBUTTONDOWN;
                  break;
               }

               case WM_MBUTTONDOWN:
               {
                  pMsg->message = WM_NCMBUTTONDOWN;
                  break;
               }
            }

            pMsg->wParam = nHitTest;
            pMsg->lParam = MAKELONG( pt.x, pt.y );
         }

         Hide( );
         pWnd->PostMessage( pMsg->message, pMsg->wParam, pMsg->lParam );
         return( TRUE );
      }

      case WM_KEYDOWN:
      case WM_SYSKEYDOWN:
      {
         Hide( );
         m_pParentWnd->PostMessage( pMsg->message, pMsg->wParam, pMsg->lParam );
         return( TRUE );
      }
   }

   if ( GetFocus( ) == 0 )
   {
      Hide( );
      return( TRUE );
   }

   return( CWnd::PreTranslateMessage( pMsg ) );
}