47 #include "DataControlPlugin.hh" 49 #include <ACG/QtWidgets/QtMaterialDialog.hh> 53 #include <ObjectTypes/Light/LightWidget.hh> 55 #include <ACG/Scenegraph/MaterialNode.hh> 64 QItemSelectionModel* selection =
view_->selectionModel();
66 if (selection == 0)
return;
69 QModelIndexList indexList = selection->selectedRows();
73 msgBox.setText(tr(
"Do you really want to remove the selected objects?"));
74 msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
75 msgBox.setDefaultButton(QMessageBox::Yes);
79 for (
int i = 0 ; i < indexList.size() ; ++i)
82 msgBox.setDetailedText(text);
84 if ( msgBox.exec() == QMessageBox::No)
87 for (
int i = 0 ; i < indexList.size() ; ++i) {
93 emit deleteObject(
id );
106 QItemSelectionModel* selection =
view_->selectionModel();
109 QModelIndexList indexList = selection->selectedRows ( 0 );
123 QItemSelectionModel* selection =
view_->selectionModel();
125 if (selection == 0)
return;
128 QModelIndexList indexList = selection->selectedRows();
130 for (
int i = 0 ; i < indexList.size() ; ++i) {
138 emit copyObject(
id, newObject );
154 QItemSelectionModel* selection =
view_->selectionModel();
157 QModelIndexList indexList = selection->selectedRows ( 0 );
162 for (
int i = 0; i < indexList.size(); ++i)
168 emit objectsGrouped(ids);
188 QItemSelectionModel* selection =
view_->selectionModel();
191 QModelIndexList indexList = selection->selectedRows ( 0 );
192 int selectedRows = indexList.size();
197 if ( selectedRows > 1 ) {
198 action = menu.addAction(
"Copy",
this,SLOT (
slotCopy() ));
199 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"edit-copy.png");
200 action->setIcon(icon);
201 menu.addAction(tr(
"Group"),
this,SLOT (
slotGroup() ));
206 if ( item->isGroup() ) {
207 action = menu.addAction(tr(
"Zoom to objects"),
this,SLOT (
slotZoomTo() ));
208 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"zoom-in.png");
209 action->setIcon(icon);
210 menu.addAction(tr(
"Ungroup"),
this,SLOT (
slotUngroup() ));
212 action = menu.addAction(tr(
"Rename"),
this,SLOT (
slotRename() ));
213 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"edit-rename.png");
214 action->setIcon(icon);
217 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"datacontrol-delete-item.png");
218 action->setIcon(icon);
225 QAction* header = menu.addAction(tr(
"Object ")+QString::number(
id)+
": "+item->
name());
232 action = menu.addAction(tr(
"Copy"),
this,SLOT (
slotCopy() ));
233 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"edit-copy.png");
234 action->setIcon(icon);
235 action = menu.addAction(tr(
"Rename"),
this,SLOT (
slotRename() ));
236 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"edit-rename.png");
237 action->setIcon(icon);
239 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"datacontrol-delete-item.png");
240 action->setIcon(icon);
247 action = menu.addAction(tr(
"Switch On"),
this,SLOT (
slotSwitchLight() ));
253 action = menu.addAction(tr(
"Switch Off"),
this,SLOT (
slotSwitchLight() ));
254 icon = QIcon (OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"LightOff.png");
256 action->setIcon(icon);
258 action = menu.addAction(tr(
"Edit Light"),
this,SLOT (
slotEditLight() ));
260 action->setIcon(icon);
263 action = menu.addAction(tr(
"Zoom to object"),
this,SLOT (
slotZoomTo() ));
264 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"zoom-in.png");
265 action->setIcon(icon);
267 action = menu.addAction(tr(
"Copy"),
this,SLOT (
slotCopy() ));
268 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"edit-copy.png");
269 action->setIcon(icon);
271 action = menu.addAction(tr(
"Rename"),
this,SLOT (
slotRename() ));
272 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"edit-rename.png");
273 action->setIcon(icon);
276 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"datacontrol-material.png");
277 action->setIcon(icon);
280 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"datacontrol-copyToTargets-material.png");
281 action->setIcon(icon);
284 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"datacontrol-copy-material.png");
285 action->setIcon(icon);
288 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"datacontrol-paste-material.png");
289 action->setIcon(icon);
291 menu.addAction(tr(
"Group"),
this,SLOT (
slotGroup() ));
295 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"datacontrol-delete-item.png");
296 action->setIcon(icon);
302 menu.exec(
view_->mapToGlobal( _pos) );
322 QVector<DataType> types;
325 if ( !types.contains( o_it->dataType() ) )
326 types.push_back( o_it->dataType() );
336 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"drawModes.png");
337 action = menu.addAction(icon,tr(
"Show all"),
this,SLOT (
showAll() ));
338 action->setData( QVariant() );
340 if (types.count() > 1)
341 for (
int i=0; i < types.count(); i++){
342 action = menu.addAction(icon, tr(
"Show all of type '") +
dataTypeName(types[i]) +
"'",
this,SLOT (
showAll() ));
343 action->setData( QVariant( types[i].value() ) );
347 action = menu.addAction(tr(
"Hide all"),
this,SLOT (
hideAll() ));
348 action->setData( QVariant() );
350 if (types.count() > 1)
351 for (
int i=0; i < types.count(); i++){
352 action = menu.addAction(tr(
"Hide all of type '") +
dataTypeName(types[i]) +
"'",
this,SLOT (
hideAll() ));
353 action->setData( QVariant( types[i].value() ) );
359 action = menu.addAction(tr(
"Select all"),
this,SLOT (
setAllSource() ));
360 action->setData( QVariant() );
362 if (types.count() > 1)
363 for (
int i=0; i < types.count(); i++){
364 action = menu.addAction(icon, tr(
"Select all of type '") +
dataTypeName(types[i]) +
"'",
this,SLOT (
setAllSource() ));
365 action->setData( QVariant( types[i].value() ) );
369 action = menu.addAction(tr(
"Deselect all"),
this,SLOT (
clearAllSource() ));
370 action->setData( QVariant() );
372 if (types.count() > 1)
373 for (
int i=0; i < types.count(); i++){
375 action->setData( QVariant( types[i].value() ) );
381 action = menu.addAction(tr(
"Select all"),
this,SLOT (
setAllTarget() ));
382 action->setData( QVariant() );
384 if (types.count() > 1)
385 for (
int i=0; i < types.count(); i++){
386 action = menu.addAction(icon, tr(
"Select all of type '") +
dataTypeName(types[i]) +
"'",
this,SLOT (
setAllTarget() ));
387 action->setData( QVariant( types[i].value() ) );
391 action = menu.addAction(tr(
"Deselect all"),
this,SLOT (
clearAllTarget() ));
392 action->setData( QVariant() );
394 if (types.count() > 1)
395 for (
int i=0; i < types.count(); i++){
397 action->setData( QVariant( types[i].value() ) );
416 QItemSelectionModel* selection =
view_->selectionModel();
419 QModelIndexList indexList = selection->selectedRows ( 0 );
420 int selectedRows = indexList.size();
421 if (selectedRows == 1){
428 QString newName = QInputDialog::getText(0, tr(
"Rename"),
429 tr(
"Enter a new name:"), QLineEdit::Normal,
431 if (ok && !newName.isEmpty()){
433 view_->resizeColumnToContents(0);
449 QAction* action =
dynamic_cast< QAction*
> ( sender() );
454 int id = action->data().toInt(&ok);
462 QItemSelectionModel* selection =
view_->selectionModel();
465 QModelIndexList indexList = selection->selectedRows ( 0 );
466 int selectedRows = indexList.size();
467 if (selectedRows == 1){
482 MaterialNode *
const materialNode = o_it->materialNode();
484 materialNode->
material() = sourceMaterial;
496 QAction* action =
dynamic_cast< QAction*
> ( sender() );
501 int id = action->data().toInt(&ok);
509 QItemSelectionModel* selection =
view_->selectionModel();
512 QModelIndexList indexList = selection->selectedRows ( 0 );
513 int selectedRows = indexList.size();
514 if (selectedRows == 1){
527 const QString materialJson = sourceMaterial.serializeToJson();
528 QApplication::clipboard()->setText(materialJson);
536 QAction* action =
dynamic_cast< QAction*
> ( sender() );
541 int id = action->data().toInt(&ok);
549 QItemSelectionModel* selection =
view_->selectionModel();
552 QModelIndexList indexList = selection->selectedRows ( 0 );
553 int selectedRows = indexList.size();
554 if (selectedRows == 1){
567 destMaterial.deserializeFromJson(QApplication::clipboard()->text());
578 QAction* action =
dynamic_cast< QAction*
> ( sender() );
583 int id = action->data().toInt(&ok);
591 QItemSelectionModel* selection =
view_->selectionModel();
594 QModelIndexList indexList = selection->selectedRows ( 0 );
595 int selectedRows = indexList.size();
596 if (selectedRows == 1){
610 dialog->setWindowFlags(dialog->windowFlags() | Qt::WindowStaysOnTopHint);
615 dialog->setWindowIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"datacontrol-material.png"));
636 QItemSelectionModel* selection =
view_->selectionModel();
639 QModelIndexList indexList = selection->selectedRows ( 0 );
640 int selectedRows = indexList.size();
641 if (selectedRows == 1) {
649 if(light == 0)
return;
666 QItemSelectionModel* selection =
view_->selectionModel();
669 QModelIndexList indexList = selection->selectedRows ( 0 );
670 int selectedRows = indexList.size();
671 if (selectedRows == 1) {
679 if(light == 0)
return;
682 widget->setWindowFlags(Qt::WindowStaysOnTopHint);
693 QItemSelectionModel* selection =
view_->selectionModel();
696 QModelIndexList indexList = selection->selectedRows ( 0 );
697 int selectedRows = indexList.size();
698 if (selectedRows == 1){
707 QList< BaseObject* > children = item->
getLeafs();
710 bool firstRound =
true;
714 for (
int i=0; i < children.size(); i++){
732 bbmin[0] = std::min( bbmin[0], cur_min[0]);
733 bbmin[1] = std::min( bbmin[1], cur_min[1]);
734 bbmin[2] = std::min( bbmin[2], cur_min[2]);
735 bbmax[0] = std::max( bbmax[0], cur_max[0]);
736 bbmax[1] = std::max( bbmax[0], cur_max[1]);
737 bbmax[2] = std::max( bbmax[0], cur_max[2]);
745 double bbradius = (bbmax - bbmin).norm();
765 if ((bbmin[0] > bbmax[0]) || (bbmin[1] > bbmax[1]) || (bbmin[2] > bbmax[2])){
766 std::cerr <<
"Error while computing bounding box!";
772 double bbradius = (bbmax - bbmin).norm();
void hideAll()
Hides all objects.
LightSource * lightSource()
void disable()
disable LightSource
DLLEXPORT QString dataTypeName(DataType _id)
Get DataType Human readable name ( this name might change. Use the typeName instead! ) ...
QList< BaseObject *> getLeafs()
get all leafes of the tree below this object ( These will be all visible objects ) ...
void showAll()
Shows all objects.
bool enabled() const
Get light source status.
virtual void show()
Sets the whole Scenegraph subtree of this node to visible.
int groupObjects(IdList _objectIDs, QString _groupName="")
Group given Objects together.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
QHeaderView * viewHeader_
Pointer to the header to the view widget.
void slotSwitchLight()
Called by the popup menu in order to turn lights on/off.
QModelIndex popupIndex_
Index where a popup has been opened.
void slotCopyMaterialToTargeted()
Called by the popup menu to copy material properties.
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
bool unGroupObject(int _id)
void slotNodeChanged(ACG::SceneGraph::BaseNode *_node)
Called when the material properties were changed inside the material dialog.
void clearAllTarget()
Unselect all objects.
const QStringList ALL_OBJECTS
Iterable object range.
void slotCopy()
Called by the popup menu to copy items.
void slotCopyMaterialToClipboard()
Called by the popup menu to copy material properties to clipboard.
void setAllTarget()
Makes all available objects target.
TreeItem * getItem(const QModelIndex &_index) const
Get the TreeItem corresponding to a given ModelIndex.
void slotHeaderCustomContextMenuRequested(const QPoint &_pos)
Display a custom context window for the TreeViews header.
bool dataType(DataType _type) const
std::vector< int > IdList
Standard Type for id Lists used for scripting.
TreeModel * model_
The Treemodel organizing the data.
int itemId(const QModelIndex &_index) const
Get the id of a TreeItem corresponding to a given ModelIndex.
QTreeView * view_
Tree view.
virtual void setName(QString _name)
path to the file from which the object is loaded ( defaults to "." )
void setAllSource()
Makes all available objects source.
QString name() const
return the name of the object. The name defaults to NONAME if unset.
ACG::Vec3d eyePos(int _viewer)
Get the current viewer position.
void slotCustomContextMenuRequested(const QPoint &_pos)
Display a custom context window for the TreeView.
void slotUngroup()
Called by the popup menu to ungroup items.
QString itemName(const QModelIndex &_index) const
Get the name of a TreeItem corresponding to a given ModelIndex.
void slotGroup()
Called by the popup menu to group items.
void enable()
enable LightSource
const QStringList TARGET_OBJECTS("target")
Iterable object range.
MaterialNode * materialNode()
get a pointer to the materialnode
bool isGroup() const
Check if object is a group.
ObjectRange objects(IteratorRestriction _restriction, DataType _dataType)
Iterable object range.
void slotZoomTo()
Called by the popup menu to zoom to an object.
void clearAllSource()
remove source selection from all objects
void slotMaterialProperties()
Called by the popup menu to set material properties.
int headerPopupType_
Defines the section of the Popup.
void slotPasteMaterialFromClipboard()
Called by the popup menu to paste material properties from clipboard.
void getBoundingBox(ACG::Vec3d &bbmin, ACG::Vec3d &bbmax)
get the bounding box of the object
void slotEditLight()
Called by the popup menu in order to edit lights.
LightNode * lightNode()
Get the scenegraph Node.
DLLEXPORT QIcon & typeIcon(DataType _id)
Get an QIcon associated with the given DataType.
ACG::SceneGraph::Material & material()
Get material object reference.
virtual bool visible() override
return visiblity
void slotRename()
Called by the popup menu to rename items.
void flyTo(const ACG::Vec3d &_position, const ACG::Vec3d &_center, double _time)
Fly to point and viewing direction (animated).
void slotPopupRemove()
Called by the popup menu to remove an object/group.