// on left mouse button down void CSplitterFrame::OnLButtonDown(UINT nFlags, CPoint point) { INDEX ctParentLevels = 0; if(sp_bDockingEnabled) { ctParentLevels = 1; } CRect rc; ASSERT(GetParent()!=NULL); pDockedParent = GetParent(); pFloatingParent = pDockedParent->GetParent(); ASSERT(pFloatingParent!=NULL); for(INDEX ipar=0; ipar<ctParentLevels; ipar++) { pFloatingParent = pFloatingParent->GetParent(); ASSERT(pFloatingParent!=NULL); } /* CPoint pt = GetAbsPosition(); pt.x += point.x; SetAbsPosition(pt); */ SetCapture(); sp_ptStartPoint = GetAbsPosition(); ChangeParent(pFloatingParent); CWnd::OnLButtonDown(nFlags, point); }
//Search in buffered_nodes but change new_nodes vector<Node> Design::Rebranch (int worst_sink, const vector<Node> & buffered_nodes){ vector<Node> new_nodes = buffered_nodes; int current = worst_sink; int parent = new_nodes.at(current).parent_; while (parent != 0){//0 is the root Node current_node = new_nodes.at(current); Node parent_node = new_nodes.at(parent); int grandparent = parent_node.parent_; if (current_node.type_ == Node::BUFFER && parent_node.get_children().size()>1){ Node upstream_buffer_node = FindFirstUpstreamBuffer(parent_node.index_, new_nodes); //Even upstream_buffer_node is the root, we still try rebranch at the root ChangeParent(current_node.index_, parent_node.index_, upstream_buffer_node.index_, new_nodes); InsertCornerNode(current_node.index_,upstream_buffer_node.index_, new_nodes); } current = parent; parent = new_nodes.at(current).parent_; } //remove buffers in new_nodes for (int i = 0; i < new_nodes.size(); i++){ if (new_nodes.at(i).type_ == Node::BUFFER){ new_nodes.at(i).type_ = Node::NORMAL; } } return new_nodes; }
// on left mouse button up void CSplitterFrame::OnLButtonUp(UINT nFlags, CPoint point) { if(GetCapture()==this) { ReleaseCapture(); ChangeParent(pDockedParent); UpdateParent(); // SetOrientation(uiOrientation); } CWnd::OnLButtonUp(nFlags, point); }
//Search in buffered_nodes but change new_nodes vector<Node> Design::Rebranch (int worst_sink, const vector<Node> & buffered_nodes){ vector<Node> new_nodes = buffered_nodes; int current = worst_sink; int parent = new_nodes.at(current).parent_; while (parent != 0){//0 is the root Node current_node = new_nodes.at(current); Node parent_node = new_nodes.at(parent); int grandparent = parent_node.parent_; if (current_node.type_ == Node::BUFFER && parent_node.get_children().size()>1){ Node upstream_buffer_node = FindFirstUpstreamBuffer(parent_node.index_, new_nodes); //Even upstream_buffer_node is the root, we still try rebranch at the root Node new_steiner_node; new_steiner_node.index_ = new_nodes.size(); Node direction_node = new_nodes.at(upstream_buffer_node.parent_); new_steiner_node.point_ = upstream_buffer_node.point_; if (direction_node.point_.x > upstream_buffer_node.point_.x){ new_steiner_node.point_.x += 1; }else if (direction_node.point_.x < upstream_buffer_node.point_.x){ new_steiner_node.point_.x -= 1; } if (direction_node.point_.y > upstream_buffer_node.point_.y){ new_steiner_node.point_.y += 1; }else if (direction_node.point_.y < upstream_buffer_node.point_.y){ new_steiner_node.point_.y -= 1; } new_steiner_node.parent_ = direction_node.index_; new_nodes.at(direction_node.index_).remove_child(upstream_buffer_node.index_); new_nodes.at(direction_node.index_).add_child(new_steiner_node.index_); new_steiner_node.add_child(upstream_buffer_node.index_); // new_steiner_node.add_child(current_node.index_); // current_node.parent_ = new_steiner_node.index_; upstream_buffer_node.parent_ = new_steiner_node.index_; new_nodes.push_back(new_steiner_node); ChangeParent(current_node.index_, parent_node.index_, new_steiner_node.index_, new_nodes); InsertCornerNode(current_node.index_,new_steiner_node.index_, new_nodes); parent = new_steiner_node.index_; } current = parent; parent = new_nodes.at(current).parent_; } /* //remove buffers in new_nodes for (int i = 0; i < new_nodes.size(); i++){ if (new_nodes.at(i).type_ == Node::BUFFER){ new_nodes.at(i).type_ = Node::NORMAL; } }*/ return new_nodes; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); scene = new Scene(this); ui->glwidget->SetScene(scene); //ui->raycastwidget->s = scene; QObject::connect(ui->object_create_button, SIGNAL(clicked(bool)), scene, SLOT(CreateObject())); QObject::connect(ui->octree_create_button, SIGNAL(clicked(bool)), this, SLOT(CreateOctreePressed())); QObject::connect(ui->object_tree, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(SelectObject(QTreeWidgetItem *, QTreeWidgetItem *))); QObject::connect(scene, SIGNAL(UpdateObjList()), this, SLOT(UpdateObjList())); QObject::connect(scene, SIGNAL(UpdateDrawing()), this, SLOT(UpdateDrawing())); QObject::connect(ui->octree_spread_slider, SIGNAL(valueChanged(int)), scene, SLOT(ChangeOctreeSpread(int))); QObject::connect(ui->pos_x, SIGNAL(valueChanged(double)), this, SLOT(UpdateCurrentObjectTransform(double))); QObject::connect(ui->pos_y, SIGNAL(valueChanged(double)), this, SLOT(UpdateCurrentObjectTransform(double))); QObject::connect(ui->pos_z, SIGNAL(valueChanged(double)), this, SLOT(UpdateCurrentObjectTransform(double))); QObject::connect(ui->rot_x, SIGNAL(valueChanged(double)), this, SLOT(UpdateCurrentObjectTransform(double))); QObject::connect(ui->rot_y, SIGNAL(valueChanged(double)), this, SLOT(UpdateCurrentObjectTransform(double))); QObject::connect(ui->rot_z, SIGNAL(valueChanged(double)), this, SLOT(UpdateCurrentObjectTransform(double))); QObject::connect(ui->sca_x, SIGNAL(valueChanged(double)), this, SLOT(UpdateCurrentObjectTransform(double))); QObject::connect(ui->sca_y, SIGNAL(valueChanged(double)), this, SLOT(UpdateCurrentObjectTransform(double))); QObject::connect(ui->sca_z, SIGNAL(valueChanged(double)), this, SLOT(UpdateCurrentObjectTransform(double))); QObject::connect(ui->name_lineEdit, SIGNAL(textEdited(QString)), this, SLOT(UpdateCurrentObjectName(QString))); QObject::connect(ui->lines_checkBox, SIGNAL(toggled(bool)), this, SLOT(UpdateCurrentObjectCheck(bool))); QObject::connect(ui->hide_checkBox, SIGNAL(toggled(bool)), this, SLOT(UpdateCurrentObjectCheck(bool))); ui->obj_content->setEnabled(false); QObject::connect(ui->object_tree, SIGNAL(ChangeParent(QString, QString)), scene, SLOT(Reparent(QString, QString))); QObject::connect(ui->delete_object, SIGNAL(clicked(bool)), scene, SLOT(DeleteCurrentObject())); QObject::connect(ui->operate_octree_button, SIGNAL(clicked(bool)), this, SLOT(OperateOctreePressed())); QObject::connect(ui->save_pushButton,SIGNAL(clicked(bool)),this,SLOT(SaveScenePress())); QObject::connect(ui->load_pushButton,SIGNAL(clicked(bool)),this,SLOT(LoadScenePress())); QObject::connect(ui->duplicate_button,SIGNAL(clicked(bool)),this,SLOT(DuplicateObjectPressed())); QObject::connect(ui->faceColor,SIGNAL(clicked(bool)),this,SLOT(SetFaceColor())); QObject::connect(ui->lineColor,SIGNAL(clicked(bool)),this,SLOT(SetLineColor())); faceColor = QColor(0,0,0); ui->faceColor->setStyleSheet(colorButtonStyle.arg(faceColor.name())); lineColor = QColor(255,255,255); ui->lineColor->setStyleSheet(colorButtonStyle.arg(lineColor.name())); QObject::connect(ui->clear_pushButton,SIGNAL(clicked(bool)),this,SLOT(ClearScene())); QObject::connect(ui->create_csg_pushButton,SIGNAL(clicked(bool)),this,SLOT(CreateCSGPressed())); QObject::connect(ui->create_he_button,SIGNAL(clicked(bool)),this,SLOT(CreateHEPressed())); QObject::connect(ui->edge_spinBox,SIGNAL(valueChanged(int)),this,SLOT(UpdateCurrentObjectHE())); //QObject::connect(ui->face_spinBox,SIGNAL(valueChanged(int)),this,SLOT(UpdateCurrentObjectHE())); // QObject::connect(ui->face_pushButton,SIGNAL(clicked(bool)),this,SLOT(GetEdgeFace())); QObject::connect(ui->next_pushButton,SIGNAL(clicked(bool)),this,SLOT(GetNextEdge())); QObject::connect(ui->mate_pushButton,SIGNAL(clicked(bool)),this,SLOT(GetMateEdge())); QObject::connect(ui->mef,SIGNAL(clicked(bool)),this,SLOT(MEF())); QObject::connect(ui->mev,SIGNAL(clicked(bool)),this,SLOT(MEV())); QObject::connect(ui->translate,SIGNAL(clicked(bool)),this,SLOT(Translate())); QObject::connect(ui->extrude,SIGNAL(clicked(bool)),this,SLOT(Extrude())); QObject::connect(ui->create_bezier_button,SIGNAL(clicked(bool)),this,SLOT(CreateBezierPressed())); QObject::connect(ui->bezi,SIGNAL(valueChanged(int)),this,SLOT(SelectBezierControl())); QObject::connect(ui->bezj,SIGNAL(valueChanged(int)),this,SLOT(SelectBezierControl())); QObject::connect(ui->bezx,SIGNAL(valueChanged(double)),this,SLOT(SelectBezierPosition())); QObject::connect(ui->bezy,SIGNAL(valueChanged(double)),this,SLOT(SelectBezierPosition())); QObject::connect(ui->bezz,SIGNAL(valueChanged(double)),this,SLOT(SelectBezierPosition())); ui->specific_stackedWidget->setCurrentWidget(ui->default_page); }