Esempio n. 1
0
void Model::DeleteObjTree(vector<Gtk::TreeModel::Path> &iter)
{
  objtree.DeleteSelected (iter);
  ClearGCode();
  ClearLayers();
  ModelChanged();
}
Esempio n. 2
0
void Model::OptimizeRotation(Shape *shape, TreeObject *object)
{
  if (!shape)
    return; // FIXME: rotate entire Objects ...
  shape->OptimizeRotation();
  ModelChanged();
}
Esempio n. 3
0
void Model::ReadStl(Glib::RefPtr<Gio::File> file)
{
  STL stl;
  if (stl.loadFile (file->get_path()) == 0)
    AddStl(NULL, stl, file->get_path());
  ModelChanged();
}
Esempio n. 4
0
void Model::TwistObject(Shape *shape, TreeObject *object, double angle)
{
  if (!shape)
    return;
  shape->Twist(angle);
  ModelChanged();
}
Esempio n. 5
0
void Model::Mirror(Shape *shape, TreeObject *object)
{
  if (shape)
    shape->mirror();
  else // if (object) object->mirror();
    return;
  ModelChanged();
}
Esempio n. 6
0
void Model::RotateObject(Shape* shape, TreeObject* object, Vector4d rotate)
{
  if (!shape)
    return;
  Vector3d rot(rotate.x(), rotate.y(), rotate.z());
  shape->Rotate(rot, rotate.w());
  ModelChanged();
}
Esempio n. 7
0
void Model::ReadGCode(Glib::RefPtr<Gio::File> file)
{
  PrintInhibitor inhibitPrint(this);
  m_progress.start ("Converting", 100.0);
  gcode.Read (this, &m_progress, file->get_path());
  m_progress.stop ("Done");
  ModelChanged();
}
Esempio n. 8
0
void Model::InvertNormals(Shape *shape, TreeObject *object)
{
  if (shape)
    shape->invertNormals();
  else // if (object) object->invertNormals();
    return;
  ModelChanged();
}
Esempio n. 9
0
void DeviceProperties::SetDeviceManager(DeviceManager* manager) {
    manager_ = manager;
    connect(manager_, SIGNAL(dataChanged(QModelIndex, QModelIndex)),
            SLOT(ModelChanged()));
    connect(manager_, SIGNAL(rowsInserted(QModelIndex, int, int)),
            SLOT(ModelChanged()));
    connect(manager_, SIGNAL(rowsRemoved(QModelIndex, int, int)),
            SLOT(ModelChanged()));
}
Esempio n. 10
0
void Model::ScaleObjectZ(Shape *shape, TreeObject *object, double scale)
{
  if (shape)
    shape->ScaleZ(scale);
  else if(object)
    for (uint s = 0;s<object->shapes.size(); s++) {
      //      double fact = object->shapes[s].getScaleFactorZ();
      object->shapes[s]->ScaleZ(scale);
    }
  else return;
  ModelChanged();
}
Esempio n. 11
0
/* Scales the object on changes of the scale slider */
void Model::ScaleObject(Shape *shape, TreeObject *object, double scale)
{
  if (shape)
    shape->Scale(scale);
  else if(object)
    //    for (uint s = 0;s<object->shapes.size(); s++) {
      //double fact = object->shapes[s].getScaleFactor();
      object->transform3D.scale(scale);
  //}
  else return;
  ModelChanged();
}
Esempio n. 12
0
void Model::PlaceOnPlatform(Shape *shape, TreeObject *object)
{
  if (shape)
    shape->PlaceOnPlatform();
  else if(object) {
    Transform3D * transf = &object->transform3D;
    transf->move(Vector3f(0, 0, -transf->getTranslation().z()));
    for (uint s = 0;s<object->shapes.size(); s++) {
      object->shapes[s]->PlaceOnPlatform();
    }
  }
  else return;
  ModelChanged();
}
Esempio n. 13
0
// rearrange unselected shapes in random sequence
bool Model::AutoArrange(vector<Gtk::TreeModel::Path> &path)
{
  // all shapes
  vector<Shape*>   allshapes;
  vector<Matrix4d> transforms;
  objtree.get_all_shapes(allshapes, transforms);

  // selected shapes
  vector<Shape*>   selshapes;
  vector<Matrix4d> seltransforms;
  objtree.get_selected_shapes(path, selshapes, seltransforms);

  // get unselected shapes
  vector<Shape*>   unselshapes;
  vector<Matrix4d> unseltransforms;

  for(uint s=0; s < allshapes.size(); s++) {
    bool issel = false;
    for(uint ss=0; ss < selshapes.size(); ss++)
      if (selshapes[ss] == allshapes[s]) {
	issel = true; break;
      }
    if (!issel) {
      unselshapes.    push_back(allshapes[s]);
      unseltransforms.push_back(transforms[s]);
    }
  }

  // find place for unselected shapes
  int num = unselshapes.size();
  vector<int> rand_seq(num,1); // 1,1,1...
  partial_sum(rand_seq.begin(), rand_seq.end(), rand_seq.begin()); // 1,2,3,...,N

  Glib::TimeVal timeval;
  timeval.assign_current_time();
  srandom((unsigned long)(timeval.as_double()));
  random_shuffle(rand_seq.begin(), rand_seq.end()); // shuffle

  for(int s=0; s < num; s++) {
    int index = rand_seq[s]-1;
    // use selshapes as vector to fill up
    Vector3d trans = FindEmptyLocation(selshapes, seltransforms, unselshapes[index]);
    selshapes.push_back(unselshapes[index]);
    seltransforms.push_back(unseltransforms[index]); // basic transform, not shape
    selshapes.back()->transform3D.move(trans);
    CalcBoundingBoxAndCenter();
  }
  ModelChanged();
  return true;
}
Esempio n. 14
0
void Model::ReadStl(Glib::RefPtr<Gio::File> file, filetype_t ftype)
{
  bool autoplace = settings.Misc.ShapeAutoplace;
  string path = file->get_path();
  vector<Shape*> shapes = ReadShapes(file, 0, ftype);
  if (shapes.size()==1){
    AddShape(NULL, shapes.front(), shapes.front()->filename, autoplace);
  }
  else for (uint i=0;i<shapes.size();i++){
      // do not autoplace to keep saved positions
      AddShape(NULL, shapes[i], shapes[i]->filename, false);
    }
  shapes.clear();
  ModelChanged();
  return;
}
Esempio n. 15
0
void CQDM_Edit::LMouseUp(Vec3D<> P)
{
	if (LMBDown){
		LMBDown = false;

		int MatIndex = 0;
		emit GetCurMaterial(&MatIndex);
		//apply the stuff here!

		for (int i=0; i<(int)CurHighlighted.size(); i++){
			SetMat(CurHighlighted[i], MatIndex);
		}
		if ((int)CurHighlighted.size()>0) emit ModelChanged();

		CurHighlighted.clear();
		emit UpdateGLWindows();
	}
	
}
Esempio n. 16
0
void VoxCad::SetupVoxInfoWindow(void)
{
	VoxInfoDockWidget = new QDockWidget(this);
	VoxInfoDockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
	VoxInfoDlg = new Dlg_VoxInfo(VoxInfoDockWidget);
	VoxInfoDockWidget->setWidget(VoxInfoDlg);
    VoxInfoDockWidget->setWindowTitle("Voxel Info");

	connect(VoxInfoDockWidget->toggleViewAction(), SIGNAL(toggled(bool)), this, SLOT(ViewVoxInfoWindow(bool)));
	connect(VoxInfoDlg, SIGNAL(GetCurIndex(int*)), this, SLOT(GetCurGLSelected(int*)));
	connect(VoxInfoDlg, SIGNAL(GetDMInfoString(QString*)), &MainObj, SLOT(GetVXCInfoString(QString*)));
	connect(VoxInfoDlg, SIGNAL(GetVoxInfoString(int, QString*)), &MainObj, SLOT(GetVoxInfoString(int, QString*)));
	connect(&MainObj, SIGNAL(ModelChanged()), VoxInfoDlg, SLOT(UpdateUI()));


	VoxInfoDlg->UpdateUI();
	addDockWidget(Qt::RightDockWidgetArea, VoxInfoDockWidget);

}
Esempio n. 17
0
int Model::AddShape(TreeObject *parent, Shape *shape, string filename, bool autoplace)
{
  //Shape *retshape;
  bool found_location=false;


  FlatShape* flatshape = dynamic_cast<FlatShape*>(shape);
  if (flatshape != NULL)
    shape = flatshape;

  if (!parent) {
    if (objtree.Objects.size() <= 0)
      objtree.newObject();
    parent = objtree.Objects.back();
  }
  g_assert (parent != NULL);

  // Decide where it's going
  Vector3d trans = Vector3d(0,0,0);
  if (autoplace) found_location = FindEmptyLocation(trans, shape);
  // Add it to the set
  size_t found = filename.find_last_of("/\\");
  Gtk::TreePath path = objtree.addShape(parent, shape, filename.substr(found+1));
  Shape *retshape = parent->shapes.back();

  // Move it, if we found a suitable place
  if (found_location) {
    retshape->transform3D.move(trans);
  }

  //if (autoplace) retshape->PlaceOnPlatform();

  // Update the view to include the new object
  ModelChanged();
    // Tell everyone
  m_signal_stl_added.emit (path);

  return 0;
}
Esempio n. 18
0
void
FilePermissionsView::MessageReceived(BMessage* message)
{
	switch(message->what) {
		case kPermissionsChanged:
			if (fModel != NULL) {
				mode_t newPermissions = 0;
				newPermissions
					= (mode_t)((fReadUserCheckBox->Value() ? S_IRUSR : 0)
					| (fReadGroupCheckBox->Value() ? S_IRGRP : 0)
					| (fReadOtherCheckBox->Value() ? S_IROTH : 0)

					| (fWriteUserCheckBox->Value() ? S_IWUSR : 0)
					| (fWriteGroupCheckBox->Value() ? S_IWGRP : 0)
					| (fWriteOtherCheckBox->Value() ? S_IWOTH : 0)

					| (fExecuteUserCheckBox->Value() ? S_IXUSR : 0)
					| (fExecuteGroupCheckBox->Value() ? S_IXGRP :0)
					| (fExecuteOtherCheckBox->Value() ? S_IXOTH : 0));

				BNode node(fModel->EntryRef());

				if (node.InitCheck() == B_OK)
					node.SetPermissions(newPermissions);
				else {
					ModelChanged(fModel);
					beep();
				}
			}
			break;

		case kNewOwnerEntered:
			if (fModel != NULL) {
				uid_t owner;
				if (sscanf(fOwnerTextControl->Text(), "%d", &owner) == 1) {
					BNode node(fModel->EntryRef());
					if (node.InitCheck() == B_OK)
						node.SetOwner(owner);
					else {
						ModelChanged(fModel);
						beep();
					}
				} else {
					ModelChanged(fModel);
					beep();
				}
			}
			break;

		case kNewGroupEntered:
			if (fModel != NULL) {
				gid_t group;
				if (sscanf(fGroupTextControl->Text(), "%d", &group) == 1) {
					BNode node(fModel->EntryRef());
					if (node.InitCheck() == B_OK)
						node.SetGroup(group);
					else {
						ModelChanged(fModel);
						beep();
					}
				} else {
					ModelChanged(fModel);
					beep();
				}
			}
			break;

		default:
			_inherited::MessageReceived(message);
			break;
	}
}
Esempio n. 19
0
void Model::LoadConfig(Glib::RefPtr<Gio::File> file)
{
  settings.load_settings(file);
  ModelChanged();
}
Esempio n. 20
0
FilePermissionsView::FilePermissionsView(BRect rect, Model* model)
	:
	BView(rect, "FilePermissionsView", B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW),
	fModel(model)
{
	SetViewUIColor(B_PANEL_BACKGROUND_COLOR);

	// Constants for the column labels: "User", "Group" and "Other".
	const float kColumnLabelMiddle = 77, kColumnLabelTop = 0,
		kColumnLabelSpacing = 37, kColumnLabelBottom = 39,
		kColumnLabelWidth = 80, kAttribFontHeight = 10;

	BStringView* strView;

	strView = new RotatedStringView(
		BRect(kColumnLabelMiddle - kColumnLabelWidth / 2,
			kColumnLabelTop,
			kColumnLabelMiddle + kColumnLabelWidth / 2,
			kColumnLabelBottom),
		"", B_TRANSLATE("Owner"));
	AddChild(strView);
	strView->SetFontSize(kAttribFontHeight);

	strView = new RotatedStringView(
		BRect(kColumnLabelMiddle - kColumnLabelWidth / 2
				+ kColumnLabelSpacing,
			kColumnLabelTop,
			kColumnLabelMiddle + kColumnLabelWidth / 2 + kColumnLabelSpacing,
			kColumnLabelBottom),
		"", B_TRANSLATE("Group"));
	AddChild(strView);
	strView->SetFontSize(kAttribFontHeight);

	strView = new RotatedStringView(
		BRect(kColumnLabelMiddle - kColumnLabelWidth / 2
				+ 2 * kColumnLabelSpacing,
			kColumnLabelTop,
			kColumnLabelMiddle + kColumnLabelWidth / 2
				+ 2 * kColumnLabelSpacing,
			kColumnLabelBottom),
		"", B_TRANSLATE("Other"));
	AddChild(strView);
	strView->SetFontSize(kAttribFontHeight);

	// Constants for the row labels: "Read", "Write" and "Execute".
	const float kRowLabelLeft = 10, kRowLabelTop = kColumnLabelBottom + 5,
		kRowLabelVerticalSpacing = 18, kRowLabelRight = kColumnLabelMiddle
		- kColumnLabelSpacing / 2 - 5, kRowLabelHeight = 14;

	strView = new BStringView(BRect(kRowLabelLeft, kRowLabelTop,
			kRowLabelRight, kRowLabelTop + kRowLabelHeight),
		"", B_TRANSLATE("Read"));
	AddChild(strView);
	strView->SetAlignment(B_ALIGN_RIGHT);
	strView->SetFontSize(kAttribFontHeight);

	strView = new BStringView(BRect(kRowLabelLeft, kRowLabelTop
			+ kRowLabelVerticalSpacing, kRowLabelRight, kRowLabelTop
			+ kRowLabelVerticalSpacing + kRowLabelHeight),
		"", B_TRANSLATE("Write"));
	AddChild(strView);
	strView->SetAlignment(B_ALIGN_RIGHT);
	strView->SetFontSize(kAttribFontHeight);

	strView = new BStringView(BRect(kRowLabelLeft, kRowLabelTop
			+ 2 * kRowLabelVerticalSpacing, kRowLabelRight, kRowLabelTop
			+ 2 * kRowLabelVerticalSpacing + kRowLabelHeight),
		"", B_TRANSLATE("Execute"));
	AddChild(strView);
	strView->SetAlignment(B_ALIGN_RIGHT);
	strView->SetFontSize(kAttribFontHeight);

	// Constants for the 3x3 check box array.
	const float kLeftMargin = kRowLabelRight + 5,
		kTopMargin = kRowLabelTop - 2,
		kHorizontalSpacing = kColumnLabelSpacing,
		kVerticalSpacing = kRowLabelVerticalSpacing,
		kCheckBoxWidth = 18, kCheckBoxHeight = 18;

	BCheckBox** checkBoxArray[3][3] = {
		{
			&fReadUserCheckBox,
			&fReadGroupCheckBox,
			&fReadOtherCheckBox
		},
		{
			&fWriteUserCheckBox,
			&fWriteGroupCheckBox,
			&fWriteOtherCheckBox
		},
		{
			&fExecuteUserCheckBox,
			&fExecuteGroupCheckBox,
			&fExecuteOtherCheckBox
		}
	};

	for (int32 x = 0; x < 3; x++) {
		for (int32 y = 0; y < 3; y++) {
			*checkBoxArray[y][x] =
				new BCheckBox(BRect(kLeftMargin + kHorizontalSpacing * x,
						kTopMargin + kVerticalSpacing * y,
						kLeftMargin + kHorizontalSpacing * x + kCheckBoxWidth,
						kTopMargin + kVerticalSpacing * y + kCheckBoxHeight),
					"", "", new BMessage(kPermissionsChanged));
			AddChild(*checkBoxArray[y][x]);
		}
	}

	const float kTextControlLeft = 170, kTextControlRight = 270,
		kTextControlTop = kRowLabelTop - 29,
		kTextControlHeight = 14, kTextControlSpacing = 16;

	strView = new BStringView(BRect(kTextControlLeft, kTextControlTop,
		kTextControlRight, kTextControlTop + kTextControlHeight), "",
		B_TRANSLATE("Owner"));
	strView->SetAlignment(B_ALIGN_CENTER);
	strView->SetFontSize(kAttribFontHeight);
	AddChild(strView);

	fOwnerTextControl = new BTextControl(
		BRect(kTextControlLeft,
			kTextControlTop - 2 + kTextControlSpacing,
			kTextControlRight,
			kTextControlTop + kTextControlHeight - 2 + kTextControlSpacing),
		"", "", "", new BMessage(kNewOwnerEntered));
	fOwnerTextControl->SetDivider(0);
	AddChild(fOwnerTextControl);

	strView = new BStringView(BRect(kTextControlLeft,
			kTextControlTop + 11 + 2 * kTextControlSpacing,
			kTextControlRight,
			kTextControlTop + 11 + 2 * kTextControlSpacing
				+ kTextControlHeight),
		"", B_TRANSLATE("Group"));
	strView->SetAlignment(B_ALIGN_CENTER);
	strView->SetFontSize(kAttribFontHeight);
	AddChild(strView);

	fGroupTextControl = new BTextControl(BRect(kTextControlLeft,
			kTextControlTop + 10 + 3 * kTextControlSpacing,
			kTextControlRight,
			kTextControlTop + 10 + 3 * kTextControlSpacing + kTextControlHeight),
		"", "", "", new BMessage(kNewGroupEntered));
	fGroupTextControl->SetDivider(0);
	AddChild(fGroupTextControl);

	ModelChanged(model);
}