MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    ui->actionGenerate_Polygons->setDisabled(true);
    ui->actionAddPolygons->setDisabled(true);
    ui->actionPolygons_List->setDisabled(true);
    ui->actionSave->setDisabled(true);

    this->setWindowTitle("2D Polygon Packing Problem");

    connect(ui->actionGenerate_Polygons, SIGNAL(triggered()), this, SLOT(generatePolygons()));
    connect(ui->actionNew, SIGNAL(triggered()), this, SLOT(neo()));
    connect(ui->actionAddPolygons, SIGNAL(triggered()), this, SLOT(addPolygons()));
    connect(ui->actionPolygons_List, SIGNAL(triggered()), this, SLOT(polygonsList()));
    connect(ui->actionSave, SIGNAL(triggered()), this, SLOT(save()));

    stripHeight = SCENE_HEIGHT;

    settings = new Settings(this);
    this->setCentralWidget(settings);
    this->resize(800, 600);
}
Ejemplo n.º 2
0
UT_SVGMatrix UT_SVGMatrix::skewY (float angle) // degrees, I assume
{
  double mod_angle = static_cast<double>(angle);

  if (mod_angle > 180.0)
    mod_angle -= floor (mod_angle / 180.0) * 180.0;
  else if (mod_angle < 0.0)
    mod_angle += (1.0 + floor ((-mod_angle) / 180.0)) * 180.0;

  if ((mod_angle > 89.9) && (mod_angle < 90.1)) // Sorry, I'm being judgemental here.
    {
      UT_SVGMatrix neo(a, b, c, d, e, f);
      return neo;
    }

  float T = static_cast<float>(tan ((mod_angle * UT_PI) / 180.0));

  UT_SVGMatrix neo(a+T*c, b+T*d, c, d, e, f);

  return neo;
}
Ejemplo n.º 3
0
UT_SVGMatrix UT_SVGMatrix::inverse ()
{
  float det = a * d - b * c;

  if (det == 0) // or < tol.?
    {
      UT_SVGMatrix neo; // singular matrix, no inverse; return identity; ought to throw exception, etc.
      return neo;
    }

  UT_SVGMatrix neo(d/det, -b/det, -c/det, a/det, (c*f-e*d)/det, (e*b-f*a)/det);

  return neo;
}
Ejemplo n.º 4
0
UT_SVGMatrix UT_SVGMatrix::rotateFromVector (float x, float y)
{
  double r = sqrt (static_cast<double>(x) * static_cast<double>(x) + static_cast<double>(y) * static_cast<double>(y));

  if (r == 0) // or < tol.?
    {
      UT_SVGMatrix neo(a,b,c,d,e,f); // not a vector; ought to throw exception, etc.
      return neo;
    }

  float cos_angle = static_cast<float>(static_cast<double>(x) / r);
  float sin_angle = static_cast<float>(static_cast<double>(y) / r);

  UT_SVGMatrix rotation(cos_angle, sin_angle, -sin_angle, cos_angle, 0, 0);

  return multiply(rotation);
}
Ejemplo n.º 5
0
int main(int argc, char** argv)
{
  if(argc == 2)
  {
    underwood::GREETING();

    std::ifstream inputFile;
    inputFile.open(argv[1], std::ios::in);

    if(inputFile.is_open())
    {
        matrix<int> neo(inputFile);
        inputFile.close();
        std::cout << neo;
        size_t u,v;
        underwood::PROMPT_U_V(u,v);
        std::cout << "The shortest path from " << u << " to " << v << "; p = "
                  << CALCULATE_SHORTEST_PATH(neo, u, v) << std::endl;
        return EXIT_SUCCESS;
    }
    else 
    {
        std::cout << "Failed to open file\n";
        return 2;
    }

  }

  else
  {

    std::cerr << "enter filename as argument\n";
    std::cerr << "File must be of format:\n"
              << "1. The input data will be in the following format within the file.\n"
              << "6\n"
              << "// The number of vertices in the vertex set V.\n"
              << "1 2 3 4 5 6\t"
              << "// The vertex set, V, space delimited.\n"
              << "12\t" << "// The number of edges in th edge set E.\n"
              << "1 3\t" << "// Edge (u, v), one per line, u and v space delimited\n"
              << "1 4\t" << "......" << std::endl;
    return 1;

  }
}
Ejemplo n.º 6
0
UT_SVGMatrix UT_SVGMatrix::flipY ()
{
  UT_SVGMatrix neo(a, b, -c, -d, e, f);

  return neo;
}
Ejemplo n.º 7
0
UT_SVGMatrix UT_SVGMatrix::flipX ()
{
  UT_SVGMatrix neo(-a, -b, c, d, e, f);

  return neo;
}
Ejemplo n.º 8
0
UT_SVGMatrix UT_SVGMatrix::scaleNonUniform (float scaleFactorX, float scaleFactorY)
{
  UT_SVGMatrix neo(a*scaleFactorX, b*scaleFactorX, c*scaleFactorY, d*scaleFactorY, e, f);

  return neo;
}
Ejemplo n.º 9
0
UT_SVGMatrix UT_SVGMatrix::scale (float scaleFactor)
{
  UT_SVGMatrix neo(a*scaleFactor, b*scaleFactor, c*scaleFactor, d*scaleFactor, e, f);

  return neo;
}
Ejemplo n.º 10
0
UT_SVGMatrix UT_SVGMatrix::translate (float x, float y)
{
  UT_SVGMatrix neo(a, b, c, d, a*x+c*y+e, b*x+d*y+f);

  return neo;
}