Example #1
0
void draw(SkCanvas* canvas) {
    SkPath* path = new SkPath();
    path->lineTo(20, 20);
    SkPath path2(*path);
    delete path;
    SkDebugf("path2 is " "%s" "empty", path2.isEmpty() ? "" : "not ");
}
void 
HCopyFile(const HFileSpec& inFile1, const HFileSpec& inFile2, bool inFailIfExists)
{
	if (HasUnicode())
	{
		std::wstring path1(inFile1.GetWCharPath());
		std::wstring path2(inFile2.GetWCharPath());
		::CopyFileW(path1.c_str(), path2.c_str(), inFailIfExists);
	}
	else
	{
		std::string path1(inFile1.GetCharPath());
		std::string path2(inFile2.GetCharPath());
		::CopyFileA(path1.c_str(), path2.c_str(), inFailIfExists);
	}
}
void	PathTest::testPath() {
	debug(LOG_DEBUG, DEBUG_LOG, 0, "testPath() begin");
	Path	path1("/usr/local/bin/test");
	CPPUNIT_ASSERT(path1.size() == 5);
	CPPUNIT_ASSERT(path1[0] == "");
	CPPUNIT_ASSERT(path1[1] == "usr");
	CPPUNIT_ASSERT(path1[2] == "local");
	CPPUNIT_ASSERT(path1[3] == "bin");
	CPPUNIT_ASSERT(path1[4] == "test");
	CPPUNIT_ASSERT(path1.basename() == "test");
	CPPUNIT_ASSERT(path1.dirname() == "/usr/local/bin");
	Path	path2("/usr/local/bin/");
	CPPUNIT_ASSERT(path2.size() == 4);
	CPPUNIT_ASSERT(path2[0] == "");
	CPPUNIT_ASSERT(path2[1] == "usr");
	CPPUNIT_ASSERT(path2[2] == "local");
	CPPUNIT_ASSERT(path2[3] == "bin");
	CPPUNIT_ASSERT(path2.basename() == "bin");
	CPPUNIT_ASSERT(path2.dirname() == "/usr/local");
	Path	path3("blubb/bla/foo");
	CPPUNIT_ASSERT(path3.size() == 3);
	CPPUNIT_ASSERT(path3[0] == "blubb");
	CPPUNIT_ASSERT(path3[1] == "bla");
	CPPUNIT_ASSERT(path3[2] == "foo");
	CPPUNIT_ASSERT(path3.basename() == "foo");
	CPPUNIT_ASSERT(path3.dirname() == "blubb/bla");
	debug(LOG_DEBUG, DEBUG_LOG, 0, "testPath() end");
}
Example #4
0
Rocket::Core::FileHandle UI_FileInterface::Open(const Rocket::Core::String & path)
{
	int filenum = 0;
	int length = -1;
	Rocket::Core::URL url( path );
	Rocket::Core::String protocol = url.GetProtocol();

	// local
	if( protocol.Empty() || protocol == "file" ) {
		Rocket::Core::String path2( url.GetPathedFileName() );
		if( path2[0] == '/' ) {
			path2.Erase( 0, 1 );
		}
		length = trap::FS_FOpenFile( path2.CString(), &filenum, FS_READ );
	}
	else if( protocol == "http" ) {
		// allow blocking download of remote resources
		length = trap::FS_FOpenFile( path.CString(), &filenum, FS_READ );
	}

	if( length == -1 )
		return 0;

	// cache file length
	fileSizeMap[filenum] = length;

	// Com_Printf("UI_FileInterface opened %s\n", path2.CString() );
	return static_cast<Rocket::Core::FileHandle>( filenum );
}
void LibraryLoaderTest::findDSOAndCallEntryPointTest()
{
   try
   {
      std::vector<std::string> path1(1, std::string(MODULE_DIR));

      vpr::LibraryPtr dso;
      vpr::LibraryLoader::findDSOAndCallEntryPoint("loadermod1", path1,
                                                   mModules[0].second,
                                                   (bool(*)(void*)) rawCallback,
                                                   dso);
      CPPUNIT_ASSERT(dso.get() != NULL);
   }
   catch (vpr::Exception&)
   {
      CPPUNIT_ASSERT(false);
   }

   try
   {
      std::vector<fs::path> path2(1, fs::path(std::string(MODULE_DIR), fs::native));

      vpr::LibraryPtr dso;
      vpr::LibraryLoader::findDSOAndCallEntryPoint("loadermod1", path2,
                                                   mModules[0].second,
                                                   (bool(*)(void*)) rawCallback,
                                                   dso);
      CPPUNIT_ASSERT(dso.get() != NULL);
   }
   catch (vpr::Exception&)
   {
      CPPUNIT_ASSERT(false);
   }
}
BOOL 
HMoveFile(const HFileSpec& inFileFrom, const HFileSpec& inFileTo)
{
	BOOL result;
	if (HasUnicode())
	{
		std::wstring path1(inFileFrom.GetWCharPath());
		std::wstring path2(inFileTo.GetWCharPath());
		result = ::MoveFileW(path1.c_str(), path2.c_str());
	}
	else
	{
		std::string path1(inFileFrom.GetCharPath());
		std::string path2(inFileTo.GetCharPath());
		result = ::MoveFileA(path1.c_str(), path2.c_str());
	}
	return result;
}
Example #7
0
void factor_vm::primitive_save_image()
{
	/* do a full GC to push everything into tenured space */
	primitive_compact_gc();

	data_root<byte_array> path2(ctx->pop(),this);
	path2.untag_check(this);
	data_root<byte_array> path1(ctx->pop(),this);
	path1.untag_check(this);
	save_image((vm_char *)(path1.untagged() + 1 ),(vm_char *)(path2.untagged() + 1));
}
Example #8
0
v8::Handle<v8::Value> Util::addPath( const v8::Arguments& args ) {
	if ( args.Length() < 1 ) {
		return v8::Undefined();
	} else if ( args.Length() < 2 ) {
		return args[0];
	} else {
		v8::String::Utf8Value path1( args[0] );
		v8::String::Utf8Value path2( args[1] );

		return v8::String::NewSymbol( addPath( *path1, *path2 ).c_str() );
	}
}
Example #9
0
// Find the child that matches the first part of 'path'.
// E.g. if a child path is "/usr" and 'path' is "/usr/include"
// then the child for /usr is returned.
wxTreeItemId wxGenericDirCtrl::FindChild(wxTreeItemId parentId, const wxString& path, bool& done)
{
    wxString path2(path);

    // Make sure all separators are as per the current platform
    path2.Replace(wxT("\\"), wxString(wxFILE_SEP_PATH));
    path2.Replace(wxT("/"), wxString(wxFILE_SEP_PATH));

    // Append a separator to foil bogus substring matching
    path2 += wxString(wxFILE_SEP_PATH);

    // In MSW or PM, case is not significant
#if defined(__WINDOWS__) || defined(__DOS__) || defined(__OS2__)
    path2.MakeLower();
#endif

    wxTreeItemIdValue cookie;
    wxTreeItemId childId = m_treeCtrl->GetFirstChild(parentId, cookie);
    while (childId.IsOk())
    {
        wxDirItemData* data = (wxDirItemData*) m_treeCtrl->GetItemData(childId);

        if (data && !data->m_path.empty())
        {
            wxString childPath(data->m_path);
            if (!wxEndsWithPathSeparator(childPath))
                childPath += wxString(wxFILE_SEP_PATH);

            // In MSW and PM, case is not significant
#if defined(__WINDOWS__) || defined(__DOS__) || defined(__OS2__)
            childPath.MakeLower();
#endif

            if (childPath.length() <= path2.length())
            {
                wxString path3 = path2.Mid(0, childPath.length());
                if (childPath == path3)
                {
                    if (path3.length() == path2.length())
                        done = true;
                    else
                        done = false;
                    return childId;
                }
            }
        }

        childId = m_treeCtrl->GetNextChild(parentId, cookie);
    }
    wxTreeItemId invalid;
    return invalid;
}
Example #10
0
char *
Environment::getExternalStoragePublicDirectory(char *buffer, size_t max_size,
        const char *type)
{
    JNIEnv *env = Java::GetEnv();
    jstring path = ::getExternalStoragePublicDirectory(env, type);
    if (path == NULL)
        return NULL;

    Java::String path2(env, path);
    path2.CopyTo(env, buffer, max_size);
    return buffer;
}
    //Transform-----------------------------------------------------------------
    Status GraphicsPath::Transform( const Matrix* matrix )
    {
        if ( matrix )
        {
            agg::path_storage path2( mPathStorage );
            agg::conv_transform< agg::path_storage > trans( path2, matrix->mMatrix );

            // Remove all points from the current path:
            mPathStorage.remove_all();
            mPathStorage.concat_path( trans );
        }
        return SetStatus( Ok );
    }
static int main_(int argc, char** argv)
{
    { for(int i = 1; i < argc; ++i)
    {
        char const* const arg = argv[i];

    }}

	winstl::temporary_directory dir;

	winstl::path path1(dir);
	winstl::path path2(dir);

	path1 /= "abc";
	path2 /= "def";

	stlsoft::scoped_handle<char const*> scoper3(path1.c_str(), ::remove);
	stlsoft::scoped_handle<char const*> scoper4(path2.c_str(), ::remove);

	HANDLE hFile = winstl::file_create_always(path1.c_str(), GENERIC_WRITE, 0, 0);

	if(INVALID_HANDLE_VALUE == hFile)
	{
		fprintf(stderr, "could not open %s: %s\n", path1.c_str(), winstl::error_desc().c_str());

		return EXIT_FAILURE;
	}
	else
	{
		stlsoft::scoped_handle<HANDLE> scoper1(hFile, ::CloseHandle, INVALID_HANDLE_VALUE);

		;
	}

	DWORD numLinks1;
	DWORD numLinks2;

	winstl::hard_link_count_links(path1.c_str(), &numLinks1);

	if(!winstl::hard_link_create(path2.c_str(), path1.c_str()))
	{
		fprintf(stderr, "failed: %s\n", winstl::error_desc().c_str());
	}

	winstl::hard_link_count_links(path1.c_str(), &numLinks2);

//		tmpnam

    /* . */
    return EXIT_SUCCESS;
}
Example #13
0
File: fs.cpp Project: kyusof/SilkJS
static JSVAL fs_cmp(JSARGS args) {
    HandleScope scope;
    String::Utf8Value path1(args[0]->ToString());
    String::Utf8Value path2(args[1]->ToString());
    int fd;
    long size1, size2;
    char buf[1024];

    fd = open(*path1, O_RDONLY);
    if (fd < 0) {
        sprintf(buf, "Could not open %s", *path1);
        return scope.Close(String::New(buf));
    }
    size1 = lseek(fd, 0, 2);
    lseek(fd, 0, 0);
    unsigned char buf1[size1];
    if (read(fd, buf1, size1) != size1) {
        close(fd);
        sprintf(buf, "Error reading %s", *path1);
        return scope.Close(String::New(buf));
    }
    close(fd);

    fd = open(*path2, O_RDONLY);
    if (fd < 0) {
        sprintf(buf, "Could not open %s", *path2);
        return scope.Close(String::New(buf));
    }
    size2 = lseek(fd, 0, 2);
    lseek(fd, 0, 0);
    unsigned char buf2[size2];
    if (read(fd, buf2, size2) != size2) {
        close(fd);
        sprintf(buf, "Error reading %s", *path2);
        return scope.Close(String::New(buf));
    }
    close(fd);

    if (size1 != size2) {
        return scope.Close(String::New("Files differ in size"));
    }

    for (long n=0; n<size1; n++) {
        if (buf1[n] != buf2[n]) {
            sprintf(buf, "Files differ at offset %ld", n);
            return scope.Close(String::New(buf));
        }
    }
    return scope.Close(True());
}
void LibraryLoaderTest::findDSOTest()
{
   vpr::LibraryPtr dso1, dso2;
   std::vector<std::string> path1(1);

   path1[0] = std::string(MODULE_DIR);
   dso1 = vpr::LibraryLoader::findDSO("loadermod1", path1);
   CPPUNIT_ASSERT(dso1.get() != NULL);

   std::vector<fs::path> path2(1);
   path2[0] = fs::path(std::string(MODULE_DIR), fs::native);
   dso2 = vpr::LibraryLoader::findDSO("loadermod1", path2);
   CPPUNIT_ASSERT(dso2.get() != NULL);
}
Example #15
0
QIcon Convert::getFileIcon(const QString &path, bool exists) {
    // performance tuned using:
    //http://www.codeguru.com/Cpp/COM-Tech/shell/article.php/c4511/
	QString path2(path);
	path2.replace('/','\\');  // -- necessary, I don't exactly know why... --
	UINT flags = SHGFI_ICON | SHGFI_LARGEICON;
	if(!exists) {
		flags |= SHGFI_USEFILEATTRIBUTES;
	}
    SHFILEINFO file_info;
    ::SHGetFileInfo((wchar_t*)path2.utf16(),FILE_ATTRIBUTE_NORMAL,
            &file_info, sizeof(SHFILEINFO), flags);
    return QIcon(convertHIconToPixmap(file_info.hIcon));
}
Example #16
0
TEST(Path, pwd)
{
    cxx::sys::Path path1(cxx::sys::Path::curpath());
    printf("current path is: %s\n", path1.name());

    cxx::sys::Path path2(cxx::sys::Path::curpath());
    path2.append("abc");
    printf("path2 is: %s\n", path2.name());

    cxx::sys::Path path3("abc/");
    printf("path3 is: %s\n", path3.name());

    cxx::sys::Path path6("../");
    printf("path6 is: %s\n", path6.name());
}
int
main(int argc, const char *argv[]) {
    int i;

    UNCALL_INIT();

    for (i = 0; i < 10000; i++) {
        path1();
        path2();
        path1();
    }

    UNCALL_DEINIT();
    return 0;
}
Example #18
0
int
main(int argc, const char *argv[]) {
    int i;
    int logfd;

    logfd = open("basic_flow.log", O_RDWR | O_CREAT | O_TRUNC, 0666);
    uncall_context_init(&ctx, 16, logfd);

    for (i = 0; i < 10000; i++) {
        path1();
        path2();
        path1();
    }

    uncall_context_destroy(&ctx);
    close(logfd);
}
Example #19
0
/**
 * @brief Find the CDiffContext diffpos of an item from its left & right paths
 * @return POSITION to item, NULL if not found.
 * @note Filenames must be same, if they differ NULL is returned.
 */
UINT_PTR CDirDoc::FindItemFromPaths(LPCTSTR pathLeft, LPCTSTR pathRight)
{
	LPCTSTR file1 = paths_FindFileName(pathLeft);
	LPCTSTR file2 = paths_FindFileName(pathRight);

	// Filenames must be identical
	if (lstrcmpi(file1, file2) != 0)
		return NULL;

	String path1(pathLeft, file1 - pathLeft); // include trailing backslash
	String path2(pathRight, file2 - pathRight); // include trailing backslash

	// Path can contain (because of difftools?) '/' and '\'
	// so for comparing purposes, convert whole path to use '\\'
	replace_char(&*path1.begin(), '/', '\\');
	replace_char(&*path2.begin(), '/', '\\');

	String base1 = m_pCtxt->GetLeftPath(); // include trailing backslash
	if (path1.compare(0, base1.length(), base1.c_str()) != 0)
		return NULL;
	path1.erase(0, base1.length()); // turn into relative path
	if (String::size_type length = path1.length())
		path1.resize(length - 1); // remove trailing backslash

	String base2 = m_pCtxt->GetRightPath(); // include trailing backslash
	if (path2.compare(0, base2.length(), base2.c_str()) != 0)
		return NULL;
	path2.erase(0, base2.length()); // turn into relative path
	if (String::size_type length = path2.length())
		path2.resize(length - 1); // remove trailing backslash

	UINT_PTR pos = m_pCtxt->GetFirstDiffPosition();
	while (UINT_PTR currentPos = pos) // Save our current pos before getting next
	{
		const DIFFITEM &di = m_pCtxt->GetNextDiffPosition(pos);
		if (di.left.path == path1 &&
			di.right.path == path2 &&
			di.left.filename == file1 &&
			di.right.filename == file2)
		{
			return currentPos;
		}
	}
	return 0;
}
Example #20
0
int main()
{
    boost::filesystem::path path1("abc");
    boost::filesystem::path path2("def");

    try 
    {
        boost::filesystem::rename(path1, "def");

        std::cout << "Renamed " 
                  << path1.string()
                  << " to "
                  << path2.string()
                  << std::endl;
    } 
    catch (boost::filesystem::filesystem_error e)
    {
        std::cerr << "Could not rename file " << path1.string() << std::endl;
    }
    return 0;
}
Example #21
0
DEF_TEST(SkOpBuilderFuzz665, reporter) {
    SkPath path;
    path.setFillType(SkPath::kEvenOdd_FillType);
path.moveTo(SkBits2Float(0xcc4264a7), SkBits2Float(0x4bb12e50));  // -5.0959e+07f, 2.32235e+07f
path.lineTo(SkBits2Float(0xcc4264b0), SkBits2Float(0x4bb12e48));  // -5.0959e+07f, 2.32234e+07f
path.lineTo(SkBits2Float(0xcc4264a7), SkBits2Float(0x4bb12e50));  // -5.0959e+07f, 2.32235e+07f
path.close();
    SkPath path1(path);
    path.reset();
    path.setFillType(SkPath::kWinding_FillType);
path.moveTo(SkBits2Float(0x43213333), SkBits2Float(0x43080000));  // 161.2f, 136
path.lineTo(SkBits2Float(0x43038000), SkBits2Float(0x43080000));  // 131.5f, 136
path.cubicTo(SkBits2Float(0x43038000), SkBits2Float(0x42f00000), SkBits2Float(0x42f16666), SkBits2Float(0x42d53333), SkBits2Float(0x42d3cccd), SkBits2Float(0x42cd6666));  // 131.5f, 120, 120.7f, 106.6f, 105.9f, 102.7f
path.lineTo(SkBits2Float(0x42e33333), SkBits2Float(0x42940000));  // 113.6f, 74
    SkPath path2(path);
    SkOpBuilder builder;
    builder.add(path1, kUnion_SkPathOp);
    builder.add(path2, kUnion_SkPathOp);
    SkPath result;
    builder.resolve(&result);
}
JNIEXPORT void JNICALL
Java_org_apache_subversion_javahl_SVNClient_merge__Ljava_lang_String_2Lorg_apache_subversion_javahl_types_Revision_2Ljava_lang_String_2Lorg_apache_subversion_javahl_types_Revision_2Ljava_lang_String_2ZLorg_apache_subversion_javahl_types_Depth_2ZZZ
(JNIEnv *env, jobject jthis, jstring jpath1, jobject jrevision1,
 jstring jpath2, jobject jrevision2, jstring jlocalPath, jboolean jforce,
 jobject jdepth, jboolean jignoreAncestry, jboolean jdryRun,
 jboolean jrecordOnly)
{
  JNIEntry(SVNClient, merge);
  SVNClient *cl = SVNClient::getCppObject(jthis);
  if (cl == NULL)
    {
      JNIUtil::throwError(_("bad C++ this"));
      return;
    }
  Revision revision1(jrevision1);
  if (JNIUtil::isExceptionThrown())
    return;

  JNIStringHolder path1(jpath1);
  if (JNIUtil::isExceptionThrown())
    return;

  Revision revision2(jrevision2);
  if (JNIUtil::isExceptionThrown())
    return;

  JNIStringHolder path2(jpath2);
  if (JNIUtil::isExceptionThrown())
    return;

  JNIStringHolder localPath(jlocalPath);
  if (JNIUtil::isExceptionThrown())
    return;

  cl->merge(path1, revision1, path2, revision2, localPath,
            jforce ? true:false, EnumMapper::toDepth(jdepth),
            jignoreAncestry ? true:false, jdryRun ? true:false,
            jrecordOnly ? true:false);
}
Example #23
0
Path Directory::relativePathTo(Path path) const
{
  if ( toString().empty() || path.toString().empty() )
    return *this;

  Path path1 = absolutePath();
  Path path2( Directory( path.directory() ).absolutePath() );
  StringArray list1, list2;

  list1 = utils::split( path1.toString(), "/\\");
  list2 = utils::split( path2.toString(), "/\\");

  unsigned int i=0;
  for (; i<list1.size() && i<list2.size(); ++i)
  {
    utils::equaleMode emode = utils::equaleIgnoreCase;
#ifdef CAESARIA_PLATFORM_UNIX
    emode = utils::equaleCase;
#endif //CAESARIA_PLATFORM_UNIX

    if( !utils::isEquale( list1[ i ], list2[ i ], emode ) )
    {
      break;
    }
  }

  path1="";
  for( unsigned int k=i; k<list1.size(); ++k)
  {
    path1 = path1.toString() + "../";
  }

  for( ; i < list2.size(); i++ )
  {
    path1 = path1.toString() + list2[ i ] + "/";
  }

  return path1.toString() + path.baseName().toString();
}
Example #24
0
void factor_vm::primitive_save_image_and_exit()
{
	/* We unbox this before doing anything else. This is the only point
	where we might throw an error, so we have to throw an error here since
	later steps destroy the current image. */
	data_root<byte_array> path2(ctx->pop(),this);
	path2.untag_check(this);
	data_root<byte_array> path1(ctx->pop(),this);
	path1.untag_check(this);

	/* strip out special_objects data which is set on startup anyway */
	for(cell i = 0; i < special_object_count; i++)
		if(!save_special_p(i)) special_objects[i] = false_object;

	gc(collect_compact_op,
		0, /* requested size */
		false /* discard objects only reachable from stacks */);

	/* Save the image */
	if(save_image((vm_char *)(path1.untagged() + 1), (vm_char *)(path2.untagged() + 1)))
		exit(0);
	else
		exit(1);
}
void TrafficGraph::drawBeams(QPainter *p, int top, int w, int h, int horizontalScale)
{
  Q_ASSERT(mNiceRange != 0); if(mNiceRange == 0) mNiceRange = 1;
  double scaleFac = (h-1) / mNiceRange;

  int xPos = 0;
  QLinkedList< QList<double> >::Iterator it = mBeamData.begin();

  p->setPen(Qt::NoPen);
  /* In autoRange mode we determine the range and plot the values in
   * one go. This is more efficiently than running through the
   * buffers twice but we do react on recently discarded samples as
   * well as new samples one plot too late. So the range is not
   * correct if the recently discarded samples are larger or smaller
   * than the current extreme values. But we can probably live with
   * this.
   *
   * These values aren't used directly anywhere.  Instead we call
   * calculateNiceRange()  which massages these values into a nicer 
   * values.  Rounding etc.  This means it's safe to change these values
   * without affecting any other drawings
   * */
  if ( mUseAutoRange )
    mMinValue = mMaxValue = 0.0;

  /* mBezierCurveOffset is how many points we have at the start.
   * All the bezier curves are in groups of 3, with the first of the next group being the last point
   * of the previous group->
   *
   * Example, when mBezierCurveOffset == 0, and we have data, then just plot a normal bezier curve 
   * (we will have at least 3 points in this case)
   * When mBezierCurveOffset == 1, then we want a bezier curve that uses the first data point and 
   * the second data point.  Then the next group starts from the second data point.
   * When mBezierCurveOffset == 2, then we want a bezier curve that uses the first, second and third data
   *
   */
  for (unsigned int i = 0; it != mBeamData.end() && i < mSamples; ++i) {
    QPen pen;
    pen.setWidth(1);
    pen.setCapStyle(Qt::FlatCap);

    /**
     * We will plot 1 bezier curve for every 3 points, with the 4th point being the end
     * of one bezier curve and the start of the second.
     * This does means the bezier curves will not join nicely,
     * but it should be better than nothing.
     */

    QList<double> datapoints = *it;
    QList<double> prev_datapoints = datapoints;
    QList<double> prev_prev_datapoints = datapoints;
    QList<double> prev_prev_prev_datapoints = datapoints;

    if (i == 0 && mBezierCurveOffset>0) {
      /**
       * We are plotting an incomplete bezier curve - we don't have all the data we want.
       * Try to cope
       */
      xPos += horizontalScale*mBezierCurveOffset;
      if (mBezierCurveOffset == 1) {
        prev_datapoints = *it;
        ++it; //Now we are on the first element of the next group, if it exists
        if (it != mBeamData.end()) {
          prev_prev_prev_datapoints = prev_prev_datapoints = *it;
        } else {
          prev_prev_prev_datapoints = prev_prev_datapoints = prev_datapoints;
        }
      } else {
        // mBezierCurveOffset must be 2 now
        prev_datapoints = *it;
        Q_ASSERT(it != mBeamData.end());
        ++it;
        prev_prev_datapoints = *it;
        Q_ASSERT(it != mBeamData.end());
        ++it; //Now we are on the first element of the next group, if it exists
        if (it != mBeamData.end()) {
          prev_prev_prev_datapoints = *it;
        } else {
          prev_prev_prev_datapoints = prev_prev_datapoints;
        }
      }
    } else {
      /**
       * We have a group of 3 points at least.  That's 1 start point and 2 control points.
       */
      xPos += horizontalScale*3;
      it++;
      if (it != mBeamData.end()) {
        prev_datapoints = *it;
        it++;
        if (it != mBeamData.end()) {
          prev_prev_datapoints = *it;
          it++;  //We are now on the next set of data points
          if (it != mBeamData.end()) {
            // We have this datapoint, so use it for our finish point
            prev_prev_prev_datapoints = *it;
          } else {
            // We don't have the next set, so use our last control point as our finish point
            prev_prev_prev_datapoints = prev_prev_datapoints;
          }
        } else {
          prev_prev_prev_datapoints = prev_prev_datapoints = prev_datapoints;
        }
      } else {
          prev_prev_prev_datapoints = prev_prev_datapoints = prev_datapoints = datapoints;
      }
    }


    float x0 = w - xPos + 3.0*horizontalScale;
    float x1 = w - xPos + 2.0*horizontalScale;
    float x2 = w - xPos + 1.0*horizontalScale;
    float x3 = w - xPos;
    float y0 = h -1 + top;
    float y1 = y0;
    float y2 = y0;
    float y3 = y0;

    int offset = 0; //Our line is 2 pixels thick.  This means that when we draw the area, we need to offset 
    double max_y=0;
    double min_y=0;
    for (int j =  qMin(datapoints.size(), mBeamColors.size())-1; j >=0 ; --j) {
      if ( mUseAutoRange) {
        //If we use autorange, then we need to prepare the min and max values for _next_ time we paint
	//if we are stacking the beams, then we need to add the maximums together
	double current_maxvalue = qMax(datapoints[j], qMax(prev_datapoints[j], qMax(prev_prev_datapoints[j], prev_prev_prev_datapoints[j])));
	double current_minvalue = qMin(datapoints[j], qMin(prev_datapoints[j], qMin(prev_prev_datapoints[j], prev_prev_prev_datapoints[j])));
	mMaxValue = qMax(mMaxValue, current_maxvalue);
	mMinValue = qMin(mMinValue, current_maxvalue);
	if( mStackBeams ) {
	  max_y += current_maxvalue;
	  min_y += current_minvalue;
	}
      }

      /*
       * Draw polygon only if enough data points are available.
       */
      if ( j < prev_prev_prev_datapoints.count() &&
           j < prev_prev_datapoints.count() &&
           j < prev_datapoints.count() ) {

        QPolygon curve( 4 );


        /* The height of the whole widget is h+top->  The height of the area we are plotting in is just h.
	 * The y coordinate system starts from the top, so at the bottom the y coordinate is h+top
	 * So to draw a point at value y', we need to put this at  h+top-y'
	 */
	float delta_y0;
        delta_y0 = (datapoints[j] - mNiceMinValue)*scaleFac;

	float delta_y1;
	delta_y1 = (prev_datapoints[j] - mNiceMinValue)*scaleFac;
	
	float delta_y2;
	delta_y2 = (prev_prev_datapoints[j] - mNiceMinValue)*scaleFac;
	
	float delta_y3;
	delta_y3 = (prev_prev_prev_datapoints[j] - mNiceMinValue)*scaleFac;

        QPainterPath path;
	if(mStackBeams && offset) {
		//we don't want the lines to overdraw each other.  This isn't a great solution though :(
	  if(delta_y0 < 3) delta_y0=3;
	  if(delta_y1 < 3) delta_y1=3;
	  if(delta_y2 < 3) delta_y2=3;
	  if(delta_y3 < 3) delta_y3=3;
	}
	path.moveTo( x0,y0-delta_y0);
        path.cubicTo( x1,y1-delta_y1,x2,y2-delta_y2,x3,y3-delta_y3 );
        
	if(mFillBeams) {
	  QPainterPath path2(path);
          QLinearGradient myGradient(0,(h-1+top),0,(h-1+top)/5);
	  Q_ASSERT(mBeamColorsDark.size() >= j);
	  Q_ASSERT(mBeamColors.size() >= j);
	  QColor c0(mBeamColorsDark[j]);
	  QColor c1(mBeamColors[j]);
	  c0.setAlpha(150);
	  c1.setAlpha(150);
	  myGradient.setColorAt(0, c0);
          myGradient.setColorAt(1, c1);

          path2.lineTo( x3,y3-offset);
	  if(mStackBeams)
	    path2.cubicTo( x2,y2-offset,x1,y1-offset,x0,y0-offset); //offset is set to 1 after the first beam is drawn, so we don't trample on top of the 2pt thick line
	  else
	    path2.lineTo(x0,y0-1);
          p->setBrush(myGradient);
          p->setPen(Qt::NoPen);
          p->drawPath( path2 );
	}
	p->setBrush(Qt::NoBrush);
	Q_ASSERT(mBeamColors.size() >= j);
	pen.setColor(mBeamColors[j]);
	p->setPen(pen);
        p->drawPath( path );

	if(mStackBeams) {
          //We can draw the beams stacked on top of each other.  This means that say beam 0 has the value 2 and beam
	  // 1 has the value 3, then we plot beam 0 at 2 and beam 1 at 2+3 = 5.
	  y0-=delta_y0;
	  y1-=delta_y1;
	  y2-=delta_y2;
	  y3-=delta_y3;
	  offset = 1;  //see the comment further up for int offset;
	}
      }
      if ( mUseAutoRange && mStackBeams) {
	mMaxValue = qMax(max_y, mMaxValue);
	mMinValue = qMin(min_y, mMinValue);
      }
    }
  }
}
Example #26
0
int main(int argc, char *argv[])
{
  // Workaround to start browser from QTextView
  qputenv( "BROWSER", "browser --url" );

  // @AP: Reset the locale that is used for number formatting to "C" locale.
  setlocale(LC_NUMERIC, "C");

#ifdef ANDROID

  // Gets the additional data directory from our app. That is normally the
  // storage path to the SD-Card as /sdcard/Cumulus.
  QString addDir = jniGetAddDataDir();

  while( addDir.isEmpty() )
    {
      qDebug() << " Waiting for Cumulus addDir ...";
      usleep(250000);
      addDir = jniGetAddDataDir();
    }

  // Assign the original path name
  addDir = QDir(addDir).canonicalPath();

  // Nice trick to overwrite the HOME directory under Android by us ;-)
  // That must be done before the QApplication constructor is called.
  // Otherwise another HOME is used by QApplication.
  qputenv ( "HOME", addDir.toLatin1().data() );

#endif

#ifndef ANDROID
#if QT_VERSION < 0x050000
  // Note this must be called before QApplication constructor
  QApplication::setGraphicsSystem( "raster" );
#endif
#endif

  QApplication app(argc, argv, true);

  QCoreApplication::setApplicationName( "Cumulus" );
  QCoreApplication::setApplicationVersion( CU_VERSION );
  QCoreApplication::setOrganizationName( "KFLog" );
  QCoreApplication::setOrganizationDomain( "www.kflog.org" );

  // Make sure the application uses utf8 encoding for translated widgets
#if QT_VERSION < 0x050000
  QTextCodec::setCodecForTr( QTextCodec::codecForName ("UTF-8") );
#endif

  // Note, that first $HOME must be overwritten under Android otherwise the
  // setting file is created/searched in the internal data area under:
  // /data/data/org.kflog.cumulus/files. That is the $HOME, set by Necessitas.
  GeneralConfig *conf = GeneralConfig::instance();

#ifdef ANDROID

  // Set the add data directory in our configuration
  conf->setDataRoot( addDir );

  // Set data directory after every startup because different Android APIs
  // uses different locations. Otherwise that can cause problems during Andoid
  // updates to a newer release.
  conf->setUserDataDirectory( addDir );

  // As next we must wait, that the add data are installed. That is done
  // at the Java side.
  while( jniAddDataInstalled() == false )
    {
      qDebug() << " Waiting for Cumulus addData installed ...";
      usleep(250000);
    }

  // Gets the internal data directory from our App
  QString appDir = jniGetAppDataDir();

  while (appDir.isEmpty())
    {
      qDebug() << " Waiting for Cumulus appDir ...";
      usleep(250000);
      appDir = jniGetAppDataDir();
    }

  conf->setAppRoot( appDir );

#endif /* ANDROID */

  // @AP: we installing our own message handler
#if QT_VERSION < 0x050000
  qInstallMsgHandler(messageHandler);
#else
  qInstallMessageHandler(messageHandler);
#endif

  // @AP: to make trace output available, if process is started via
  // QT/X11, we can redirect all output into a file, if configuration option
  // Log2File is set to true.

#ifndef ANDROID
  // @AP: make install root of Cumulus available for other modules via
  // GeneralConfig. The assumption is that Cumulus is installed at
  // <root>/bin/cumulus. The <root> path will be passed to GeneralConfig.
  QDir rootDir( QFileInfo(argv[0]).canonicalPath() );

  if( rootDir.cdUp() == false )
    {
      qWarning() << "main: Cumulus App has no parent directory! InstallDir is" << rootDir;
    }

  QString rootPath = rootDir.canonicalPath();

  conf->setAppRoot( rootPath );
#endif

#ifdef MAEMO
  bool isLog2File = true;
#else
  bool isLog2File = conf->getLog2FileMode();
#endif

  QString logDir = "/tmp";

#ifdef ANDROID

  // always log on Android for now
  isLog2File = true;
  logDir = QDir::homePath();

#endif

  if( isLog2File )
    {

#ifdef MAEMO
      // check for alternate paths under Maemo
      QDir path1("/media/mmc1"); // N8x0
      QDir path2("/media/mmc2"); // N8x0
      QDir path3("/home/user/MyDocs");

      if( path1.exists() && HwInfo::isMounted(path1.absolutePath()) )
        {
          logDir = path1.absolutePath();
        }
      else if( path2.exists() && HwInfo::isMounted(path2.absolutePath()) )
        {
          logDir = path2.absolutePath();
        }
      else if( path3.exists() )
         {
           logDir = path3.absolutePath();
         }

#endif

      logDir += "/cumulus.log";

      // Save one old log file version.
      rename( logDir.toLatin1().data(), (logDir + ".old").toLatin1().data() );

      int i = open( logDir.toLatin1().data(), O_RDWR|O_CREAT|O_TRUNC,
                    S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH );

      // Duplicate file descriptors 1, 2 that the output goes into a logfile

      // dup2( i, fileno(stdin) );
      dup2( i, fileno(stdout) );
      dup2( i, fileno(stderr) );
      close(i);
    }

#ifdef ANDROID

  qDebug() << "Cumulus addDir and QtHome:" << addDir;
  qDebug() << "Cumulus appDir:" << appDir;
  qDebug() << "Cumulus LogDir:" << logDir;

#endif

  /*
    @AP: check, if environment variable LD_BIND_NOW is set. In this case reset
    it to avoid a gps client crash during fork under Opie.

    If the process environment [see exec(base operating system)] contains a
    variable named LD_BIND_NOW with a non-null value, the dynamic linker processes
    all relocations before transferring control to the program. For example, all
    the following environment entries would specify this behavior.

    * LD_BIND_NOW=1
    * LD_BIND_NOW=on
    * LD_BIND_NOW=off

    Otherwise, LD_BIND_NOW either does not occur in the environment or has a null
    value. The dynamic linker is permitted to evaluate procedure linkage table
    entries lazily, thus avoiding symbol resolution and relocation overhead for
    functions that are not called. See the Procedure Linkage Table in this chapter
    of the processor supplement for more information.
  */

  char *env = getenv("LD_BIND_NOW");
  qDebug( "LD_BIND_NOW=%s", env ? env : "NULL" );

//  if( env != 0 )
//    {
//      unsetenv("LD_BIND_NOW");
//    }

  // Load language translation file for Cumulus.

#ifndef ANDROID

  conf->setLanguage( conf->getLanguage() );

#else

  // Gets the default language from the Android device.
   QString language = jniGetLanguage();

   // Put Android's default language into the program environment.
   qputenv( "LANG",  language.toLatin1().data() );

   qDebug() << "Android sets language to" << language;

   if( language.startsWith( "de" ) )
     {
       // In case of German there is a translation available.
       conf->setLanguage( "de" );
     }
   else
     {
       conf->setLanguage( conf->getLanguage() );
     }

  QFontDatabase database;

  foreach (const QString &family, database.families())
    {
      foreach (const QString &style, database.styles(family))
        {
          QString sizes;

          foreach (int points, database.smoothSizes(family, style))
            sizes += QString::number(points) + " ";

          qDebug() << "Installed Font:" << family << style << sizes.trimmed();
        }
    }

  QHash <QString, float> dmh = jniGetDisplayMetrics();

  QHashIterator<QString, float> i(dmh);

  qDebug() << "Android display metrics as key value list";

  while( i.hasNext() )
    {
      i.next();
      qDebug() << i.key() << "=" << i.value();
    }

  QHash <QString, QString> bdh = jniGetBuildData();

  QHashIterator<QString, QString> j(bdh);

  qDebug() << "Android build data as key value list";

  while( j.hasNext() )
    {
      j.next();
      qDebug() << j.key() << "=" << j.value();
    }

#endif

  // save done configuration settings
  conf->save();

  // create the Cumulus application window
  MainWindow *cumulus = new MainWindow( Qt::WindowContextHelpButtonHint );

  // start window manager event processing loop
  int result = QApplication::exec();

  // remove as first MainWindow because class objects inside can call GeneralConfig
  delete cumulus;

  // remove GeneralConfig, it is created during first call to it
  delete GeneralConfig::instance();

  return result;
}
    virtual void on_draw()
    {
        pixfmt pixf(rbuf_window());
        renderer_base rb(pixf);
        renderer_solid r(rb);
        rb.clear(agg::rgba(1, 1, 1));

        scanline_type sl;
        agg::rasterizer_scanline_aa<> ras;

        agg::simple_polygon_vertex_source path1(m_poly1.polygon(), 
                                                m_poly1.num_points(), 
                                                false, 
                                                false);

        agg::simple_polygon_vertex_source path2(m_poly2.polygon(), 
                                                m_poly2.num_points(), 
                                                false, 
                                                false);


        typedef agg::conv_bspline<agg::simple_polygon_vertex_source> conv_bspline_type;
        conv_bspline_type bspline1(path1);
        conv_bspline_type bspline2(path2);
        bspline1.interpolation_step(1.0 / m_num_points.value());
        bspline2.interpolation_step(1.0 / m_num_points.value());


        typedef agg::conv_curve<font_manager_type::path_adaptor_type>            conv_font_curve_type;
        typedef agg::conv_segmentator<conv_font_curve_type>                      conv_font_segm_type;
        typedef agg::conv_transform<conv_font_segm_type, agg::trans_double_path> conv_font_trans_type;

        agg::trans_double_path tcurve;
        conv_font_curve_type fcurves(m_fman.path_adaptor());
        conv_font_segm_type  fsegm(fcurves);
        conv_font_trans_type ftrans(fsegm, tcurve);

        tcurve.preserve_x_scale(m_preserve_x_scale.status());
        if(m_fixed_len.status()) tcurve.base_length(1140.0);
        tcurve.base_height(30.0);

        tcurve.add_paths(bspline1, bspline2);
        fsegm.approximation_scale(3.0);
        fcurves.approximation_scale(5.0);

        if(m_feng.load_font(full_file_name("timesi.ttf"), 0, agg::glyph_ren_outline))
        {
            double x = 0.0;
            double y = 3.0;
            const char* p = text;

            m_feng.hinting(false);
            m_feng.height(40);

            while(*p)
            {
                const agg::glyph_cache* glyph = m_fman.glyph(*p);
                if(glyph)
                {
                    if(x > tcurve.total_length1()) break;

                    m_fman.add_kerning(&x, &y);
                    m_fman.init_embedded_adaptors(glyph, x, y);

                    if(glyph->data_type == agg::glyph_data_outline)
                    {
                        ras.reset();
                        ras.add_path(ftrans);
                        r.color(agg::rgba8(0, 0, 0));
                        agg::render_scanlines(ras, sl, r);
                    }

                    // increment pen position
                    x += glyph->advance_x;
                    y += glyph->advance_y;
                }
                ++p;
            }
        }
        else
        {
            message("Please copy file timesi.ttf to the current directory\n"
                    "or download it from http://www.antigrain.com/timesi.zip");
        }



        typedef agg::conv_stroke<conv_bspline_type> conv_stroke_type;
        conv_stroke_type stroke1(bspline1);
        conv_stroke_type stroke2(bspline2);

        stroke1.width(2.0);
        stroke2.width(2.0);

        r.color(agg::rgba8(170, 50, 20, 100));
        ras.add_path(stroke1);
        agg::render_scanlines(ras, sl, r);

        ras.add_path(stroke2);
        agg::render_scanlines(ras, sl, r);


        //--------------------------
        // Render the "poly" tool and controls
        r.color(agg::rgba(0, 0.3, 0.5, 0.2));
        ras.add_path(m_poly1);
        agg::render_scanlines(ras, sl, r);

        ras.add_path(m_poly2);
        agg::render_scanlines(ras, sl, r);


        agg::render_ctrl(ras, sl, rb, m_fixed_len);
        agg::render_ctrl(ras, sl, rb, m_preserve_x_scale);
        agg::render_ctrl(ras, sl, rb, m_animate);
        agg::render_ctrl(ras, sl, rb, m_num_points);
        //--------------------------

    }
Example #28
0
bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding,
                                     wxNativeEncodingInfo *info,
                                     const wxString& facename,
                                     bool interactive)
{
#if wxUSE_GUI
    // we need a flag to prevent infinite recursion which happens, for
    // example, when GetAltForEncoding() is called from an OnPaint() handler:
    // in this case, wxYield() which is called from wxMessageBox() we use here
    // will lead to another call of OnPaint() and hence to another call of
    // GetAltForEncoding() -- and it is impossible to catch this from the user
    // code because we are called from wxFont ctor implicitly.

    // assume we're always called from the main thread, so that it is safe to
    // use a static var
    static bool s_inGetAltForEncoding = false;

    if ( interactive && s_inGetAltForEncoding )
        return false;

    ReentrancyBlocker blocker(s_inGetAltForEncoding);
#endif // wxUSE_GUI

    wxCHECK_MSG( info, false, wxT("bad pointer in GetAltForEncoding") );

    info->facename = facename;

    if ( encoding == wxFONTENCODING_DEFAULT )
    {
        encoding = wxFont::GetDefaultEncoding();
    }

    // if we failed to load the system default encoding, something is really
    // wrong and we'd better stop now -- otherwise we will go into endless
    // recursion trying to create the font in the msg box with the error
    // message
    if ( encoding == wxFONTENCODING_SYSTEM )
    {
        wxLogFatalError(_("can't load any font, aborting"));

        // wxLogFatalError doesn't return
    }

    wxString configEntry,
             encName = GetEncodingName(encoding);
    if ( !facename.empty() )
    {
        configEntry = facename + wxT("_");
    }
    configEntry += encName;

#if wxUSE_CONFIG && wxUSE_FILECONFIG
    // do we have a font spec for this encoding?
    wxString fontinfo;
    wxFontMapperPathChanger path(this, FONTMAPPER_FONT_FROM_ENCODING_PATH);
    if ( path.IsOk() )
    {
        fontinfo = GetConfig()->Read(configEntry);
    }

    // this special value means that we don't know of fonts for this
    // encoding but, moreover, have already asked the user as well and he
    // didn't specify any font neither
    if ( fontinfo == FONTMAPPER_FONT_DONT_ASK )
    {
        interactive = false;
    }
    else // use the info entered the last time
    {
        if ( !fontinfo.empty() && !facename.empty() )
        {
            // we tried to find a match with facename -- now try without it
            fontinfo = GetConfig()->Read(encName);
        }

        if ( !fontinfo.empty() )
        {
            if ( info->FromString(fontinfo) )
            {
                if ( wxTestFontEncoding(*info) )
                {
                    // ok, got something
                    return true;
                }
                //else: no such fonts, look for something else
                //      (should we erase the outdated value?)
            }
            else
            {
                wxLogDebug(wxT("corrupted config data: string '%s' is not a valid font encoding info"),
                           fontinfo);
            }
        }
        //else: there is no information in config about this encoding
    }
#endif // wxUSE_CONFIG

    // now try to map this encoding to a compatible one which we have on this
    // system
    wxFontEncodingArray equiv = wxEncodingConverter::GetAllEquivalents(encoding);
    size_t count = equiv.GetCount();
    bool foundEquivEncoding = false;
    wxFontEncoding equivEncoding = wxFONTENCODING_SYSTEM;
    if ( count )
    {
        for ( size_t i = 0; i < count && !foundEquivEncoding; i++ )
        {
            // don't test for encoding itself, we already know we don't have it
            if ( equiv[i] == encoding )
                continue;

            if ( TestAltEncoding(configEntry, equiv[i], info) )
            {
                equivEncoding = equiv[i];

                foundEquivEncoding = true;
            }
        }
    }

    // ask the user
#if wxUSE_FONTDLG
    if ( interactive )
    {
        wxString title(m_titleDialog);
        if ( !title )
            title << wxTheApp->GetAppDisplayName() << _(": unknown encoding");

        // built the message
        wxString encDesc = GetEncodingDescription(encoding),
                 msg;
        if ( foundEquivEncoding )
        {
            // ask the user if he wants to override found alternative encoding
            msg.Printf(_("No font for displaying text in encoding '%s' found,\nbut an alternative encoding '%s' is available.\nDo you want to use this encoding (otherwise you will have to choose another one)?"),
                       encDesc, GetEncodingDescription(equivEncoding));
        }
        else
        {
            msg.Printf(_("No font for displaying text in encoding '%s' found.\nWould you like to select a font to be used for this encoding\n(otherwise the text in this encoding will not be shown correctly)?"),
                       encDesc);
        }

        // the question is different in 2 cases so the answer has to be
        // interpreted differently as well
        int answer = foundEquivEncoding ? wxNO : wxYES;

        if ( wxMessageBox(msg, title,
                          wxICON_QUESTION | wxYES_NO,
                          m_windowParent) == answer )
        {
            wxFontData data;
            data.SetEncoding(encoding);
            data.EncodingInfo() = *info;
            wxFontDialog dialog(m_windowParent, data);
            if ( dialog.ShowModal() == wxID_OK )
            {
                wxFontData retData = dialog.GetFontData();

                *info = retData.EncodingInfo();
                info->encoding = retData.GetEncoding();

#if wxUSE_CONFIG && wxUSE_FILECONFIG
                // remember this in the config
                wxFontMapperPathChanger path2(this,
                                              FONTMAPPER_FONT_FROM_ENCODING_PATH);
                if ( path2.IsOk() )
                {
                    GetConfig()->Write(configEntry, info->ToString());
                }
#endif // wxUSE_CONFIG

                return true;
            }
            //else: the user canceled the font selection dialog
        }
        else
        {
            // the user doesn't want to select a font for this encoding
            // or selected to use equivalent encoding
            //
            // remember it to avoid asking the same question again later
#if wxUSE_CONFIG && wxUSE_FILECONFIG
            wxFontMapperPathChanger path2(this,
                                          FONTMAPPER_FONT_FROM_ENCODING_PATH);
            if ( path2.IsOk() )
            {
                GetConfig()->Write
                             (
                                configEntry,
                                foundEquivEncoding
                                    ? (const wxChar*)info->ToString().c_str()
                                    : FONTMAPPER_FONT_DONT_ASK
                             );
            }
#endif // wxUSE_CONFIG
        }
    }
    //else: we're in non-interactive mode
#else
    wxUnusedVar(equivEncoding);
#endif // wxUSE_FONTDLG

    return foundEquivEncoding;
}
Example #29
0
int path2(int y, int x){
	if(y == n -1) return triangle[y][x];
	cache2[y][x] = max(cache2[y - 1][x], cache2[y - 1][x - 1]) + triangle[y][x];
	return cache2[y][x] = path2(y);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
//                                       place ring
//
// Place autonomous ring while sensing the IR beacon
//
/////////////////////////////////////////////////////////////////////////////////////////////////
void placering (string iSide, int iPos, int iColumn, int iHeight)
{
	if (iColumn == 2)
	{
		moveLift (0, 0, UP);
	}
	else
	{
		if (iHeight == 1)
		{
			moveLift(40, 571, UP);
		}
		else if (iHeight == 2)
		{
			moveLift(40, 3095, UP);
		}
		else if (iHeight == 3)
		{
			moveLift(40, 5233, UP);
		}
	}

	if (iPos == 1)
	{
		if (iColumn == 1)
		{
			path1 (iSide,33, 15);
		}
		else if (iColumn == 2)
		{
			move(50, 16, FORWARD);

			if (strcmp(iSide, "left")== 0)
			{
				GyroTurn (50, 45, LEFT);
			}
			else
			{
				GyroTurn (50, 45, RIGHT);
			}

			move(50, 21, FORWARD);

			if (strcmp(iSide, "left")== 0)
			{
				GyroTurn (50, 45, LEFT);
			}
			else
			{
				GyroTurn (50, 45, RIGHT);
			}

			move(50, 13, FORWARD);

			if (strcmp(iSide, "left")== 0)
			{
				GyroTurn (50, 30, RIGHT);
			}
			else
			{
				GyroTurn (50, 30, LEFT);
			}

			move(50, 1, BACKWARD);

			moveLift(40, 500, UP);

			move(50, 3, FORWARD);
		}
		else if (iColumn == 3)
		{
			path2 (iSide, 20, 31);
		}
	}
	else if (iPos == 2)
	{
		if (iColumn == 1)
		{
			path1 (iSide, 15, 12);
		}
		else if (iColumn == 2)
		{
			move(50, 33, FORWARD);

			if (strcmp(iSide, "left")== 0)
			{
				GyroTurn (50, 90, LEFT);
			}
			else
			{
				GyroTurn (50, 90, RIGHT);
			}

			move(50, 19, FORWARD);

			if (strcmp(iSide, "left")== 0)
			{
				GyroTurn (50, 30, RIGHT);
			}
			else
			{
				GyroTurn (50, 30, LEFT);
			}

			move(50, 2, BACKWARD);

			moveLift(40, 500, UP);

			move(50, 3, FORWARD);
		}
		else if (iColumn == 3)
		{
			path2 (iSide, 35, 13);
		}
	}
	else if (iPos == 3)
	{
		if (iColumn == 1)
		{
			path1 (iSide, 12, 14);
		}
		else if (iColumn == 2)
		{
			move(50, 12, FORWARD);

			if (strcmp(iSide, "left")== 0)
			{
				GyroTurn (50, 90, LEFT);
			}
			else
			{
				GyroTurn (50, 90, RIGHT);
			}

			move(50, 13, FORWARD);

			if (strcmp(iSide, "left")== 0)
			{
				GyroTurn (50, 90, RIGHT);
			}
			else
			{
				GyroTurn (50, 90, LEFT);
			}

			move(50, 18, FORWARD);

			if (strcmp(iSide, "left")== 0)
			{
				GyroTurn (50, 35, LEFT);
			}
			else
			{
				GyroTurn (50, 35, RIGHT);
			}

			move(50, 1, BACKWARD);

			moveLift(40, 500, UP);

			move(50, 4, FORWARD);
		}
		else if (iColumn == 3)
		{
			path3 (iSide, 15);
		}
	}

	servo[pivotLeft]  = 0;
	servo[pivotRight] = 255;

	if (iHeight == 1)
	{
		moveLift(40, 571, DOWN);
	}
	else if (iHeight == 2)
	{
		moveLift(40, 3095, DOWN);
	}
	else if (iHeight == 3)
	{
		moveLift(40, 5233,DOWN);
	}
}